VLAN间路由——实验验证

在这里插入图片描述
设有如上图所示的设备。要求:全网使用192.168.1.0/24网段,使PC 3能够ping通PC 7,PC 4不能ping通PC 6.
一、实验步骤
1.分别为每台设备做基本配置
SW 1:

sw1#config terminal
sw1(config)#vlan 10
sw1(config-vlan)#vlan 20
sw1(config-vlan)#vlan 30

SW 2:

sw2#config terminal
sw2(config)#vlan 10
sw2(config-vlan)#vlan 20
sw2(config-vlan)#vlan 30

PC 3:pc3> ip 192.168.1.3 /24 192.168.1.1

PC 4:pc4> ip 192.168.1.4 /24 192.168.1.1

PC 5:pc5> ip 192.168.1.5 /24 192.168.1.2

PC 6:pc6> ip 192.168.1.6 /24 192.168.1.2

PC 7:pc7> ip 192.168.1.7 /24 192.168.1.2

PC 8:pc8> ip 192.168.1.8 /24 192.168.1.1

2.划分VLAN
SW 1:

sw1(config)#interface e0/0
sw1(config-if)#switchport trunk encapsulation dot1q
sw1(config-if)#switchport mode trunk
sw1(config-if)#exit 
sw1(config)#interface e0/1
sw1(config-if)#switchport mode access
sw1(config-if)#switchport access vlan 30
sw1(config-if)#exit
sw1(config)#interface e0/2
sw1(config-if)#switchport mode access
sw1(config-if)#switchport access vlan 20
sw1(config-if)#exit
sw1(config)#interface e0/3
sw1(config-if)#switchport mode access
sw1(config-if)#switchport access vlan 10

SW 2:

sw2(config)#interface e0/0
sw2(config-if)#switchport mode access
sw2(config-if)#switchport access vlan 20
sw2(config-if)#exit
sw2(config)#interface e0/1
sw2(config-if)#switchport mode access
sw2(config-if)#switchport access vlan 30
sw2(config-if)#exit
sw2(config)#interface e0/2
sw2(config-if)#switchport mode access
sw2(config-if)#switchport access vlan 10
sw2(config-if)#exit
sw2(config)#interface e0/3
sw2(config-if)#switchport trunk encapsulation dot1q
sw2(config-if)#switchport mode trunk

VLAN划分完成后,VLAN内的设备可以相互通信。但若要实现PC 3 ping通 PC 7,还需修改SW 1的本征VLAN

3.修改本征VLAN

SW 1

sw1(config)#interface e0/0
sw1(config-if)#switchport trunk native vlan 10	!修改SW 1的本征VLAN为vlan 10

SW 2

sw2(config)#interface e0/3
sw2(config-if)#switchport trunk native vlan 30	!修改SW 2的本征VLAN为vlan 30

验证:

pc3> ping 192.168.1.7

84 bytes from 192.168.1.7 icmp_seq=1 ttl=64 time=1.259 ms
84 bytes from 192.168.1.7 icmp_seq=2 ttl=64 time=1.495 ms
84 bytes from 192.168.1.7 icmp_seq=3 ttl=64 time=1.054 ms
84 bytes from 192.168.1.7 icmp_seq=4 ttl=64 time=1.409 ms
84 bytes from 192.168.1.7 icmp_seq=5 ttl=64 time=1.820 ms
pc7> ping 192.168.1.3

84 bytes from 192.168.1.3 icmp_seq=1 ttl=64 time=3.970 ms
84 bytes from 192.168.1.3 icmp_seq=2 ttl=64 time=2.281 ms
84 bytes from 192.168.1.3 icmp_seq=3 ttl=64 time=3.886 ms
84 bytes from 192.168.1.3 icmp_seq=4 ttl=64 time=0.859 ms
84 bytes from 192.168.1.3 icmp_seq=5 ttl=64 time=1.719 ms

修改完本征VLAN后,PC 3可以 ping 通PC 7
但此时PC 4因为与PC 6同为VLAN 20内的设备,依旧能够相互ping通

4.修改VLAN的通过权限

只需在SW 1上配置如下命令

sw1(config-if)#switchport trunk allowed vlan execpt 20
!该接口不允许传输vlan 20 的流量

配置完成后,验证结果为:

pc4> ping 192.168.1.6

192.168.1.6 icmp_seq=1 timeout
192.168.1.6 icmp_seq=2 timeout
192.168.1.6 icmp_seq=3 timeout
192.168.1.6 icmp_seq=4 timeout
192.168.1.6 icmp_seq=5 timeout
pc6> ping 192.168.1.4

host (192.168.1.4) not reachable

或在SW 2上配置如下命令

sw2(config-if)#switchport trunk allowed vlan execpt 20

配置完成后,验证结果为:

pc4> ping 192.168.1.6

host (192.168.1.6) not reachable
pc6> ping 192.168.1.4

192.168.1.4 icmp_seq=1 timeout
192.168.1.4 icmp_seq=2 timeout
192.168.1.4 icmp_seq=3 timeout
192.168.1.4 icmp_seq=4 timeout
192.168.1.4 icmp_seq=5 timeout

两种情况下的验证结果也侧面验证了,交换机之间不能传输同一本征VLAN的数据这一结论

VLAN间路由——学习笔记

发布了20 篇原创文章 · 获赞 17 · 访问量 4518

猜你喜欢

转载自blog.csdn.net/zhang175gl/article/details/103740121
今日推荐