图
要求:
1. DCHP server可以使用0/0/0接口DHCP进行分配ip
2. DCHP server可以使用0/0/1接口DHCP进行分配ip
3.各PC之间可以互通
思路:分别给路由器的接口0/0/0和0/0/1进行全局DHCP配置,在分别将pc用DHCP配置
配置
接口0/0/0
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sys
[Huawei]sysname DHCP Server
[DHCP Server]interface GigabitEthernet 0/0/0
[DHCP Server-GigabitEthernet0/0/0]ip address 192.168.1.254 24
Mar 12 2023 14:11:21-08:00 DHCP Server %%01IFNET/4/LINK_STATE(l)[2]:The line pro
tocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[DHCP Server-GigabitEthernet0/0/0]quit
[DHCP Server]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[DHCP Server]ip policy-based-route
[DHCP Server]ip pool 111
Info: It's successful to create an IP address pool.
[DHCP Server-ip-pool-111]network 192.168.1.0 mask 24
[DHCP Server-ip-pool-111]gateway-list 192.168.1.254
[DHCP Server-ip-pool-111]dns-list 8.8.8.8 114.114.114.114
[DHCP Server-ip-pool-111]quit
[DHCP Server]interface GigabitEthernet 0/0/0
[DHCP Server-GigabitEthernet0/0/0]dhcp select global
接口0/0/1:
[DHCP Server]interface GigabitEthernet 0/0/1
[DHCP Server-GigabitEthernet0/0/1]ip address 192.168.2.254 24
Mar 12 2023 14:17:00-08:00 DHCP Server %%01IFNET/4/LINK_STATE(l)[3]:The line pro
tocol IP on the interface GigabitEthernet0/0/1 has entered the UP state.
[DHCP Server-GigabitEthernet0/0/1]quit
[DHCP Server]dhcp enable
[DHCP Server]ip policy-based-route
[DHCP Server]ip pool 222
Info: It's successful to create an IP address pool.
[DHCP Server-ip-pool-222]netbios-type
[DHCP Server-ip-pool-222]network 192.168.2.0 mask 24
[DHCP Server-ip-pool-222]gateway-list 192.168.2.254
[DHCP Server-ip-pool-222]dns-list 8.8.8.8 114.114.114.114
[DHCP Server-ip-pool-222]quit
[DHCP Server]interface GigabitEthernet 0/0/1
[DHCP Server-GigabitEthernet0/0/1]dhcp select global
pc测试
pc1的IP
pc1
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe9a:26c8
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.1.253
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.1.254
Physical address..................: 54-89-98-9A-26-C8
DNS server........................: 8.8.8.8
114.114.114.114
pc1-pc2
PC>ping 192.168.1.252
Ping 192.168.1.252: 32 data bytes, Press Ctrl_C to break
From 192.168.1.252: bytes=32 seq=1 ttl=128 time=47 ms
From 192.168.1.252: bytes=32 seq=2 ttl=128 time=31 ms
From 192.168.1.252: bytes=32 seq=3 ttl=128 time=47 ms
From 192.168.1.252: bytes=32 seq=4 ttl=128 time=31 ms
From 192.168.1.252: bytes=32 seq=5 ttl=128 time=47 ms
--- 192.168.1.252 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/40/47 ms
pc1-pc3
PC>ping 192.168.2.2532
host 192.168.2.2532 unreachable
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=127 time=62 ms
From 192.168.2.253: bytes=32 seq=2 ttl=127 time=47 ms
From 192.168.2.253: bytes=32 seq=3 ttl=127 time=63 ms
From 192.168.2.253: bytes=32 seq=4 ttl=127 time=62 ms
From 192.168.2.253: bytes=32 seq=5 ttl=127 time=63 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/59/63 ms
pc1-pc4
PC>ping 192.168.2.252
Ping 192.168.2.252: 32 data bytes, Press Ctrl_C to break
Request timeout!
From 192.168.2.252: bytes=32 seq=2 ttl=127 time=78 ms
From 192.168.2.252: bytes=32 seq=3 ttl=127 time=62 ms
From 192.168.2.252: bytes=32 seq=4 ttl=127 time=79 ms
From 192.168.2.252: bytes=32 seq=5 ttl=127 time=78 ms
--- 192.168.2.252 ping statistics ---
5 packet(s) transmitted
4 packet(s) received
20.00% packet loss
round-trip min/avg/max = 0/74/79 ms
pc1-路由器接口
pc1-0/0/0
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=255 time=31 ms
From 192.168.1.254: bytes=32 seq=2 ttl=255 time=32 ms
From 192.168.1.254: bytes=32 seq=3 ttl=255 time=46 ms
From 192.168.1.254: bytes=32 seq=4 ttl=255 time=32 ms
From 192.168.1.254: bytes=32 seq=5 ttl=255 time=47 ms
--- 192.168.1.254 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/37/47 ms
pc1·-0/0/1
PC>ping 192.168.2.254
Ping 192.168.2.254: 32 data bytes, Press Ctrl_C to break
From 192.168.2.254: bytes=32 seq=1 ttl=255 time=32 ms
From 192.168.2.254: bytes=32 seq=2 ttl=255 time=31 ms
From 192.168.2.254: bytes=32 seq=3 ttl=255 time=47 ms
From 192.168.2.254: bytes=32 seq=4 ttl=255 time=47 ms
From 192.168.2.254: bytes=32 seq=5 ttl=255 time=31 ms
--- 192.168.2.254 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/37/47 ms