测试目的
- 主机通过DHCP协议动态获取IP地址和DNS地址
应用场景
- 模拟实现可用于不同楼层不同部门/科室等不同网段实现互联。
- 模拟实现可用于不同部门/科室分类别连接外网。
测试环境
- eNSP 1.3.00.100 V100R003C000SPC100
- window 10
测试拓扑
拓扑配置
路由器AR1
配置
- 路由器开启
DHCP
全局使能,让路由器开启DHCP
功能。 - 配置IP地址池分配给
VLAN 10
,地址范围192.168.10.0/24
,网关地址192.168.10.254
,域名服务器地址8.8.8.8
。这里VLAN
没有意义,只是说明,真正起作用的是网关,即连接到网关地址192.168.10.254
互联的主机开启DHCP
即可获得这个地址池分配。 - 配置IP地址池分配给
VLAN 20
,地址范围192.168.20.0/24
,网关地址192.168.20.254
,域名服务器地址8.8.8.8
。这里VLAN
没有意义,只是说明,真正起作用的是网关,即连接到网关地址192.168.20.254
互联的主机开启DHCP
即可获得这个地址池分配。 - 开启与三层交换机
LWS1
互联接口的DHCP
使能,PC主机发送DHCP Discover
报文会被接收处理。
<AR1>sys
Enter system view, return user view with Ctrl+Z.
[AR1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[AR1]ip pool pool-10
Info: It's successful to create an IP address pool.
[AR1-ip-pool-pool-10]network 192.168.10.0 mask 24
[AR1-ip-pool-pool-10]gateway-list 192.168.10.254
[AR1-ip-pool-pool-10]dns-list 8.8.8.8
[AR1-ip-pool-pool-10]q
[AR1]
[AR1]ip pool pool-20
Info: It's successful to create an IP address pool.
[AR1-ip-pool-pool-20]network 192.168.20.0 mask 24
[AR1-ip-pool-pool-20]gateway-list 192.168.20.254
[AR1-ip-pool-pool-20]dns-list 8.8.8.8
[AR1-ip-pool-pool-20]q
[AR1]
[AR1]interface GigabitEthernet 0/0/1
[AR1-GigabitEthernet0/0/1]dhcp select global
[AR1-GigabitEthernet0/0/1]q
[AR1]q
<AR1>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait.......
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
<AR1>
完整配置
<AR1>dis current-configuration
[V200R003C00]
#
sysname AR1
#
snmp-agent local-engineid 800007DB03000000000000
snmp-agent
#
clock timezone China-Standard-Time minus 08:00:00
#
portal local-server load flash:/portalpage.zip
#
drop illegal-mac alarm
#
dns resolve
dns server 8.8.8.8
#
wlan ac-global carrier id other ac id 0
#
set cpu-usage threshold 80 restore 75
#
dhcp enable
#
acl number 2000
rule 5 permit source 192.168.0.0 0.0.255.255
#
ip pool pool-10
gateway-list 192.168.10.254
network 192.168.10.0 mask 255.255.255.0
dns-list 8.8.8.8
#
ip pool pool-20
gateway-list 192.168.20.254
network 192.168.20.0 mask 255.255.255.0
dns-list 8.8.8.8
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
local-user admin service-type http
#
firewall zone Local
priority 15
#
interface Ethernet0/0/0
#
interface Ethernet0/0/1
#
interface Ethernet0/0/2
#
interface Ethernet0/0/3
#
interface Ethernet0/0/4
#
interface Ethernet0/0/5
#
interface Ethernet0/0/6
#
interface Ethernet0/0/7
#
interface GigabitEthernet0/0/0
ip address 192.168.137.2 255.255.255.0
nat outbound 2000
#
interface GigabitEthernet0/0/1
ip address 192.168.100.2 255.255.255.0
dhcp select global
#
interface NULL0
#
ip route-static 0.0.0.0 0.0.0.0 192.168.137.1
ip route-static 192.168.0.0 255.255.0.0 192.168.100.1
#
user-interface con 0
authentication-mode password
user-interface vty 0 4
user-interface vty 16 20
#
wlan ac
#
return
<AR1>
交换机LWS1
配置
- 交换机开启
DHCP
全局使能,让路由器开启DHCP
功能。 - 配置
VLAN 10
口为DHCP中继(中转站),DHCP 服务器地址为192.168.100.2
。 - 配置
VLAN 20
口为DHCP中继(中转站),DHCP 服务器地址为192.168.100.2
。
[LSW1]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[LSW1]interface Vlanif 10
[LSW1-Vlanif10]dhcp select relay
[LSW1-Vlanif10]dhcp relay server-ip 192.168.100.2
[LSW1-Vlanif10]q
[LSW1]
[LSW1]interface Vlanif 20
[LSW1-Vlanif20]dhcp select relay
[LSW1-Vlanif20]dhcp relay server-ip 192.168.100.2
[LSW1-Vlanif20]q
[LSW1]q
<LSW1>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Now saving the current configuration to the slot 0.
Dec 23 2021 17:54:40-08:00 LSW1 %%01CFM/4/SAVE(l)[0]:The user chose Y when decid
ing whether to save the configuration to the device.
Save the configuration successfully.
<LSW1>
完整配置
<LSW1>dis current-configuration
#
sysname LSW1
#
vlan batch 10 20 100
#
cluster enable
ntdp enable
ndp enable
#
drop illegal-mac alarm
#
dhcp enable
#
diffserv domain default
#
drop-profile default
#
aaa
authentication-scheme default
authorization-scheme default
accounting-scheme default
domain default
domain default_admin
local-user admin password simple admin
local-user admin service-type http
#
interface Vlanif1
#
interface Vlanif10
ip address 192.168.10.254 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.100.2
#
interface Vlanif20
ip address 192.168.20.254 255.255.255.0
dhcp select relay
dhcp relay server-ip 192.168.100.2
#
interface Vlanif100
ip address 192.168.100.1 255.255.255.0
#
interface MEth0/0/1
#
interface GigabitEthernet0/0/1
port link-type trunk
port trunk allow-pass vlan 10 20
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 10 20
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 100
#
interface GigabitEthernet0/0/4
#
interface GigabitEthernet0/0/5
#
interface GigabitEthernet0/0/6
#
interface GigabitEthernet0/0/7
#
interface GigabitEthernet0/0/8
#
interface GigabitEthernet0/0/9
#
interface GigabitEthernet0/0/10
#
interface GigabitEthernet0/0/11
#
interface GigabitEthernet0/0/12
#
interface GigabitEthernet0/0/13
#
interface GigabitEthernet0/0/14
#
interface GigabitEthernet0/0/15
#
interface GigabitEthernet0/0/16
#
interface GigabitEthernet0/0/17
#
interface GigabitEthernet0/0/18
#
interface GigabitEthernet0/0/19
#
interface GigabitEthernet0/0/20
#
interface GigabitEthernet0/0/21
#
interface GigabitEthernet0/0/22
#
interface GigabitEthernet0/0/23
#
interface GigabitEthernet0/0/24
#
interface NULL0
#
ip route-static 0.0.0.0 0.0.0.0 192.168.100.2
#
user-interface con 0
user-interface vty 0 4
#
return
<LSW1>
PC机配置和测试
*选择DCHP,点击应用。
PC>ipconfig
Link local IPv6 address...........: fe80::5689:98ff:fe49:126c
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 0.0.0.0
Subnet mask.......................: 0.0.0.0
Gateway...........................: 0.0.0.0
Physical address..................: 54-89-98-49-12-6C
DNS server........................:
PC>ipconfig /renew
IP Configuration
Link local IPv6 address...........: fe80::5689:98ff:fe49:126c
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.10.253
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.10.254
Physical address..................: 54-89-98-49-12-6C
DNS server........................: 8.8.8.8
PC>ping 8.8.8.8
Ping 8.8.8.8: 32 data bytes, Press Ctrl_C to break
From 8.8.8.8: bytes=32 seq=1 ttl=109 time=125 ms
From 8.8.8.8: bytes=32 seq=2 ttl=109 time=110 ms
From 8.8.8.8: bytes=32 seq=3 ttl=109 time=110 ms
From 8.8.8.8: bytes=32 seq=4 ttl=109 time=125 ms
From 8.8.8.8: bytes=32 seq=5 ttl=109 time=109 ms
--- 8.8.8.8 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 109/115/125 ms
PC>ping www.baidu.com
www.baidu.com -> www.a.shifen.com
www.a.shifen.com -> www.wshifen.com
Ping www.wshifen.com [103.235.46.39]: 32 data bytes, Press Ctrl_C to break
From 103.235.46.39: bytes=32 seq=1 ttl=40 time=265 ms
From 103.235.46.39: bytes=32 seq=2 ttl=40 time=234 ms
From 103.235.46.39: bytes=32 seq=3 ttl=40 time=235 ms
From 103.235.46.39: bytes=32 seq=4 ttl=40 time=250 ms
From 103.235.46.39: bytes=32 seq=5 ttl=40 time=234 ms
--- 103.235.46.39 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 234/243/265 ms
PC>