划分vlan
[Huawei]vlan batch 10 20
interface Ethernet0/0/1
port link-type access
port default vlan 10
interface Ethernet0/0/2
port link-type access
port default vlan 20
配置trunk
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan all
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 2 to 4094
交换机SW2命令
划分vlan
[Huawei]vlan batch 10 20
interface Ethernet0/0/3
port link-type access
port default vlan 10
配置trunk
interface Ethernet0/0/4
port link-type access
port default vlan 20
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
交换机SW3命令
划分vlan
[Huawei]vlan batch 10 20 30
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 30
在三层交换机的vlanif里配置网关和直连路由的IP地址
interface Vlanif10
ip address 192.168.10.1 255.255.255.0
interface Vlanif20
ip address 192.168.20.1 255.255.255.0
interface Vlanif30
ip address 12.0.0.1 255.255.255.252
配置默认路由
ip route-static 0.0.0.0 0.0.0.0 12.0.0.2
交换机SW4命令
划分vlan
interface Ethernet0/0/1
port link-type access
port default vlan 30
interface Ethernet0/0/2
port link-type access
port default vlan 40
将g0/0/1到g0/0/2接口进行链路捆绑,并且设置为trunk口,允许所有vlan通过。
[Huawei]int Eth-Trunk 1
[Huawei-Eth-Trunk1]trunkport g 0/0/1 to 0/0/2
[Huawei-Eth-Trunk1]port link-type trunk
[Huawei-port-group-trunk]port trunk allow-pass vlan all
[Huawei-port-group-trunk]un sh
路由器R1命令
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 12.0.0.2 30
[Huawei]int Eth-Trunk 1
[Huawei-Eth-Trunk1]trunkport GigabitEthernet 0/0/1 to 0/0/2
将路由器R1设置成单臂路由。
interface Eth-Trunk1.30
dot1q termination vid 30
ip address 192.168.30.1 255.255.255.0
arp broadcast enable
interface Eth-Trunk1.40
dot1q termination vid 40
ip address 192.168.40.1 255.255.255.0
arp broadcast enable