SW1
[sw1]vlan batch 10 20 100
[sw1]int g0/0/4
[sw1-GigabitEthernet0/0/4]port link-type access
[sw1-GigabitEthernet0/0/4]port default vlan 10
[sw1-GigabitEthernet0/0/4]int vlanif 10
[sw1-Vlanif10]ip address 192.168.10.254 24
[sw1]int g0/0/5
[sw1-GigabitEthernet0/0/5]port link-type access
[sw1-GigabitEthernet0/0/5]port default vlan 20
[sw1-GigabitEthernet0/0/5]int vlanif 20
[sw1-Vlanif20]ip address 192.168.20.254 24
[sw1]int Eth-Trunk 1
[sw1-Eth-Trunk1]int g 0/0/1
[sw1-GigabitEthernet0/0/1]eth-trunk 1
[sw1-Eth-Trunk1]int g 0/0/2
[sw1-GigabitEthernet0/0/2]eth-trunk 1
[sw1-Eth-Trunk1]int g 0/0/3
[sw1-GigabitEthernet0/0/3]eth-trunk 1
[sw1]int Eth-Trunk 1
[sw1-Eth-Trunk1]port link-type trunk
[sw1-Eth-Trunk1]port trunk allow-pass vlan all
[sw1-Eth-Trunk1]port trunk pvid vlan 100
[sw1-Eth-Trunk1]int vlanif 100
[sw1-Vlanif100]ip address 10.10.20.1 30
ip route-static 10.10.10.0 30 10.10.20.2
ip route-static 10.10.12.0 30 10.10.20.2
SW2
[sw2]vlan batch 10 20 100
[sw2]int g0/0/7
[sw2-GigabitEthernet0/0/7]port link-type access
[sw2-GigabitEthernet0/0/7]port default vlan 10
[sw2-GigabitEthernet0/0/7]int vlanif 10
[sw2-Vlanif10]ip address 192.168.10.254 24
[sw2]int g0/0/8
[sw2-GigabitEthernet0/0/8]port link-type access
[sw2-GigabitEthernet0/0/8]port default vlan 20
[sw2-GigabitEthernet0/0/8]int vlanif 20
[sw2-Vlanif20]ip address 192.168.20.254 24
[sw2]int Eth-Trunk 1
[sw2-Eth-Trunk1]int g 0/0/4
[sw2-GigabitEthernet0/0/4]eth-trunk 1
[sw2-Eth-Trunk1]int g 0/0/5
[sw2-GigabitEthernet0/0/5]eth-trunk 1
[sw2-Eth-Trunk1]int g 0/0/6
[sw2-GigabitEthernet0/0/6]eth-trunk 1
[sw2]int Eth-Trunk 1
[sw2-Eth-Trunk1]port link-type trunk
[sw2-Eth-Trunk1]port trunk allow-pass vlan all
[sw2-Eth-Trunk1]port trunk pvid vlan 100
[sw2-Eth-Trunk1]int vlanif 100
[sw2-Vlanif100]ip address 10.10.20.2 30
[sw2]int Eth-Trunk 2
[sw2-Eth-Trunk1]int g 0/0/1
[sw2-GigabitEthernet0/0/1]eth-trunk 2
[sw2-Eth-Trunk1]int g 0/0/2
[sw2-GigabitEthernet0/0/2]eth-trunk 2
[sw2-Eth-Trunk1]int g 0/0/3
[sw2-GigabitEthernet0/0/3]eth-trunk 2
[sw2]int Eth-Trunk 2
[sw2-Eth-Trunk2]port link-type access
[sw2-Eth-Trunk2]port default vlan 1
[sw2-Eth-Trunk2]int vlanif 1
[sw2-Vlanif1]ip address 10.10.10.2 30
ip route-static 10.10.12.0 30 10.10.10.1
R1
[r1]int Eth-Trunk 2
[r1-Eth-Trunk2]undo portswitch
[r1-Eth-Trunk2]int g0/0/0
[r1-GigabitEthernet0/0/0]eth-trunk 2
[r1-Eth-Trunk2]int g0/0/1
[r1-GigabitEthernet0/0/1]eth-trunk 2
[r1-Eth-Trunk2]int g0/0/2
[r1-GigabitEthernet0/0/2]eth-trunk 2
[r1-GigabitEthernet0/0/2]int eth 2
[r1-Eth-Trunk2]ip address 10.10.10.1 30
[r1]int g4/0/0
[r1-GigabitEthernet4/0/0]ip address 10.10.12.1 30
ip route-static 192.168.0.0 16 10.10.10.2
R2
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip address 10.10.12.2 30
ip route-static 0.0.0.0 0 10.10.12.
标签:int,trunk,GigabitEthernet0,交换机,链路,sw1,Eth,sw2,路由器 From: https://blog.csdn.net/2401_86336750/article/details/144582587