一、 要求:1.全网ip网段192.168.1.0/24
2.所有pc通过dhcp获取地址
3.网络可达
分析:1.划分网段
2.开启dhcp服务
3.接口配ip
4.创建ip池,加入网段、网关、dns
二、配置:1.开启dhcp服务
[Huawei]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done
[Huawei-GigabitEthernet0/0/0]dhcp select global
2.接口配ip
[Huawei]in g 0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 192.168.1.1 25
Aug 12 2022 18:51:18-08:00 Huawei %%01IFNET/4/LINK_STATE(l)[2]:The line protocol
IP on the interface GigabitEthernet0/0/0 has entered the UP state.
[Huawei-GigabitEthernet0/0/0]q
[Huawei]in g 0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 192.168.1.129 25
3.创建ip pool
[Huawei]undo ip pool 1
[Huawei]ip pool 1
Info: It's successful to create an IP address pool.
4.网段、网关、dns
[Huawei-ip-pool-2]network 192.168.1.128 mask 25
[Huawei-ip-pool-2]ga
[Huawei-ip-pool-2]gateway-list 192.168.1.129
[Huawei-ip-pool-2]dns
[Huawei-ip-pool-2]dns-list 8.8.8.8
三、结果
PC>ping 192.168.1.125
Ping 192.168.1.125: 32 data bytes, Press Ctrl_C to break
From 192.168.1.125: bytes=32 seq=1 ttl=128 time=31 ms
From 192.168.1.125: bytes=32 seq=2 ttl=128 time=47 ms
From 192.168.1.125: bytes=32 seq=3 ttl=128 time=47 ms
From 192.168.1.125: bytes=32 seq=4 ttl=128 time=31 ms
From 192.168.1.125: bytes=32 seq=5 ttl=128 time=31 ms
--- 192.168.1.125 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 31/37/47 ms
PC>
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=63 ms
From 192.168.1.254: bytes=32 seq=3 ttl=127 time=62 ms
From 192.168.1.254: bytes=32 seq=4 ttl=127 time=63 ms
From 192.168.1.254: bytes=32 seq=5 ttl=127 time=62 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/62/63 ms