本主要介绍:
在cisco中通过L3交换机实现VLAN间通讯。
拓扑
拓扑A:
配置过程
配置步骤1:sw2
SW2#vlan data
SW2(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
SW2(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
SW2(vlan)#apply
APPLY completed.
SW2(vlan)#exit
APPLY completed.
Exiting....
SW2#conf t
SW2(config)#i no ip routing
SW2(config)#interface f0/0
SW2(config-if)#switchport mode trunk
SW2(config-if)#switchport trunk encapsulation dot1q
SW2(config-if)#no shut
SW2(config-if)#exit
SW2(config)#interface f0/1
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 10
SW2(config-if)#no shut
SW2(config-if)#exit
SW2(config)#interface f0/2
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 10
SW2(config-if)#no shut
SW2(config-if)#exit
SW2(config)#interface f0/3
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 20
SW2(config-if)#no shut
SW2(config-if)#end
SW2#copy run start
配置步骤2:sw3
SW3#vlan data
SW3(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
SW3(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
SW3(vlan)#apply
APPLY completed.
SW3(vlan)#exit
APPLY completed.
Exiting....
SW3#conf t
SW3(config)#i no ip routing
SW3(config)#interface f0/0
SW3(config-if)#switchport mode trunk
SW3(config-if)#switchport trunk encapsulation dot1q
SW3(config-if)#no shut
SW3(config-if)#exit
SW3(config)#interface f0/1
SW3(config-if)#switchport mode access
SW3(config-if)#switchport access vlan 10
SW3(config-if)#no shut
SW3(config-if)#exit
SW3(config)#interface f0/2
SW3(config-if)#switchport mode access
SW3(config-if)#switchport access vlan 20
SW3(config-if)#no shut
SW3(config-if)#end
SW3#copy run start
配置步骤3:sw1
SW1#vlan data
SW1(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
SW1(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
SW1(vlan)#apply
APPLY completed.
SW1(vlan)#exit
APPLY completed.
Exiting....
SW1#conf t
SW1(config)#ip routing
SW1(config)#interface f0/0
SW1(config-if)#switchport mode trunk
SW1(config-if)#switchport trunk encapsulation dot1q
SW1(config-if)#no shut
SW1(config-if)#exit
SW1(config)#interface f0/1
SW1(config-if)#switchport mode trunk
SW1(config-if)#switchport trunk encapsulation dot1q
SW1(config-if)#no shut
SW1(config-if)#exit
SW1(config)#interface f0/2
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 10
SW1(config-if)#no shut
SW1(config-if)#exit
SW1(config)#interface f0/3
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 20
SW1(config-if)#no shut
SW1(config-if)#exit
SW1(config)#inter vlan 10
SW1(config-if)#ip address 192.168.10.254 255.255.255.0
SW1(config-if)#no shut
SW1(config-if)#exit
SW1(config)#inter vlan 20
SW1(config-if)#ip address 192.168.20.254 255.255.255.0
SW1(config-if)#no shut
SW1(config-if)#end
SW1#copy run start
其实对于L3 Switch只要有VLAN信息即可,不要划分物理端口到VLAN
这句话似乎在GNS3环境中并不正确.
配置步骤4:pc
PC-1#ip 192.168.10.1 255.255.255.0 192.168.10.254
PC-1#save
PC-2#ip 192.168.10.2 255.255.255.0 192.168.10.254
PC-2#save
PC-3#ip 192.168.20.3 255.255.255.0 192.168.20.254
PC-3#save
PC-4#ip 192.168.10.4 255.255.255.0 192.168.10.254
PC-4#save
PC-5#ip 192.168.20.5 255.255.255.0 192.168.20.254
PC-5#save
PC-6#ip 192.168.10.6 255.255.255.0 192.168.10.254
PC-6#save
PC-7#ip 192.168.20.7 255.255.255.0 192.168.20.254
PC-7#save
最终所有PC两两间都能互相ping通。
扩展一下拓扑
拓扑B:
配置过程
以下配置在拓扑A的配置基础上追加。
配置步骤5:sw3
SW3#vlan data
SW3(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
SW3(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
SW3(vlan)#apply
APPLY completed.
SW3(vlan)#exit
APPLY completed.
Exiting....
SW3#conf t
SW3(config)#interface f0/3
SW3(config-if)#switchport mode trunk
SW3(config-if)#switchport trunk encapsulation dot1q
SW3(config-if)#no shut
SW3(config-if)#end
配置步骤6:sw4
SW4#vlan data
SW4(vlan)#vlan 10
VLAN 10 added:
Name: VLAN0010
SW4(vlan)#vlan 20
VLAN 20 added:
Name: VLAN0020
SW4(vlan)#apply
APPLY completed.
SW4(vlan)#exit
APPLY completed.
Exiting....
SW4#conf t
SW4(config)#i no p routing
SW4(config)#interface f0/0
SW4(config-if)#switchport mode trunk
SW4(config-if)#switchport trunk encapsulation dot1q
SW4(config-if)#no shut
SW4(config-if)#exit
SW4(config)#interface f0/1
SW4(config-if)#switchport mode access
SW4(config-if)#switchport access vlan 10
SW4(config-if)#no shut
SW4(config-if)#exit
SW4(config)#interface f0/2
SW4(config-if)#switchport mode access
SW4(config-if)#switchport access vlan 20
SW4(config-if)#no shut
SW4(config-if)#end
SW4#copy run start
配置过程7:pc
PC-8#ip 192.168.10.8 255.255.255.0 192.168.10.254
PC-8#save
PC-9#ip 192.168.20.9 255.255.255.0 192.168.20.254
PC-9#save
最终所有PC两两间都能互相ping通。
也可以这样扩展:
只是这样扩展会占用L3交换机的端口;上一种扩展占用L2交换机的端口。