实验拓扑
PC1 F0/0 --- F0/2 SW1 F0/1 --- F0/1 SW2 F0/2 --- F0/0 PC2
1.PC1、PC2同时接入VLAN102
2.PC1、PC2分别用路由器模拟
3.TRUNK封装为公有的802.1q
4.VTP域名为vlan
配置命令
==================================================
#PC1
PC1(config)#no ip routing
PC1(config)#inter f0/0
PC1(config-if)#ip add 10.100.1.1 255.255.255.252
PC1(config-if)#no sh
PC1(config-if)#end
#SW1
SW1#conf t
SW1(config)#inter f0/1
SW1(config-if)#sw mo tr
SW1(config-if)#sw tr en do
SW1(config-if)#end
SW1#vlan da
SW1(vlan)#vtp domain vlan
SW1(vlan)#vlan 102
SW1(vlan)#exi
SW1(config)#inter f0/2
SW1(config-if)#switchport mo ac
SW1(config-if)#sw ac vlan 102
#SW2
SW2#conf t
SW2(config)#inter f0/1
SW2(config-if)#switchport mode tr
SW2(config-if)#sw tr en dot1q
SW2(config-if)#inter f0/2
SW2(config-if)#sw mo ac
SW2(config-if)#sw ac vlan 102
#PC2
PC2(config)#no ip routing
PC2(config)#inter f0/0
PC2(config-if)#ip add 10.100.1.2 255.255.255.252
PC2(config-if)#no sh
PC2(config-if)#end
==================================================
#SW1上查看VLAN
SW1#sh vlan-s
VLAN Name Status Ports
102 VLAN0102 active Fa0/2
#在PC1上ping PC2的IP测试连通性
PC1#ping 10.100.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.100.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 4/7/12 ms
#SW1查看MAC地址表
SW1#sh mac-address-table
Destination Address Address Type VLAN Destination Port
------------------- ------------ ---- --------------------
cc02.14cc.0000 Self 1 Vlan1
cc00.14cc.0000 Dynamic 102 FastEthernet0/2
#PC1上查看ARP表
PC1#sh arp
Protocol Address Age (min) Hardware Addr Type Interface
Internet 10.100.1.2 0 cc01.14cc.0000 ARPA FastEthernet0/0
Internet 10.100.1.1 - cc00.14cc.0000 ARPA FastEthernet0/0
转载自:http://www.oil88.org/archives/vlan-trunk-configuration.html