利用路由器实现不同VLAN间的访问

【实验名称】

VLAN/802.1Q-VLAN间的通信

【实验目的】

通过路由器实现VLAN间互相通信

【实验功能】

使在同一VLAN里的计算机系统能跨路由器进行相互通信,而在不同VLAN里的计算机系统也能进行相互通信

【实验设备】

路由器(1台)、交换机(1台)、PC(2台) 直连线(3条)

【实验拓扑】

 

 

 

(因为前面已经配置了一个《利用三层交换机实现不同VLAN的相互通信》 ,所以这里用一个简单的TP来说明! 配置都一样 在这里主要阐述路由器的配置)

【实验步骤】

交换机

Switch>enable
Switch#configure terminal
Switch(config)#vlan 2
Switch(config-vlan)#exit
Switch(config)#vlan 3
Switch(config-vlan)#exit
Switch(config)#interface fastEthernet 0/2
Switch(config-if)#switchport access vlan 2
Switch(config-if)#exit
Switch(config)#interface fastEthernet 0/3
Switch(config-if)#switchport access vlan 3
Switch(config)#interface fastEthernet 0/24
 Switch(config-if)#switchport mode trunk

(配置到这里你会发现 二层交换机 配来配去 就那么几步! 创建VLAN 把端口划分到VLAN 然后设置TRUNK口)

是不是觉得 二层太小儿科!  呵呵   是这样的  ! 我们要在 #战略上藐视敌人,战术上重视敌人#! 虽然简单,也不能大意!

接下来本节重点

路由器:

Router>enable
Router#configure terminal
Router(config)#interface fastEthernet 0/0                                  (与二层TRUNK口连接的物理接口只需要打开)
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#interface fastEthernet 0/0.2                              (进入物理接口的子接口:(.2) 可以想象成物理接口 一个物理接口可以有 几十亿个子接口 子接口可以随意设置)

Router(config-subif)#encapsulation dot1Q 2    (配置子接口的封装协议时dot1Q  后面2要注意!此时不可随意设置 这里的2时VLAN编号 要与交换机相互对应)
Router(config-subif)#ip address 192.168.2.254 255.255.255.0     (配置IP地址 即VLAN2 网关)
Router(config-subif)#exit
Router(config)#interface fastEthernet 0/0.3                    (同样给VLAN3)

Router(config-subif)#encapsulation dot1Q 3
Router(config-subif)#ip address 192.168.3.254 255.255.255.0

此时给VLAN2 PC配置 IP 192.168.2.1 255.255.255.0 网关 192.168.2.254

VLAN3 PC配置 IP 192.168.3.1 255.255.255.0 网关 192.168.3.254

发现

PC>ping 192.168.3.1

Pinging 192.168.3.1 with 32 bytes of data:

Reply from 192.168.3.1: bytes=32 time=96ms TTL=127
Reply from 192.168.3.1: bytes=32 time=125ms TTL=127
Reply from 192.168.3.1: bytes=32 time=125ms TTL=127
Reply from 192.168.3.1: bytes=32 time=125ms TTL=127

Ping statistics for 192.168.3.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 96ms, Maximum = 125ms, Average = 117ms

不同VLAN通过路由器实现了通信!!

原创:胡斌   

我会从简单到难的发表一些我学过的知识,希望能给一些想入门的朋友帮助,也希望找一些志同道合的朋友、老师 给我些指教。 QQ 276200261!

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章