例图:
要求:
1.全网IP地址段为192.168.1.0/24
2.所有PC通过DHCP获取IP地址
3.全网可达
分析:
1.子网划分
2.开启DHCP
2.划分两个地址池
3.地址池配置
4.DHCP配置
5.全网可达
6.ping验证
配置:
AR1配置:
<R1>sys
Enter system view, return user view with Ctrl+Z.
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]ip ad
[R1-GigabitEthernet0/0/0]ip address 192.168.1.1 25
Aug 12 2022 21:27:37-08:00 R1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP
on the interface GigabitEthernet0/0/0 has entered the UP state.
[R1-GigabitEthernet0/0/0]q
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip ad
[R1-GigabitEthernet0/0/1]ip address 192.168.1.129 25
Aug 12 2022 21:28:30-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface GigabitEthernet0/0/1 has entered the UP state.
[R1-GigabitEthernet0/0/1]q
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 10 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/25 Direct 0 0 D 192.168.1.1 GigabitEthernet
0/0/0
192.168.1.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.1.127/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
192.168.1.128/25 Direct 0 0 D 192.168.1.129 GigabitEthernet
0/0/1
192.168.1.129/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
[R1]ip pool 1
Info: It's successful to create an IP address pool.
[R1-ip-pool-1]network 192.168.1.0 mask 255.255.255.128
[R1-ip-pool-1]gateway-list 192.168.1.1
[R1-ip-pool-1]dns-list 6.6.6.6
[R1-ip-pool-1]q
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]dhcp select global
Error: Please enable DHCP in the global view first.
[R1-GigabitEthernet0/0/0]q
[R1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]dhcp select global
[R1-GigabitEthernet0/0/0]q
[R1]ip pool 2
Info: It's successful to create an IP address pool.
[R1-ip-pool-2]network 192.168.1.128 mask 255.255.255.128
[R1-ip-pool-2]gateway-list 192.168.1.129
[R1-ip-pool-2]dns-list 6.6.6.6
[R1-ip-pool-2]q
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]dhcp select global
结果:
全网可达
PC1:
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe22:42fc
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.1.126
Subnet mask.......................: 255.255.255.128
Gateway...........................: 192.168.1.1
Physical address..................: 54-89-98-22-42-FC
DNS server........................: 6.6.6.6
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=63 ms
From 192.168.1.253: bytes=32 seq=4 ttl=127 time=47 ms
From 192.168.1.253: bytes=32 seq=5 ttl=127 time=62 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/62/78 ms
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=47 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=79 ms
From 192.168.1.254: bytes=32 seq=5 ttl=127 time=78 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/66/79 ms
PC>
PC3:
Welcome to use PC Simulator!
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe3d:4ff2
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.1.254
Subnet mask.......................: 255.255.255.128
Gateway...........................: 192.168.1.129
Physical address..................: 54-89-98-3D-4F-F2
DNS server........................: 6.6.6.6
PC>ping 192.168.1.126
Ping 192.168.1.126: 32 data bytes, Press Ctrl_C to break
From 192.168.1.126: bytes=32 seq=1 ttl=127 time=78 ms
From 192.168.1.126: bytes=32 seq=2 ttl=127 time=78 ms
From 192.168.1.126: bytes=32 seq=3 ttl=127 time=63 ms
From 192.168.1.126: bytes=32 seq=4 ttl=127 time=62 ms
From 192.168.1.126: bytes=32 seq=5 ttl=127 time=63 ms
--- 192.168.1.126 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 62/68/78 ms