vlan batch 10 20 interface GigabitEthernet0/0/0.1 dot1q termination vid 10 ip address 192.168.10.1 255.255.255.0 arp broadcast enable
interface GigabitEthernet0/0/0.2 dot1q termination vid 20 ip address 192.168.20.1 255.255.255.0 arp broadcast enable
LSW1
1 2 3 4 5 6 7 8 9 10 11 12
vlan batch 10 20 interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/2 port link-type access port default vlan 10
interface GigabitEthernet0/0/3 port link-type access port default vlan 20
PC1
路由器GigabitEthernet0/0/0.1子接口IP作为网关
PC2
路由器GigabitEthernet0/0/0.2子接口IP作为网关
测试
1 2 3 4 5 6 7 8
PC>ping 192.168.20.2
Ping 192.168.20.2: 32 data bytes, Press Ctrl_C to break Request timeout! From 192.168.20.2: bytes=32 seq=2 ttl=127 time=78 ms From 192.168.20.2: bytes=32 seq=3 ttl=127 time=94 ms From 192.168.20.2: bytes=32 seq=4 ttl=127 time=78 ms From 192.168.20.2: bytes=32 seq=5 ttl=127 time=78 ms