构建拓扑
实验配置
1.将接口划入vlan
[sw1]vlan batch 2 to 5
[sw1] int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port default vlan 2
[sw1]int g0/0/2
[sw1-GigabitEthernet0/0/2]port hybrid untagged vlan 3 to 5
[sw1-GigabitEthernet0/0/2]port hybrid pvid vlan 3
[sw1]int g0/0/23
[sw1-GigabitEthernet0/0/23]port link-type trunk
[sw1-GigabitEthernet0/0/23]port trunk allow-pass vlan 2 to 5
[sw2] vlan batch 2 to 5
[sw2]int g0/0/23
[sw2-GigabitEthernet0/0/23]port hybrid tagged vlan 2 to 5
[sw2]int g0/0/1
[sw2-GigabitEthernet0/0/1]port link-type access
[sw2-GigabitEthernet0/0/1]port default vlan 2
[sw2]int g0/0/2
[sw2-GigabitEthernet0/0/2]port hybrid untagged vlan 3 to 4
[sw2-GigabitEthernet0/0/2]port hybrid pvid vlan 4
[sw2]int g0/0/24
[sw2-GigabitEthernet0/0/24]port hybrid tagged vlan 2 to 5
[sw3]int g0/0/24
[sw3-GigabitEthernet0/0/24]port hybrid tagged vlan 2 to 5
[sw3]vlan batch 2 to 5
[sw3]int g0/0/1
[sw3-GigabitEthernet0/0/1]port hybrid pvid vlan 4
[sw3-GigabitEthernet0/0/1]port hybrid untagged vlan 3 to 4
[sw3]int g0/0/2
[sw3-GigabitEthernet0/0/2]port hybrid pvid vlan 5
[sw3-GigabitEthernet0/0/2]port hybrid untagged vlan 3 5
2.配置路由器,通过池塘下发地址
[sw1]int g0/0/24
[sw1-GigabitEthernet0/0/24]port hybrid tagged vlan 2
[sw1-GigabitEthernet0/0/24]port hybrid untagged vlan 3 to 5
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add
[r1-GigabitEthernet0/0/0]ip address 192.168.1.1 24
[r1-GigabitEthernet0/0/0]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]ip address 192.168.2.1 24
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
[r1]dhcp enable
[r1]ip pool v1
[r1-ip-pool-v1]network 192.168.1.0 mask 24
[r1-ip-pool-v1]gateway-list 192.168.1.1
[r1-ip-pool-v1]dns-list 114.114.114.114 8.8.8.8
[r1-ip-pool-v1]q
[r1]ip pool v2
[r1-ip-pool-v2]network 192.168.2.0 mask 24
[r1-ip-pool-v2]gateway-list 192.168.2.1
[r1-ip-pool-v2]dns-list 114.114.114.114 8.8.8.8
[r1-ip-pool-v2]q
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]dhcp select global
[r1-GigabitEthernet0/0/0]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select global
3.PC端获取地址
查看是否自动获取ip地址
进行ping包检查: