sysname lsw1
vlan batch 10 20 30 40 110 120 199
dhcp enable
#(这里是三层交换的配置,可以替换成单臂路由的配置,见最后)
interface Vlanif10
ip address 192.168.10.1 255.255.255.0
dhcp select interface
dhcp server dns-list 8.8.8.8
interface Vlanif20
ip address 192.168.20.1 255.255.255.0
dhcp select interface
dhcp server dns-list 8.8.8.8
interface Vlanif30
ip address 192.168.30.1 255.255.255.0
dhcp select interface
dhcp server dns-list 8.8.8.8
interface Vlanif40
ip address 192.168.40.1 255.255.255.0
dhcp select interface
dhcp server dns-list 8.8.8.8
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/3
port link-type trunk
port trunk allow-pass vlan 2 to 4094
interface GigabitEthernet0/0/4
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#(这里演示的 hybrid 接口的使用场景,配置完后接口 57 可以通,接口 67 可以通,接口 56 不能通信)
interface GigabitEthernet0/0/5
port hybrid pvid vlan 110
port hybrid untagged vlan 110 199
interface GigabitEthernet0/0/6
port hybrid pvid vlan 120
port hybrid untagged vlan 120 199
interface GigabitEthernet0/0/7
port hybrid pvid vlan 199
port hybrid untagged vlan 110 120 199
lsw2 实验配置
dis cu
sysname lsw2
vlan batch 10 20
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20
interface Ethernet0/0/2
port link-type access
port default vlan 10
interface Ethernet0/0/3
port link-type access
port default vlan 20
lsw3 实验配置:
dis cu
sysname lsw3
vlan batch 10 20
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20
interface Ethernet0/0/2
port link-type access
port default vlan 10
interface Ethernet0/0/3
port link-type access
port default vlan 20
lsw4 实验配置:
dis cu
sysname lsw4
#(这里演示的基于 MAC 来划分 VLAN 的方法)
vlan batch 30 40
vlan 30
mac-vlan mac-address 000b-09cf-6f43 priority 0
vlan 40
mac-vlan mac-address 000b-09cf-7f5f priority 0
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan 30 40
interface Ethernet0/0/2
port hybrid untagged vlan 30 40
mac-vlan enable
interface Ethernet0/0/3
port hybrid untagged vlan 30 40
mac-vlan enable
实验验证
1 接入层交换机上所有 client 123456 设置成 DHCP 地址方式,可以分别得到 vlan 10 20 30 40 vlan 的 ip 并可以相互通信(VLAN Trunk VLAN 路由及 DHCP 功能 )。
2 分布层交换机上的 client 7 和 client 9 可以通信,client 8 和 client 9 可以通信,client 7 和 client 8 不能通信(hybrid 接口功能)
3 对换 client 5 和 client 6 的接口,PC 的 vlan 和 IP 保持不变(MAC VLAN 功能)
附加——路由器的单臂路由的配置:
[R1]dis current-configuration
sysname R1
dhcp enable
interface Ethernet0/0/0
undo shutdown
interface Ethernet0/0/0.10
control-vid 10 dot1q-termination
dot1q termination vid 10
ip address 192.168.10.1 255.255.255.0
arp broadcast enable
dhcp select interface
dhcp server dns-list 8.8.8.8
interface Ethernet0/0/0.20
control-vid 20 dot1q-termination
dot1q termination vid 20
ip address 192.168.20.1 255.255.255.0
arp broadcast enable
dhcp select interface
dhcp server dns-list 8.8.8.8
interface Ethernet0/0/0.30
control-vid 30 dot1q-termination
dot1q termination vid 30
ip address 192.168.30.1 255.255.255.0
arp broadcast enable
dhcp select interface
dhcp server dns-list 8.8.8.8
interface Ethernet0/0/0.40
control-vid 40 dot1q-termination
dot1q termination vid 40
ip address 192.168.40.1 255.255.255.0
arp broadcast enable
dhcp select interface
dhcp server dns-list 8.8.8.8