sw1的接口6应该调成混杂模式,因为pc2,4,5,6的pvid各不相同而网段相同,所以往上去路由时应该剥离标记(VLAN里面是标记而不是标签)出去,这样 路由器上的物理接口用来管理不带标记的流量,而vlan2流量的往上打上vlan2标记进入vlan2的子接口。
如192.168.2.1 去 访问192.168.1.1 发现目标IP和自己不在一个网段,就会去找路由器,往上去的时候经过交换机,带着vlan2的标签进入r1的子接口,发现是1.1网段,就路由给物理接口,物理接口往下发包,不会带标记。交换机收到没有标记的,会把它按pvid算,打上pvid的标记(默认vlan1)所以就会给允许vlan1的所有接口转发
access 接口不打标记
交换机1配置:
vlan batch 2 to 6
interface Ethernet0/0/1
port link-type access
port default vlan 2
#
interface Ethernet0/0/2
port hybrid pvid vlan 3
port hybrid untagged vlan 3 to 6
#
interface Ethernet0/0/3
port link-type access
port default vlan 2
#
interface Ethernet0/0/4
port hybrid pvid vlan 4
port hybrid untagged vlan 3 to 4
#
interface Ethernet0/0/5
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface Ethernet0/0/6
port hybrid tagged vlan 2
port hybrid untagged vlan 3 to 6
交换机2配置:
vlan batch 2 to 6
interface Ethernet0/0/1
port link-type trunk
port trunk allow-pass vlan 2 to 4094
#
interface Ethernet0/0/2
port hybrid pvid vlan 5
port hybrid untagged vlan 3 5
#
interface Ethernet0/0/3
port hybrid pvid vlan 6
port hybrid untagged vlan 3 6
路由器1配置:
[r1]int g 0/0/0
[r1-GigabitEthernet0/0/0]ip address 192.168.1.1 24[r1]int g 0/0/0.1
[r1-GigabitEthernet0/0/0.1]ip address 192.168.2.1 24
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
[r1-GigabitEthernet0/0/0.1]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]q
[r1]ip pool v3-v6
[r1-ip-pool-v3-v6]network 192.168.1.0 mask 24
[r1-ip-pool-v3-v6]gateway-list 192.168.1.1
[r1-ip-pool-v3-v6]q
[r1]int g 0/0/0
[r1-GigabitEthernet0/0/0]q
[r1]dhcp enable
[r1]int g 0/0/0
[r1-GigabitEthernet0/0/0]dhcp select gl
[r1-GigabitEthernet0/0/0]int g 0/0/0.1
[r1-GigabitEthernet0/0/0.1]dhcp select global
[r1-GigabitEthernet0/0/0.1]q
最终主机顺利获取DHCP分配的IP,并且满足实验要求