SVI实现VLAN间的通信
拓扑
配置
SW1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
IOU1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. IOU1(config)#hostname SW1 SW1(config)#vlan 10 SW1(config-vlan)#exit SW1(config)#vlan 20 SW1(config-vlan)#exit SW1(config)#interface vlan 10 SW1(config-if)#ip address 192.168.10.1 255.255.255.0 SW1(config-if)#no shutdown SW1(config-if)#exit SW1(config)#interface vlan 20 SW1(config-if)#ip address 192.168.20.1 255.255.255.0 SW1(config-if)#no shutdown SW1(config-if)#exit SW1(config)#interface ethernet 0/0 SW1(config-if)#switchport mode access SW1(config-if)#switchport access vlan 10 SW1(config-if)#exit SW1(config)#interface ethernet 0/1 SW1(config-if)#switchport mode access SW1(config-if)#switchport access vlan 20 SW1(config-if)#exit SW1(config)#ip routing |
PC1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
PC1> ip 192.168.10.10/24 192.168.10.1 Checking for duplicate address... PC1 : 192.168.10.10 255.255.255.0 gateway 192.168.10.1 PC1> show ip NAME : PC1[1] IP/MASK : 192.168.10.10/24 GATEWAY : 192.168.10.1 DNS : MAC : 00:50:79:66:68:00 LPORT : 10000 RHOST:PORT : 192.168.153.129:10000 MTU: : 1500 |
PC2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
PC2> ip 192.168.20.20/24 192.168.20.1 Checking for duplicate address... PC1 : 192.168.20.20 255.255.255.0 gateway 192.168.20.1 PC2> show ip NAME : PC2[1] IP/MASK : 192.168.20.20/24 GATEWAY : 192.168.20.1 DNS : MAC : 00:50:79:66:68:00 LPORT : 10001 RHOST:PORT : 192.168.153.129:10002 MTU: : 1500 |
测试
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# 查看此时路由 SW1(config)#do-exec show ip route Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP + - replicated route, % - next hop override Gateway of last resort is not set 192.168.10.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.10.0/24 is directly connected, Vlan10 L 192.168.10.1/32 is directly connected, Vlan10 192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.20.0/24 is directly connected, Vlan20 L 192.168.20.1/32 is directly connected, Vlan20 # 互ping测试 PC1> ping 192.168.20.20 84 bytes from 192.168.20.20 icmp_seq=1 ttl=63 time=0.990 ms 84 bytes from 192.168.20.20 icmp_seq=2 ttl=63 time=0.500 ms 84 bytes from 192.168.20.20 icmp_seq=3 ttl=63 time=1.479 ms 84 bytes from 192.168.20.20 icmp_seq=4 ttl=63 time=1.488 ms 84 bytes from 192.168.20.20 icmp_seq=5 ttl=63 time=1.466 ms PC2> ping 192.168.10.1 84 bytes from 192.168.10.1 icmp_seq=1 ttl=255 time=0.270 ms 84 bytes from 192.168.10.1 icmp_seq=2 ttl=255 time=0.291 ms 84 bytes from 192.168.10.1 icmp_seq=3 ttl=255 time=0.354 ms 84 bytes from 192.168.10.1 icmp_seq=4 ttl=255 time=0.279 ms 84 bytes from 192.168.10.1 icmp_seq=5 ttl=255 time=0.682 ms |
单臂路由
拓扑
配置
R1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
R1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. R1(config)#interface fastEthernet 0/0 R1(config-if)#no ip address R1(config-if)#no shutdown R1(config-if)#exit R1(config)#interface fastEthernet 0/0.10 R1(config-subif)#encapsulation dot1Q 10 R1(config-subif)#ip address 192.168.10.1 255.255.255.0 R1(config-subif)#no shutdown R1(config-subif)#exit R1(config)#interface fastEthernet 0/0.20 R1(config-subif)#encapsulation dot1Q 20 R1(config-subif)#ip address 192.168.20.1 255.255.255.0 R1(config-subif)#no shutdown |
SW1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
SW1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. SW1(config)#hostname SW1 SW1(config)#vlan 10 SW1(config-vlan)#exit SW1(config)#vlan 20 SW1(config-vlan)#exit SW1(config)#interface ethernet 0/0 SW1(config-if)#switchport trunk encapsulation dot1q SW1(config-if)#switchport mode trunk SW1(config-if)#exit SW1(config)#interface ethernet 0/1 SW1(config-if)#switchport mode access SW1(config-if)#switchport access vlan 10 SW1(config-if)#exit SW1(config)#interface ethernet 0/2 SW1(config-if)#switchport mode access SW1(config-if)#switchport access vlan 20 SW1(config-if)#exit SW1(config)#no ip routing |
PC1
1 2 3 |
PC1> ip 192.168.10.10/24 192.168.10.1 Checking for duplicate address... PC1 : 192.168.10.10 255.255.255.0 gateway 192.168.10.1 |
PC2
1 2 3 |
PC2> ip 192.168.20.20/24 192.168.20.1 Checking for duplicate address... PC1 : 192.168.20.20 255.255.255.0 gateway 192.168.20.1 |
测试
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# 查看路由 R1#show ip route Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set C 192.168.10.0/24 is directly connected, FastEthernet0/0.10 C 192.168.20.0/24 is directly connected, FastEthernet0/0.20 # 互ping测试 PC1> ping 192.168.20.20 84 bytes from 192.168.20.20 icmp_seq=1 ttl=63 time=21.969 ms 84 bytes from 192.168.20.20 icmp_seq=2 ttl=63 time=20.942 ms 84 bytes from 192.168.20.20 icmp_seq=3 ttl=63 time=20.587 ms 84 bytes from 192.168.20.20 icmp_seq=4 ttl=63 time=15.958 ms 84 bytes from 192.168.20.20 icmp_seq=5 ttl=63 time=17.954 ms PC2> ping 192.168.10.1 84 bytes from 192.168.10.1 icmp_seq=1 ttl=255 time=10.994 ms 84 bytes from 192.168.10.1 icmp_seq=2 ttl=255 time=9.620 ms 84 bytes from 192.168.10.1 icmp_seq=3 ttl=255 time=6.651 ms 84 bytes from 192.168.10.1 icmp_seq=4 ttl=255 time=10.978 ms 84 bytes from 192.168.10.1 icmp_seq=5 ttl=255 time=5.743 ms |
跨交换机实现VLAN间的通信
拓扑
注意三层交换机和二层交换机之间vlan使用trunk模式,二层和PC之间使用access模式,配置略