秒懂!详细!DHCP中继

DHCP中继原理

1 当dhcp client 启动并进行dhcp 初始化时,它会在本地网络广播配置请求报文。
2 如果本地网络存在dhcp server,则可以直接进行dhcp 配置,不需要dhcp relay。
3 如果本地网络没有dhcp server,则与本地网络相连的具有dhcprelay 功能的网络设备收到该广播报文后,将进行适当处理并转发给指定的其它网络上的dhcp server。
4 dhcp server 根据dhcp client 提供的信息进行相应的配置,并通过dhcp relay 将配置信息发送给dhcp client,完成对dhcp client 的动态配置。
事实上,从开始到最终完成配置,需要多个这样的交互过程。
1 dhcp relay设备修改dhcp消息中的相应字段,把dhcp的广播包改成单播包,并负责在服务器与客户机之间转换。
2 netcore路由器(2x05)可以作为dhcp relay 代理。

**

DHCP实验流程

**
dhcp中继拓扑图在这里插入图片描述

sw2配置

The device is running!

huawei>u t m

Info: Current terminal monitor is off.
huawei>sys

Enter system view, return user view with Ctrl+Z.
[Huawei]sysn
[Huawei]sysname SW2
[SW2]v b 10 20
Info: This operation may take a few seconds. Please wait for a moment…done.
[SW2]int e0/0/1
[SW2-Ethernet0/0/1]p l a
[SW2-Ethernet0/0/1]p d v 10
[SW2-Ethernet0/0/1]un sh
Info: Interface Ethernet0/0/1 is not shutdown.
[SW2-Ethernet0/0/1]int e0/0/2
[SW2-Ethernet0/0/2]p l a
[SW2-Ethernet0/0/2]p d v 20
[SW2-Ethernet0/0/2]un sh
Info: Interface Ethernet0/0/2 is not shutdown.
[SW2-Ethernet0/0/2]int e0/0/3
[SW2-Ethernet0/0/3]p l a
[SW2-Ethernet0/0/3]p d v 10
[SW2-Ethernet0/0/3]un sh
Info: Interface Ethernet0/0/3 is not shutdown.
[SW2-Ethernet0/0/3]int e0/0/4
[SW2-Ethernet0/0/4]p l a
[SW2-Ethernet0/0/4]p d v 20
[SW2-Ethernet0/0/4]un sh
Info: Interface Ethernet0/0/4 is not shutdown.
[SW2-Ethernet0/0/4]int g0/0/1
[SW2-GigabitEthernet0/0/1]p l t
[SW2-GigabitEthernet0/0/1]p t a v 10 20
[SW2-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[SW2-GigabitEthernet0/0/1] User interface con0 is available

Please Press ENTER.

sys
Enter system view, return user view with Ctrl+Z.
[SW2]dis cu
[SW2]dis current-configuration

sysname SW2

vlan batch 10 20

cluster enable
ntdp enable
ndp enable

drop illegal-mac alarm

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

[SW2]et
[SW2]ret
[SW2]return
sav
save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:
Jun 29 2020 15:18:06-08:00 SW2 %%01CFM/4/SAVE(l)[0]:The user chose Y when decidi
ng whether to save the configuration to the device.
Now saving the current configuration to the slot 0.
Save the configuration successfully.

**

R1

**
The device is running!

u t m Info: Current terminal monitor is off. sys Enter system view, return user view with Ctrl+Z. [Huawei]sysn [Huawei]sysname R1 [R1]dhcp en [R1]dhcp enable Info: The operation may take a few seconds. Please wait for a moment.done. [R1]int g0/0/0.10 [R1-GigabitEthernet0/0/0.10]d [R1-GigabitEthernet0/0/0.10]dh [R1-GigabitEthernet0/0/0.10]dhcp en [R1-GigabitEthernet0/0/0.10]dhcp en [R1-GigabitEthernet0/0/0.10]dhcp s [R1-GigabitEthernet0/0/0.10]dhcp select r [R1-GigabitEthernet0/0/0.10]dhcp select relay [R1-GigabitEthernet0/0/0.10]dh [R1-GigabitEthernet0/0/0.10]dhcp r [R1-GigabitEthernet0/0/0.10]dhcp relay s [R1-GigabitEthernet0/0/0.10]dhcp relay server-ip 14.0.0.2

[R1-GigabitEthernet0/0/0.10]int g0/0/0.20
[R1-GigabitEthernet0/0/0.20]dhcp s
[R1-GigabitEthernet0/0/0.20]dhcp sel
[R1-GigabitEthernet0/0/0.20]dhcp select r
[R1-GigabitEthernet0/0/0.20]dhcp select relay
[R1-GigabitEthernet0/0/0.20]dhcp relay server-ip 14.0.0.2
[R1-GigabitEthernet0/0/0.20]un sh
Info: Interface GigabitEthernet0/0/0.20 is not shutdown.
[R1-GigabitEthernet0/0/0.20]dis thi
[R1-GigabitEthernet0/0/0.20]dis thi
[R1-GigabitEthernet0/0/0.20]dis thi
[V200R003C00]

interface GigabitEthernet0/0/0.20
dhcp select relay
dhcp relay server-ip 14.0.0.2

return
[R1-GigabitEthernet0/0/0.20]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 14.0.0.1 24
[R1-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R1-GigabitEthernet0/0/1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip add 12.0.0.1 24
[R1-GigabitEthernet0/0/2]un sh
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[R1-GigabitEthernet0/0/2]q
[R1]int g0/0/0.10
[R1-GigabitEthernet0/0/0.10]a
[R1-GigabitEthernet0/0/0.10]arp b
[R1-GigabitEthernet0/0/0.10]arp broadcast en
[R1-GigabitEthernet0/0/0.10]arp broadcast enable

Error: This interface is not a termination interface.
[R1-GigabitEthernet0/0/0.10]d
[R1-GigabitEthernet0/0/0.10]do
[R1-GigabitEthernet0/0/0.10]dot1q t
[R1-GigabitEthernet0/0/0.10]dot1q termination v
[R1-GigabitEthernet0/0/0.10]dot1q termination vid 10
[R1-GigabitEthernet0/0/0.10]a
[R1-GigabitEthernet0/0/0.10]arp b
[R1-GigabitEthernet0/0/0.10]arp broadcast e
[R1-GigabitEthernet0/0/0.10]arp broadcast enable
[R1-GigabitEthernet0/0/0.10]ip add 192.168.10.1 24
[R1-GigabitEthernet0/0/0.10]un sh
Info: Interface GigabitEthernet0/0/0.10 is not shutdown.
[R1-GigabitEthernet0/0/0.10]q
[R1]int g0/0/0.20
[R1-GigabitEthernet0/0/0.20]d
[R1-GigabitEthernet0/0/0.20]do
[R1-GigabitEthernet0/0/0.20]dot1q t
[R1-GigabitEthernet0/0/0.20]dot1q termination v
[R1-GigabitEthernet0/0/0.20]dot1q termination vid 20
[R1-GigabitEthernet0/0/0.20]a
[R1-GigabitEthernet0/0/0.20]arp b
[R1-GigabitEthernet0/0/0.20]arp broadcast e
[R1-GigabitEthernet0/0/0.20]arp broadcast enable
[R1-GigabitEthernet0/0/0.20]ip add 192.168.20.1 24
[R1-GigabitEthernet0/0/0.20]un sh
Info: Interface GigabitEthernet0/0/0.20 is not shutdown.
[R1-GigabitEthernet0/0/0.20]dis th
[R1-GigabitEthernet0/0/0.20]dis th
[V200R003C00]

interface GigabitEthernet0/0/0.20
dot1q termination vid 20
ip address 192.168.20.1 255.255.255.0
arp broadcast enable
dhcp select relay
dhcp relay server-ip 14.0.0.2

return
[R1-GigabitEthernet0/0/0.20]
[R1-GigabitEthernet0/0/0.20]q
[R1]ip r
[R1]ip ro
[R1]ip route-static 15.0.0.0 24 12.0.0.2
[R1]

Please check whether system data has been changed, and save data in time

Configuration console time out, please press any key to log on

sys
Enter system view, return user view with Ctrl+Z.
[R1]dis c
[R1]dis calibrate
^
Error:Incomplete command found at ‘^’ position.
[R1]dis cu
[R1]dis current-configuration
[V200R003C00]

sysname R1

snmp-agent local-engineid 800007DB03000000000000
snmp-agent

clock timezone China-Standard-Time minus 08:00:00

portal local-server load portalpage.zip

drop illegal-mac alarm

set cpu-usage threshold 80 restore 75

dhcp enable

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}% %

[R1]ret
sve
sa
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


**

R2配置

**
The device is running!

u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn
[Huawei]sysname R2
[R2]

Please check whether system data has been changed, and save data in time

Configuration console time out, please press any key to log on

utm
^
Error: Unrecognized command found at ‘^’ position.
u t m
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R2-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R2-GigabitEthernet0/0/0]q
[R2]dh
[R2]dhcp e
[R2]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R2]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 15.0.0.1 24
[R2-GigabitEthernet0/0/1]dh
[R2-GigabitEthernet0/0/1]dhcp s
[R2-GigabitEthernet0/0/1]dhcp select r
[R2-GigabitEthernet0/0/1]dhcp select relay
[R2-GigabitEthernet0/0/1]dh
[R2-GigabitEthernet0/0/1]dhcp r
[R2-GigabitEthernet0/0/1]dhcp relay s
[R2-GigabitEthernet0/0/1]dhcp relay server-ip 14.0.0.2
[R2-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R2-GigabitEthernet0/0/1]dis th
[R2-GigabitEthernet0/0/1]dis th
[V200R003C00]

