实验要求:
拓扑图
配置
sw1:
[sw1]vlan batch 2 to 6
[sw1]int Ethernet 0/0/2
[sw1-Ethernet0/0/2]port link-type access
[sw1-Ethernet0/0/2]port default vlan 2
[sw1-Ethernet0/0/2]int e 0/0/4
[sw1-Ethernet0/0/4]port link-ty access
[sw1-Ethernet0/0/4]port default vlan 2
[sw1-Ethernet0/0/2]int g 0/0/1
[sw1-GigabitEthernet0/0/1]port link-type trunk
[sw1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[sw1-Ethernet0/0/1]int e 0/0/3
[sw1-Ethernet0/0/3]port hybrid untagged vlan 2 to 6
[sw1-Ethernet0/0/3]port hybrid pvid vlan 3
[sw1-Ethernet0/0/3]int e 0/0/5
[sw1-Ethernet0/0/5]port hybrid untagged vlan 2 to 4
[sw1-Ethernet0/0/5]port hybrid pvid vlan 4
// 此接口做混杂接口,便于配置PVID和允许列表是否封装。因为VLAN3、4、5、6都是同一个区域,如果做trunk接口的话,在做DHCP时需要建立多个子接口就过于麻烦(因为一个子接口只能绑定一个VLAN),所以需要控制接口对数据包的封装。当VLAN3、4、5、6进入次接口时,直接进入物理接口,不需要打标签(路由器不识别此标签),开启DHCP协议。
[sw1]int e 0/0/1
[sw1-Ethernet0/0/1]port hybrid tagged vlan 2
[sw1-Ethernet0/0/1]port hybrid untagged vlan 3 to 6
sw2:
<Huawei>sys
[Huawei]sys sw2
[sw2]vlan batch 2 to 6
[sw2]int g 0/0/1
[sw2-GigabitEthernet0/0/1]port lin
[sw2-GigabitEthernet0/0/1]port link-type trunk
[sw2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[sw2]int e 0/0/1
[sw2-Ethernet0/0/1]port hybrid untagged vlan 2 3 5
[sw2-Ethernet0/0/1]port hybrid pvid vlan 5
[sw2-Ethernet0/0/1]int e 0/0/2
[sw2-Ethernet0/0/2]port hybrid untagged vlan 2 3 6
[sw2-Ethernet0/0/2]port hybrid pvid vlan 6
r1:
<Huawei>sys
[Huawei]sys r1
[r1]int g 0/0/0.1
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]ip add 192.168.1.254 24
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
[r1]int g 0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.2.254 24
[r1-GigabitEthernet0/0/0]dhcp select global
[r1]dhcp enable
[r1]ip pool v2
[r1-ip-pool-v2]network 192.168.1.0 mask 255.255.255.0
[r1-ip-pool-v2]gateway-list 192.168.1.254
[r1-ip-pool-v2]q
[r1]ip pool v3
[r1-ip-pool-v3]network 192.168.2.0 mask 24
[r1-ip-pool-v3]gateway-list 192.168.2.254
[r1-GigabitEthernet0/0/0.2]dhcp select global
[r1-GigabitEthernet0/0/0.1]dhcp select global
结果截图展示