实验思路
- 配置vlan
- 配置路由器配置
- 配置vlan
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port default vlan 2
sw1-GigabitEthernet0/0/1]int g0/0/2
[sw1-GigabitEthernet0/0/2]port hybrid pvid vlan 3
[sw1-GigabitEthernet0/0/2]port hybrid untagged vlan 3 to 6
[sw1-GigabitEthernet0/0/2]int g0/0/3
[sw1-GigabitEthernet0/0/3]port link-type trunk
[sw1-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 to 6
[sw1-GigabitEthernet0/0/4]port link-type hybrid
[sw1-GigabitEthernet0/0/4]port hybrid untagged vlan 3 to 6
[sw1-GigabitEthernet0/0/4]port hybrid tagged vlan 2
[sw2]int g0/0/1
[sw2-GigabitEthernet0/0/1]port link-type access
[sw2-GigabitEthernet0/0/1]port default vlan 2
[sw2-GigabitEthernet0/0/1]int g0/0/2
[sw2-GigabitEthernet0/0/2]port hybrid pvid vlan 4
[sw2-GigabitEthernet0/0/2]port hybrid untagged vlan 3 to 6
[sw2-GigabitEthernet0/0/2]int g0/0/3
[sw2-GigabitEthernet0/0/3]port link-type trunk
[sw2-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 to 6
[sw2-GigabitEthernet0/0/4]port link-type trunk
[sw2-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 to 6
[sw3]int g0/0/1
[sw3-GigabitEthernet0/0/1]port hybrid pvid vlan 4
[sw3-GigabitEthernet0/0/1]port hybrid untagged vlan 3 to 5
[sw3-GigabitEthernet0/0/1]int g0/0/2
[sw3-GigabitEthernet0/0/2]port hybrid pvid vlan 6
[sw3-GigabitEthernet0/0/2]port hybrid untagged vlan 3 4 6
[sw3-GigabitEthernet0/0/2]int g0/0/3
[sw3-GigabitEthernet0/0/3]port link-type trunk
[sw3-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 to 6
- 配置路由器配置
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip ad 192.168.1.1 24
虚拟接口
[R1-GigabitEthernet0/0/0]int g0/0/0.1
[R1-GigabitEthernet0/0/0.1]ip ad 192.168.2.1 24
[R1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[R1-GigabitEthernet0/0/0.1]arp broadcast enable
[R1]dhcp enable
DHCP地址池
[R1]ip pool v2
[R1-ip-pool-v2]gateway-list 192.168.2.1
[R1-ip-pool-v2]network 192.168.2.0 ma 24
[R1-ip-pool-v2]dns-list 8.8.8.8
[R1-ip-pool-v2]q
[R1]ip pool v3
[R1-ip-pool-v3]gateway-list 192.168.1.1
[R1-ip-pool-v3]network 192.168.1.0 ma 24
[R1-ip-pool-v3]dns-list 8.8.8.8
[R1-ip-pool-v3]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
实验结果