interface GigabitEthernet0/0/1
ip address 15.0.0.1 255.255.255.0
dhcp select relay
dhcp relay server-ip 14.0.0.2

return
[R2-GigabitEthernet0/0/1]
[R2-GigabitEthernet0/0/1]q
[R2]ip ro
[R2]ip route-static 0.0.0.0 0.0.0.0 12.0.0.1
[R2]

Please check whether system data has been changed, and save data in time

Configuration console time out, please press any key to log on

sys
Enter system view, return user view with Ctrl+Z.
[R2]dis ip ro
Route Flags: R - relay, D - download to fib

Routing Tables: Public
Destinations : 11 Routes : 11

Destination/Mask Proto Pre Cost Flags NextHop Interface

    0.0.0.0/0   Static  60   0          RD   12.0.0.1        GigabitEthernet

0/0/0
12.0.0.0/24 Direct 0 0 D 12.0.0.2 GigabitEthernet
0/0/0
12.0.0.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
12.0.0.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
15.0.0.0/24 Direct 0 0 D 15.0.0.1 GigabitEthernet
0/0/1
15.0.0.1/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
15.0.0.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
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
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0

[R2]dis ip int b
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 1

Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 12.0.0.2/24 up up
GigabitEthernet0/0/1 15.0.0.1/24 up up
GigabitEthernet0/0/2 unassigned down down
NULL0 unassigned up up(s)
[R2]ret
sa
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

