交换机配置
Switch>
Switch>en
Switch#vlan data
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 2 name te2
VLAN 2 modified:
Name: te2
Switch(vlan)#vlan 3 name te3
VLAN 3 modified:
Name: te3
Switch(vlan)#vlan 4 name te4
VLAN 4 modified:
Name: te4
Switch(vlan)#exit
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#in r f0/1 - 2
Switch(config-if-range)#sw acc vlan 2
Switch(config-if-range)#exit
Switch(config)#in r f0/10 - 12
Switch(config-if-range)#sw acc vlan 3
Switch(config-if-range)#exit
Switch(config)#in r f0/20 - 21
Switch(config-if-range)#sw acc vlan 4
Switch(config-if-range)#exit
Switch(config)#in f0/24
Switch(config-if)#switchport mode trunk
路由配置
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#in f0/0
Router(config-if)#no shutdown
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#exit
这时可以去交换机show 24端口看看是不是trunk
Switch#sho in f0/24 sw
Name: Fa0/24
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk
继续配置路由
Router(config)#in f0/0.1 开启子接口
%LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.1, changed state to up
Router(config-subif)#en
Router(config-subif)#encapsulation dot1Q 2 封装成802.1Q (PS:有人先配IP,在封装,我测试这样不会成功)
Router(config-subif)#ip add 192.168.1.1 255.255.255.0
Router(config-subif)#exit
Router(config)#in f0/0.2
%LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.2, changed state to up
Router(config-subif)#encapsulation dot1Q 3
Router(config-subif)#ip add 192.168.2.1 255.255.255.0
Router(config-subif)#exit
Router(config)#in f0/0.3
%LINK-5-CHANGED: Interface FastEthernet0/0.3, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.3, changed state to up
Router(config-subif)#encapsulation dot1Q 4
Router(config-subif)#ip add 192.168.3.1 255.255.255.0
Router(config-subif)#exit
