VLAN多端口成员模式+DHCP
文章目录
- VLAN多端口成员模式+DHCP
- 一、题目要求
- 二、题目分析
- 三、拓扑结构
- 四、基本配置
- 五、测试验证
- 1.网段测试
- 2.访问测试
一、题目要求
1、PC1和pc3所在接口为Access接口,PC2/4/5/6处于同一网段,其中PC2可以访问PC4/5/6,PC4可以访问PC5,但不能访问PC6,PC5不能访问PC6;
2、PC1/3与PC2/4/5/6不在同一网段;
3、所有PC通过DHCP获取IP地址,且PC1/3可以正常访问PC2/4/5/6。
注:所示拓扑图中PC5,PC6名称错误,正确拓扑图在拓扑结构中。
二、题目分析
1.网段划分
192.168.1.0 24–PC1/3
192.168.2.0 24–PC2456
2.vlan划分
PC1,3–vlan2
PC2–vlan3
PC4–valn4
PC5–vlan5
PC6–vlan6
3.接口分析
PC1/3为access
PC2/4/5/6为hybird
sw1-g0/0/4为hybird
交换机之间为trunk
4.DHCP
在R1配置子接口,属于VLAN2
5.阻塞分析
PC1/2/3正常访问
PC4->PC1/2/3/5,U:2345
PC5->PC1/2/3/4,U:2345
PC6->PC1/2/3,U:236
三、拓扑结构
拓扑结构如图所示
四、基本配置
所有PC启用DHCP(同PC1):
R1:
#DHCP
<Huawei>sys
[Huawei]sys r1
[r1]un in en
[r1]dhcp enable
[r1]ip pool p1
[r1-ip-pool-p1]net 192.168.1.0 mask 24
[r1-ip-pool-p1]gateway-list 192.168.1.1
[r1-ip-pool-p1]dns-list 8.8.8.8
[r1-ip-pool-p1]q
[r1]ip pool p2
[r1-ip-pool-p2]net 192.168.2.0 mask 24
[r1-ip-pool-p2]gateway-list 192.168.2.1
[r1-ip-pool-p2]dns-list 8.8.8.8
[r1-ip-pool-p2]q
#配置子接口
[r1]int g0/0/0.1
[r1-GigabitEthernet0/0/0.1]ip add 192.168.1.1 24
##规定该子接口所属vlan id
[r1-GigabitEthernet0/0/0.1]dot1q termination vid 2
##开启子接口广播功能
[r1-GigabitEthernet0/0/0.1]arp broadcast enable
#全局模式DHCP
[r1-GigabitEthernet0/0/0.1]dhcp select global
[r1-GigabitEthernet0/0/0.1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 192.168.2.1 24
[r1-GigabitEthernet0/0/0]dhcp select global
SW1:
<Huawei>sys
[Huawei]sys sw1
[sw1]un in en
[sw1]vlan batch 2 to 6
#g0/0/1使用access
[sw1]int g0/0/1
[sw1-GigabitEthernet0/0/1]port link-type access
[sw1-GigabitEthernet0/0/1]port default vlan 2
#g0/0/2使用hybrid
[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 2 to 6
#g0/0/3使用trunk
[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 3 4 5 6
#g0/0/4使用hybrid
[sw1-GigabitEthernet0/0/3]int g0/0/4
[sw1-GigabitEthernet0/0/4]port hybrid untagged vlan 3 4 5 6
[sw1-GigabitEthernet0/0/4]port hybrid tagged vlan 2
SW2:
<Huawei>sys
[Huawei]sys sw2
[sw2]un in en
[sw2]vlan batch 2 to 6
#g0/0/1使用access
[sw2]int g0/0/1
[sw2-GigabitEthernet0/0/1]port link-type access
[sw2-GigabitEthernet0/0/1]port default vlan 2
#g0/0/2使用hybrid
[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 2 to 5
#g0/0/3使用trunk
[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 3 4 5 6
#g0/0/4使用trunk
[sw2-GigabitEthernet0/0/3]int g0/0/4
[sw2-GigabitEthernet0/0/4]port link-type trunk
[sw2-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 3 4 5 6
SW3:
<Huawei>sys
[Huawei]sys sw3
[sw3]un in en
[sw3]vlan batch 2 to 6
#g0/0/1使用hybrid
[sw3]int g0/0/1
[sw3-GigabitEthernet0/0/1]port hybrid pvid vlan 5
[sw3-GigabitEthernet0/0/1]port hybrid untagged vlan 2 to 5
#g0/0/2使用hybrid
[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 2 3 6
#g0/0/4使用trunk
[sw3-GigabitEthernet0/0/2]int g0/0/4
[sw3-GigabitEthernet0/0/4]port link-type trunk
[sw3-GigabitEthernet0/0/4]port trunk allow-pass vlan 2 3 4 5 6
五、测试验证
1.网段测试
PC1/3同一网段,PC2/4/5/6同一网段
PC1:
PC>IPCONFIG
Link local IPv6 address...........: fe80::5689:98ff:fe9f:649a
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.1.253
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.1.1
Physical address..................: 54-89-98-9F-64-9A
DNS server........................: 8.8.8.8
PC3:
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fed4:4280
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.1.254
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.1.1
Physical address..................: 54-89-98-D4-42-80
DNS server........................: 8.8.8.8
PC2:
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe51:34e9
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.2.252
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.2.1
Physical address..................: 54-89-98-51-34-E9
DNS server........................: 8.8.8.8
PC4:
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe85:520c
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.2.251
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.2.1
Physical address..................: 54-89-98-85-52-0C
DNS server........................: 8.8.8.8
PC5:
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe3f:5e0c
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.2.253
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.2.1
Physical address..................: 54-89-98-3F-5E-0C
DNS server........................: 8.8.8.8
PC6:
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe08:60a3
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.2.254
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.2.1
Physical address..................: 54-89-98-08-60-A3
DNS server........................: 8.8.8.8
2.访问测试
以下证明PC2可以访问PC4/5/6,PC4可以访问PC5,但不能访问PC6,PC5不能访问PC6,PC1/3可以正常访问PC2/4/5/6,
PC4访问PC1/2/5/6
#PC1可达
PC>ping 192.168.1.253
Ping 192.168.1.253: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.1.253: bytes=32 seq=2 ttl=127 time=78 ms
From 192.168.1.253: bytes=32 seq=3 ttl=127 time=109 ms
From 192.168.1.253: bytes=32 seq=4 ttl=127 time=94 ms
From 192.168.1.253: bytes=32 seq=5 ttl=127 time=109 ms
--- 192.168.1.253 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/97/109 ms
#PC2可达
PC>ping 192.168.2.252
Ping 192.168.2.252: 32 data bytes, Press Ctrl_C to break
From 192.168.2.252: bytes=32 seq=1 ttl=128 time=63 ms
From 192.168.2.252: bytes=32 seq=2 ttl=128 time=62 ms
From 192.168.2.252: bytes=32 seq=3 ttl=128 time=63 ms
From 192.168.2.252: bytes=32 seq=4 ttl=128 time=62 ms
From 192.168.2.252: bytes=32 seq=5 ttl=128 time=63 ms
--- 192.168.2.252 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 62/62/63 ms
#PC5可达
PC>ping 192.168.2.253
Ping 192.168.2.253: 32 data bytes, Press Ctrl_C to break
From 192.168.2.253: bytes=32 seq=1 ttl=128 time=62 ms
From 192.168.2.253: bytes=32 seq=2 ttl=128 time=63 ms
From 192.168.2.253: bytes=32 seq=3 ttl=128 time=62 ms
From 192.168.2.253: bytes=32 seq=4 ttl=128 time=47 ms
From 192.168.2.253: bytes=32 seq=5 ttl=128 time=47 ms
--- 192.168.2.253 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 47/56/63 ms
#PC6不可达
PC>ping 192.168.2.254
Ping 192.168.2.254: 32 data bytes, Press Ctrl_C to break
From 192.168.2.251: Destination host unreachable
From 192.168.2.251: Destination host unreachable
From 192.168.2.251: Destination host unreachable
From 192.168.2.251: Destination host unreachable
From 192.168.2.251: Destination host unreachable
--- 192.168.2.254 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
PC5访问2/3/6
#PC2可达
PC>ping 192.168.2.252
Ping 192.168.2.252: 32 data bytes, Press Ctrl_C to break
From 192.168.2.252: bytes=32 seq=1 ttl=128 time=78 ms
From 192.168.2.252: bytes=32 seq=2 ttl=128 time=78 ms
From 192.168.2.252: bytes=32 seq=3 ttl=128 time=94 ms
From 192.168.2.252: bytes=32 seq=4 ttl=128 time=78 ms
From 192.168.2.252: bytes=32 seq=5 ttl=128 time=78 ms
--- 192.168.2.252 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 78/81/94 ms
#PC3可达
PC>ping 192.168.1.254
Ping 192.168.1.254: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.1.254: bytes=32 seq=2 ttl=127 time=156 ms
From 192.168.1.254: bytes=32 seq=3 ttl=127 time=125 ms
From 192.168.1.254: bytes=32 seq=4 ttl=127 time=172 ms
From 192.168.1.254: bytes=32 seq=5 ttl=127 time=125 ms
--- 192.168.1.254 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/144/172 ms
#PC6不可达
PC>ping 192.168.2.254
Ping 192.168.2.254: 32 data bytes, Press Ctrl_C to break
From 192.168.2.253: Destination host unreachable
From 192.168.2.253: Destination host unreachable
From 192.168.2.253: Destination host unreachable
From 192.168.2.253: Destination host unreachable
From 192.168.2.253: Destination host unreachable
--- 192.168.2.254 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
PC6访问PC2
#PC1可达
PC>ping 192.168.1.253
Ping 192.168.1.253: 32 data bytes, Press Ctrl_C to break
From 192.168.1.253: bytes=32 seq=1 ttl=127 time=110 ms
From 192.168.1.253: bytes=32 seq=2 ttl=127 time=125 ms
From 192.168.1.253: bytes=32 seq=3 ttl=127 time=125 ms
From 192.168.1.253: bytes=32 seq=4 ttl=127 time=125 ms
From 192.168.1.253: bytes=32 seq=5 ttl=127 time=93 ms
--- 192.168.1.253 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 93/115/125 ms
#PC2可达
PC>ping 192.168.2.252
Ping 192.168.2.252: 32 data bytes, Press Ctrl_C to break
From 192.168.2.252: bytes=32 seq=1 ttl=128 time=78 ms
From 192.168.2.252: bytes=32 seq=2 ttl=128 time=78 ms
From 192.168.2.252: bytes=32 seq=3 ttl=128 time=94 ms
From 192.168.2.252: bytes=32 seq=4 ttl=128 time=78 ms
From 192.168.2.252: bytes=32 seq=5 ttl=128 time=78 ms
--- 192.168.2.252 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 78/81/94 ms
#PC3可达
PC>ping 192.168.1.254
Ping 192.168.1.254: 32 data bytes, Press Ctrl_C to break
From 192.168.1.254: bytes=32 seq=1 ttl=127 time=110 ms
From 192.168.1.254: bytes=32 seq=2 ttl=127 time=140 ms
From 192.168.1.254: bytes=32 seq=3 ttl=127 time=141 ms
From 192.168.1.254: bytes=32 seq=4 ttl=127 time=125 ms
From 192.168.1.254: bytes=32 seq=5 ttl=127 time=140 ms
--- 192.168.1.254 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 110/131/141 ms