实验描述:
通过三层交换机实现不同vlan间通信
1、配置各pc的ip地址(跳过)
2、配置switch3
Switch>en
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 2
Switch(config-vlan)#exit
Switch(config)#vla
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-if)#exit
Switch(config)#interface fastEthernet 0/1
Switch(config-if)#switchport mode trunk
Switch#show vlan
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/4, Fa0/5, Fa0/6, Fa0/7
Fa0/8, Fa0/9, Fa0/10, Fa0/11
Fa0/12, Fa0/13, Fa0/14, Fa0/15
Fa0/16, Fa0/17, Fa0/18, Fa0/19
Fa0/20, Fa0/21, Fa0/22, Fa0/23
Fa0/24, Gig0/1, Gig0/2
2 VLAN0002 active Fa0/2
3 VLAN0003 active Fa0/3
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
2 enet 100002 1500 - - - - - 0 0
3 enet 100003 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface fastEthernet 0/4
Switch(config-if)#switchport access vlan 3
Switch(config-if)#exit
3、配置三层交换机Switch4
Switch(config )#int fa 0/1
Switch(config-if)#switchport trunk encapsulation dot1q //给该接口的trunk封装为802.1Q的帧格式
Switch(config-if)#switchport mode trunk //定义该接口的工作模式为trunk
Switch(config-if)#ex
#模式切换
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
#创建vlan2 3
Switch(config)#vlan 2
Switch(config-vlan)#exit
Switch(config)#vlan 3
Switch(config-vlan)#exit
#讲接口2 3 分别添加到vlan2 3
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-if)#exit
#给vlan2 3配置ip地址
Switch(config)#interface vlan 2
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan2, changed state to up
Switch(config-if)#ip address 192.168.1.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#interface vlan 3
Switch(config-if)#
%LINK-5-CHANGED: Interface Vlan3, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to up
Switch(config-if)#interface vlan 3
Switch(config-if)#ip address 192.168.2.1 255.255.255.0
Switch(config-if)#no shutdown
Switch(config-if)#end
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#conf t
Switch(config)#ip routing //启动IP路由
Switch#show ip route //显示路由表
Switch#show vlan //显示vlan信息
4、注意事项
A、switch4上面只有一个网段不用做任何处理,只需将swich3上的接口4加入到我们的vlan3即可
B、pc13 14 要分别连接到我们配置好对应gateway方可通信
5、通过测试,此时我们的所有pc间都能正常通信