| 关键词: nbsp config 192.168 VLAN 接口 配置 路由器 fastEthernet interface 交换机 |
【实验名称】VLAN/802.1Q-VLAN间的通信【实验目的】通过路由器实现VLAN间互相通信【实验功能】使在同一VLAN里的计算机系统能跨路由器进行相互通信,而在不同VLAN里的计算机系统也能进行相互通信【实验设备】路由器(1台)、交换机(1台)、PC(2台) 直连线(3条)(因为前面已经配置了一个《利用三层交换机实现不同VLAN的相互通信》 ,所以这里用一个简单的TP来说明! 配置都一样 在这里主要阐述路由器的配置)【实验步骤】交换机Switch>enableSwitch#configure terminalSwitch(config)#vlan 2Switch(config-vlan)#exitSwitch(config)#vlan 3Switch(config-vlan)#exitSwitch(config)#interface fastEthernet 0/2Switch(config-if)#switchport access vlan 2Switch(config-if)#exitSwitch(config)#interface fastEthernet 0/3Switch(config-if)#switchport access vlan 3Switch(config)#interface fastEthernet 0/24 Switch(config-if)#switchport mode trunk(配置到这里你会发现 二层交换机 配来配去 就那么几步! 创建VLAN 把端口划分到VLAN 然后设置TRUNK口)是不是觉得 二层太小儿科! 呵呵 是这样的 ! 我们要在#战略上藐视敌人,战术上重视敌人#! 虽然简单,也不能大意!接下来本节重点路由器:Router>enableRouter#configure terminalRouter(config)#interface fastEthernet 0/0 (与二层TRUNK口连接的物理接口只需要打开)Router(config-if)#no shutdownRouter(config-if)#exitRouter(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)#exitRouter(config)#interface fastEthernet 0/0.3 (同样给VLAN3)Router(config-subif)#encapsulation dot1Q 3Router(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.254VLAN3 PC配置IP 192.168.3.1 255.255.255.0 网关192.168.3.254发现PC>ping 192.168.3.1Pinging 192.168.3.1 with 32 bytes of data:Reply from 192.168.3.1: bytes=32 time=96ms TTL=127Reply from 192.168.3.1: bytes=32 time=125ms TTL=127Reply from 192.168.3.1: bytes=32 time=125ms TTL=127Reply from 192.168.3.1: bytes=32 time=125ms TTL=127Ping 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通过路由器实现了通信!! |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|