作者:BuauOoO_987 | 来源:互联网 | 2023-08-30 18:51
配置如图的练习,要求:lsw1和lsw2内有两个网段,lsw3内有两个网段。全网可达
分析:
①lsw1和lsw2存在两个vlan(vlan2和vlan3),而lsw3也存在两个独立的vlan(vlan2和vlan3),所以要对交换机进行vlan划分
②交换机和交换机之间要能进行数通,并且可以全网可达,所以要配置干道
③需要配置dhcp池和接口划分
解:
第一步:交换机的vlan划分
//lsw1
sys
[Huawei]vlan batch 2 to 3
[Huawei]interface g0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 2
[Huawei]interface g0/0/3
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 3//lsw2
sys
[Huawei]vlan batch 2 to 3
[Huawei]interface g0/0/3
[Huawei-GigabitEthernet0/0/3]port link-type access
[Huawei-GigabitEthernet0/0/3]port default vlan 2
[Huawei]interface g0/0/4
[Huawei-GigabitEthernet0/0/4]port link-type access
[Huawei-GigabitEthernet0/0/4]port default vlan 3//lsw3
sys
[Huawei]vlan batch 2 to 3
[Huawei]interface g0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 2
[Huawei]interface g0/0/3
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 3
第二步:配置交换器和路由器干道
//lsw1只有一个g0/0/0口接通lsw2
[Huawei]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan 2 to 3//lsw2需要配置lsw1的g0/0/2口
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type trunk
[Huawei-GigabitEthernet0/0/2]port trunk allow-pass vlan all
//和路由器的g0/0/1口
[Huawei]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all //lsw3则需要配置和路由器的g0/0/1口
[Huawei]interface g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all
第三步:配置路由器
//和lsw2的接口
[Huawei]interface g0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]dot1q termination vid 2
[Huawei-GigabitEthernet0/0/0.1]arp broadcast enable
[Huawei-GigabitEthernet0/0/0.1]ip address 192.168.1.1 24
Dec 10 2021 19:10:32-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[0]:The line protocolIP on the interface GigabitEthernet0/0/0.1 has entered the UP state. [Huawei-GigabitEthernet0/0/0.1]interface g0/0/0.2
[Huawei-GigabitEthernet0/0/0.2]dot1q termination vid 3
[Huawei-GigabitEthernet0/0/0.2]arp broadcast enable
[Huawei-GigabitEthernet0/0/0.2]ip address 192.168.2.1 24
Dec 10 2021 19:11:01-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[1]:The line protocolIP on the interface GigabitEthernet0/0/0.2 has entered the UP state. //和lsw3的接口
[Huawei-GigabitEthernet0/0/0.2]interface g0/0/1.1
[Huawei-GigabitEthernet0/0/1.1]dot1q termination vid 2
[Huawei-GigabitEthernet0/0/1.1]arp broadcast enable
[Huawei-GigabitEthernet0/0/1.1]ip address 192.168.3.1 24
Dec 10 2021 19:12:29-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[2]:The line protocolIP on the interface GigabitEthernet0/0/1.1 has entered the UP state. [Huawei-GigabitEthernet0/0/1.1]interface g0/0/1.2
[Huawei-GigabitEthernet0/0/1.2]dot1q termination vid 3
[Huawei-GigabitEthernet0/0/1.2]arp broadcast enable
[Huawei-GigabitEthernet0/0/1.2]ip address 192.168.4.1 24
第四步:配置DHCP池
[Huawei]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[Huawei]ip pool vlan
Info: It's successful to create an IP address pool.
[Huawei-ip-pool-vlan]network 192.168.1.0 mask 24
[Huawei-ip-pool-vlan]gateway-list 192.168.1.1
[Huawei-ip-pool-vlan]dns-list 8.8.8.8
[Huawei-ip-pool-vlan]q[Huawei]ip pool vlan2
Info: It's successful to create an IP address pool.
[Huawei-ip-pool-vlan2]network 192.168.2.0 mask 24
[Huawei-ip-pool-vlan2]gateway-list 192.168.2.1
[Huawei-ip-pool-vlan2]dns-list 8.8.8.8
[Huawei-ip-pool-vlan2]q[Huawei]ip pool vlan3
Info: It's successful to create an IP address pool.
[Huawei-ip-pool-vlan3]network 192.168.3.0 mask 24
[Huawei-ip-pool-vlan3]gateway-list 192.168.3.1
[Huawei-ip-pool-vlan3]
[Huawei-ip-pool-vlan3]dns-list 8.8.8.8
[Huawei-ip-pool-vlan3]q[Huawei]ip pool vlan4
Info: It's successful to create an IP address pool.
[Huawei-ip-pool-vlan4]network 192.168.4.0 mask 24
[Huawei-ip-pool-vlan4]gateway-list 192.168.4.1
[Huawei-ip-pool-vlan4]dns-list 8.8.8.8
[Huawei-ip-pool-vlan4]q
第五步:为接口选择DHCP模式
[Huawei]interface g0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]dhcp select global [Huawei]interface g0/0/0.2
[Huawei-GigabitEthernet0/0/0.2]dhcp select global [Huawei-GigabitEthernet0/0/0.2]interface g0/0/1.1
[Huawei-GigabitEthernet0/0/1.1]dhcp select global[Huawei-GigabitEthernet0/0/1.1]interface g0/0/1.2
[Huawei-GigabitEthernet0/0/1.2]dhcp select global
[Huawei-GigabitEthernet0/0/1.2]q
完成,查看效果
PC>ipconfigLink local IPv6 address...........: fe80::5689:98ff:fe31:2ac9
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-31-2A-C9
DNS server........................: 8.8.8.8PC>ping 192.168.1.254Ping 192.168.1.254: 32 data bytes, Press Ctrl_C to break
From 192.168.1.254: bytes=32 seq=1 ttl=128 time=62 ms
From 192.168.1.254: bytes=32 seq=2 ttl=128 time=63 ms
From 192.168.1.254: bytes=32 seq=3 ttl=128 time=62 ms
From 192.168.1.254: bytes=32 seq=4 ttl=128 time=63 ms
From 192.168.1.254: bytes=32 seq=5 ttl=128 time=47 ms--- 192.168.1.254 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 47/59/63 msPC>ping 192.168.2.254Ping 192.168.2.254: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.2.254: bytes=32 seq=2 ttl=127 time=94 ms
From 192.168.2.254: bytes=32 seq=3 ttl=127 time=93 ms
From 192.168.2.254: bytes=32 seq=4 ttl=127 time=110 ms
From 192.168.2.254: bytes=32 seq=5 ttl=127 time=94 ms--- 192.168.2.254 ping statistics ---5 packet(s) transmitted4 packet(s) received20.00% packet lossround-trip min/avg/max = 0/97/110 msPC>ping 192.168.3.254Ping 192.168.3.254: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.3.254: bytes=32 seq=2 ttl=127 time=94 ms
From 192.168.3.254: bytes=32 seq=3 ttl=127 time=78 ms
From 192.168.3.254: bytes=32 seq=4 ttl=127 time=93 ms
From 192.168.3.254: bytes=32 seq=5 ttl=127 time=94 ms--- 192.168.3.254 ping statistics ---5 packet(s) transmitted4 packet(s) received20.00% packet lossround-trip min/avg/max = 0/89/94 ms