**

R3 配置

**
The device is running!

U T M
Info: Current terminal monitor is off.
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn
[Huawei]sysname R3
[R3]dh
[R3]dhcp en
[R3]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 14.0.0.2 24
[R3-GigabitEthernet0/0/0]d
[R3-GigabitEthernet0/0/0]dh
[R3-GigabitEthernet0/0/0]dhcp sel
[R3-GigabitEthernet0/0/0]dhcp select g
[R3-GigabitEthernet0/0/0]dhcp select global
[R3-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R3-GigabitEthernet0/0/0]q
[R3]ip p
[R3]ip pool d
[R3]ip pool dh
[R3]ip pool dhcp15
Info: It’s successful to create an IP address pool.
[R3-ip-pool-dhcp15]net
[R3-ip-pool-dhcp15]network 15.0.0.0 mask 24
[R3-ip-pool-dhcp15]ga
[R3-ip-pool-dhcp15]gateway-list 15.0.0.1
[R3-ip-pool-dhcp15]dn
[R3-ip-pool-dhcp15]dns-list 8.8.8.8 2.2.2.2
[R3-ip-pool-dhcp15]ex
[R3-ip-pool-dhcp15]excluded-ip-address 15.0.0.100 15.0.0.254
[R3-ip-pool-dhcp15]sta
[R3-ip-pool-dhcp15]static-bind ip
[R3-ip-pool-dhcp15]static-bind ip-address 15.0.0.88 ma
[R3-ip-pool-dhcp15]static-bind ip-address 15.0.0.88 mac-address 5489-9877-80A
D
[R3-ip-pool-dhcp15]q
[R3]ip pooldh
[R3]ip pool dh
[R3]ip pool dhcpvlan10
Info: It’s successful to create an IP address pool.
[R3-ip-pool-dhcpvlan10]net
[R3-ip-pool-dhcpvlan10]netw
[R3-ip-pool-dhcpvlan10]network 192.168.10.0 mask 24
[R3-ip-pool-dhcpvlan10]g
[R3-ip-pool-dhcpvlan10]gateway-list 192.168.10.1
[R3-ip-pool-dhcpvlan10]d
[R3-ip-pool-dhcpvlan10]dn
[R3-ip-pool-dhcpvlan10]dns-list 8.8.8.8 2.2.2.2
[R3-ip-pool-dhcpvlan10]q
[R3]ip pool dhcpvlan20
Info: It’s successful to create an IP address pool.
[R3-ip-pool-dhcpvlan20]nnetw
[R3-ip-pool-dhcpvlan20]netw
[R3-ip-pool-dhcpvlan20]network 192.168.20.0 mask 24
[R3-ip-pool-dhcpvlan20]ga
[R3-ip-pool-dhcpvlan20]gateway-list 192.168.20.1
[R3-ip-pool-dhcpvlan20]dns
[R3-ip-pool-dhcpvlan20]dns-list 8.8.8.8
[R3-ip-pool-dhcpvlan20]q
[R3]ip ro
[R3]ip route-
[R3]ip route-static 0.0.0.0 0.0.0.0 14.0.0.1
[R3]

Please check whether system data has been changed, and save data in time

Configuration console time out, please press any key to log on

sys
Enter system view, return user view with Ctrl+Z.
[R3]dis cu
[R3]dis current-configuration
[V200R003C00]

sysname R3

snmp-agent local-engineid 800007DB03000000000000
snmp-agent

clock timezone China-Standard-Time minus 08:00:00

portal local-server load portalpage.zip

drop illegal-mac alarm

set cpu-usage threshold 80 restore 75

dhcp enable

ip pool dhcp15
gateway-list 15.0.0.1
network 15.0.0.0 mask 255.255.255.0
static-bind ip-address 15.0.0.88 mac-address 5489-9877-80ad
excluded-ip-address 15.0.0.100 15.0.0.254
dns-list 8.8.8.8 2.2.2.2

[R3]ret
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

  • 9
    点赞
  • 34
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值