pc1 ip192.168.1.1
subnet mask 255.255.255.0
default getway 192.168.1.254
pc2 ip 192.168.2.1
subnet mask 255.255.255.0
default getway 192.168.2.254
交換機配置:
交換機
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#
Switch(config)#host SW1
SW1(config)#
SW1(config)#vlan 2
SW1(config-vlan)#int fa 0/1 鏈接PC1的交換機端口
SW1(config-if)#swi mode acc
SW1(config-if)#int fa 0/12
SW1(config-if)#swi mode trunk 把交換機鏈接路由器的端口配置成主幹端口,在交換機和路由器間使用主幹鏈路。
SW1(config-if)#int fa 0/13 鏈接PC2的交換機端口
SW1(config-if)#swi mode acc
SW1(config-if)#swi acc vlan 2
SW1(config-if)#end
路由器配置:
R1Router(config)#host R1
R1(config)#int fa 0/0
R1(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#exit
R1(config)#int fa 0/0.1 使用第一個子接口做爲VLAN 1的網關,子接口編號與VLAN號沒有必然聯繫
%LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.1, changed state to upR1(config-subif)#enca dot 1 默認封裝協議是dot 1Q,1是指VLAN的編號
R1(config-subif)#ip add 192.168.1.254 255.255.255.0
R1(config-subif)#int fa 0/0.200 第200個子接口做爲VLAN 2的網關
%LINK-5-CHANGED: Interface FastEthernet0/0.200, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.200, changed state to upR1(config-subif)#enca dot 2 子接口200的封裝協議是dot1Q,相關的VLAN 號是2 R1(config-subif)#ip add 192.168.2.254 255.255.255.0