实验拓扑图:
实验目的:
1.pc1和pc3所在接口为access;属于vlan 2;
pc2/4/5/6处于同一网段里,其中pc2可以访问pc4/5/6,pc4可以访问pc6,pc5不能访问pc6;
2.pc1/pc3与pc2/pc4/pc5/pc6不在同一网段;
3.所有pc通过DHCP获取Ip地址,且pc1/pc3可以正常访问pc2/pc4/pc5/pc6;
将PC改为DHCP获取地址:
PC1~~6都进行以下更改:
创建VLAN:
[LW1]vlan batch 2 to 6
[LW2]vlan batch 2 to 6
[LW3]vlan batch 2 to 6
进入交换机接口进行接口类型配置:
LW1:
[LW1-GigabitEthernet0/0/2]port link-type access
[LW1-GigabitEthernet0/0/2]port default vlan 2
[LW1-GigabitEthernet0/0/3]port hybrid pvid vlan 3
[LW1-GigabitEthernet0/0/3]port hybrid untagged vlan 3 to 6
[LW1-GigabitEthernet0/0/4]port link-type trunk
[LW1-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 to 6
[LW1-GigabitEthernet0/0/1]port hybrid untagged vlan 3 to 6 撕标签3~6放行
[LW1-GigabitEthernet0/0/1]port hybrid tagged vlan 2 不撕标签2放行
查看:
LW2:
[LW2-GigabitEthernet0/0/1]port link-type trunk
[LW2-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 6
[LW2-GigabitEthernet0/0/2]port link-type trunk
[LW2-GigabitEthernet0/0/2]port trunk allow-pass vlan 2 to 6
[LW2-GigabitEthernet0/0/3]port link-type access
[LW2-GigabitEthernet0/0/3]port default vlan 2
[LW2-GigabitEthernet0/0/4]port hybrid pvid vlan 4
[LW2-GigabitEthernet0/0/4]port hybrid untagged vlan 3 to 6
查看:
LW3:
[LW3-GigabitEthernet0/0/1]port link-type trunk
[LW3-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 6
[LW3-GigabitEthernet0/0/2]port hybrid pvid vlan 5
[LW3-GigabitEthernet0/0/2]port hybrid untagged vlan 3 to 5
[LW3-GigabitEthernet0/0/3]port hybrid pvid vlan 6
[LW3-GigabitEthernet0/0/3]port hybrid untagged vlan 3 4 6
查看:
进入R1配置ip并开启子接口识别数据帧802.1Q:
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 192.168.1.0 24
Error: The specified IP address is invalid.
[R1-GigabitEthernet0/0/0]ip add 192.168.1.1 24
[R1-GigabitEthernet0/0/0]int g0/0/0.1
[R1-GigabitEthernet0/0/0.1]ip add 192.168.2.1 24
[R1-GigabitEthernet0/0/0.1]dot1q termination vid 2
May 20 2024 18:57:27-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/0.1 has entered the UP state.
[R1-GigabitEthernet0/0/0.1]arp broadcast enable
在R1上进行DHCP服务配置:
[R1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R1]ip policy-based-route
[R1]ip pool aa 创建地址池aa
Info: It's successful to create an IP address pool.
[R1-ip-pool-aa]network 192.168.2.0 mask 24 宣告网段
[R1-ip-pool-aa]gateway-list 192.168.2.1 网关
[R1-ip-pool-aa]dns-list 8.8.8.8
[R1-ip-pool-aa]q
[R1]int g0/0/0.1 进入子接口启用DHCP
[R1-GigabitEthernet0/0/0.1]dhcp select global
[R1-GigabitEthernet0/0/0.1]q
[R1]ip pool bb 创建地址池bb
Info: It's successful to create an IP address pool.
[R1-ip-pool-bb]network 192.168.1.0 mask 24 宣告网段
[R1-ip-pool-bb]gateway-list 192.168.1.1 网关
[R1-ip-pool-bb]dns-list 8.8.8.8
[R1-ip-pool-bb]q
[R1]int g0/0/0 进入物理口启用DHCP
[R1-GigabitEthernet0/0/0]dhcp select global
查看:
PC1 ping PC6
PC5 ping PC6
PC2 ping PC4