一、实验拓扑
二、实验要求
1、pc1和pc3所在接口为access;属于vlan 2;
PC2/PC4/PC5/PC6处于同一网段’其中PC2可以访问PC4/PC5/PC6;
PC4可以访问PC6;PC5不能访问PC6;
2、PC1/PC3与PC2/PC4/PC5/PC6不在同一个网段;
3、所有PC通过DHCP获取IP地址,且PC1/PC3可以正常访问PC2/PC4/PC5/PC6;
三、实验思路
1、先给交换机配置相应类型的接口配置
2、再在路由器配置IP地址和DHCP的配置
四、实验步骤
1,将PC设置成用DHCP获取IP地址
2、在交换机SW1,SW2,SW3配置VLAN和各个接口对应类型的配置
SW1:
<Huawei>sys [Huawei]sysn SW1#创建vlan [SW1]vlan batch 2 to 6 #进入接口加入vlan [LSW1]int g 0/0/1 [LSW1-GigabitEthernet0/0/1]port link-type access [LSW1-GigabitEthernet0/0/1]port default vlan 2[LSW1]int g 0/0/2 [LSW1-GigabitEthernet0/0/2]port hybrid pvid vlan 3 [LSW1-GigabitEthernet0/0/2]port hybrid untagged vlan 3 to 6[LSW1-GigabitEthernet0/0/2]int g 0/0/3 [LSW1-GigabitEthernet0/0/3]port link-type trunk [LSW1-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 to 6[LSW1-GigabitEthernet0/0/3]int g 0/0/4 [LSW1-GigabitEthernet0/0/4]port hybrid untagged vlan 3 to 6 [LSW1-GigabitEthernet0/0/4]port hybrid tagged vlan 2
[SW1]dis port vlan active
SW2:
<Huawei>sys [Huawei]sysn SW2#创建vlan [SW2]vlan batch 2 to 6#进入接口加入vlan [LSW2]interface g 0/0/1 [LSW2-GigabitEthernet0/0/1]port link-type access [LSW2-GigabitEthernet0/0/1]port default vlan 2 [LSW2-GigabitEthernet0/0/1]int g 0/0/2[LSW2-GigabitEthernet0/0/2]port hybrid pvid vlan 4 [LSW2-GigabitEthernet0/0/2]port hybrid untagged vlan 3 to 6[LSW2-GigabitEthernet0/0/2]int g 0/0/3 [LSW2-GigabitEthernet0/0/3]port link-type trunk [LSW2-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 to 6[LSW2-GigabitEthernet0/0/3]int g 0/0/4 [LSW2-GigabitEthernet0/0/4]port link-type trunk [LSW2-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 to 6
[SW2]dis port vlan active
SW3:
<Huawei>sys [Huawei]sysn SW3#创建vlan [SW3]vlan batch 2 to 6#进入接口加入vlan [LSW3]int g 0/0/1 [LSW3-GigabitEthernet0/0/1]port hybrid pvid vlan 5 [LSW3-GigabitEthernet0/0/1]port hybrid untagged vlan 3 4 5[LSW3-GigabitEthernet0/0/1]int g 0/0/2 [LSW3-GigabitEthernet0/0/2]port hybrid pvid vlan 6 [LSW3-GigabitEthernet0/0/2]port hybrid untagged vlan 3 4 6[LSW3-GigabitEthernet0/0/2]int g 0/0/3 [LSW3-GigabitEthernet0/0/3]port link-type trunk [LSW3-GigabitEthernet0/0/3]port trunk allow-pass vlan 2 to 6
[R3]dis port vlan active
3、在路由器上面配置DHCP服务
R1:
子接口——vlan2
物理口——vlan3,4,5,6
[R1]int g 0/0/0 [R1-GigabitEthernet0/0/0]ip add [R1-GigabitEthernet0/0/0]ip address 192.168.1.1 24[R1-GigabitEthernet0/0/0]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 //接口开启802.1q帧识别 [R1-GigabitEthernet0/0/0.1]arp broadcast enable //开启arp广播协议#配置地址池 [R1]dhcp enable [R1]ip pool aa [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]int g 0/0/0.1 [R1-GigabitEthernet0/0/0.1]dhcp select global [R1]dhcp enable [R1]ip pool bb [R1-ip-pool-bb]network 192.168.1.0 mask 24 [R1-ip-pool-bb]gateway-list 192.168.1.1 [R1-GigabitEthernet0/0/0]dhcp select global
4、在PC端进行测试(PC都要开启DHCP服务)
各个PC使用DHCP获取的IP地址如下:
PC1:192.168.2.254
PC2:192.168.1.254
PC3:192.168.2.253
PC4:192.168.1.253
PC5:192.168.1.252
PC6:192.168.1.251