首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >直接连接路由器是否需要DHCP中继的路由协议才能工作?

直接连接路由器是否需要DHCP中继的路由协议才能工作?
EN

Network Engineering用户
提问于 2023-04-18 19:44:49
回答 1查看 122关注 0票数 2

假设我们有R01、R02和R03相互连接,它们分别连接到不同的子网SUB01、SUB02和SUB03。R03被设置为DHCP服务器,DHCP在其自己的子网中对工作站很好地工作。现在,我们使用一个IP助手地址R01和R02来设置R03,其中每个地址都是连接的。假设所有配置都是正确的。Do,我们需要为DHCP和DHCP中继配置路由协议,以实现它们的魔力?或者它们应该在这些配置中正常工作吗?

UPDATE (28APR2023):

这里有一个例子,说明了所有正在运行的路由器的信任以及路由表的情况。还有,下面是到数据包跟踪器文件的链接

代码语言:javascript
复制
R01(config)#do sh run
Building configuration...

Current configuration : 787 bytes
!
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname R01
!
!
!
!
!
!
!
!
ip cef
no ipv6 cef
!
!
!
!
license udi pid CISCO2911/K9 sn FTX1524X850-
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface GigabitEthernet0/0
 ip address 192.168.0.30 255.255.255.224
 ip helper-address 192.168.0.254
 duplex auto
 speed auto
!
interface GigabitEthernet0/1
 ip address 192.168.0.126 255.255.255.224
 duplex auto
 speed auto
!
interface GigabitEthernet0/2
 ip address 192.168.0.253 255.255.255.224
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
 shutdown
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
line con 0
 exec-timeout 0 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end


----------------------


R01(config)#do sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

     192.168.0.0/24 is variably subnetted, 6 subnets, 2 masks
C       192.168.0.0/27 is directly connected, GigabitEthernet0/0
L       192.168.0.30/32 is directly connected, GigabitEthernet0/0
C       192.168.0.96/27 is directly connected, GigabitEthernet0/1
L       192.168.0.126/32 is directly connected, GigabitEthernet0/1
C       192.168.0.224/27 is directly connected, GigabitEthernet0/2
L       192.168.0.253/32 is directly connected, GigabitEthernet0/2

========================

代码语言:javascript
复制
R02(config)#do sh run
Building configuration...

Current configuration : 787 bytes
!
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname R02
!
!
!
!
!
!
!
!
ip cef
no ipv6 cef
!
!
!
!
license udi pid CISCO2911/K9 sn FTX1524U1U3-
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface GigabitEthernet0/0
 ip address 192.168.0.62 255.255.255.224
 ip helper-address 192.168.0.189
 duplex auto
 speed auto
!
interface GigabitEthernet0/1
 ip address 192.168.0.125 255.255.255.224
 duplex auto
 speed auto
!
interface GigabitEthernet0/2
 ip address 192.168.0.190 255.255.255.224
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
 shutdown
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
line con 0
 exec-timeout 0 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end


----------------------


R02(config)#do sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

     192.168.0.0/24 is variably subnetted, 6 subnets, 2 masks
C       192.168.0.32/27 is directly connected, GigabitEthernet0/0
L       192.168.0.62/32 is directly connected, GigabitEthernet0/0
C       192.168.0.96/27 is directly connected, GigabitEthernet0/1
L       192.168.0.125/32 is directly connected, GigabitEthernet0/1
C       192.168.0.160/27 is directly connected, GigabitEthernet0/2
L       192.168.0.190/32 is directly connected, GigabitEthernet0/2

============================

代码语言:javascript
复制
R03(config)#do sh run
Building configuration...

Current configuration : 1125 bytes
!
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname R03
!
!
!
!
ip dhcp excluded-address 192.168.0.30
ip dhcp excluded-address 192.168.0.62
ip dhcp excluded-address 192.168.0.94
!
ip dhcp pool SUB01
 network 192.168.0.0 255.255.255.224
 default-router 192.168.0.30
ip dhcp pool SUB02
 network 192.168.0.32 255.255.255.224
 default-router 192.168.0.62
ip dhcp pool SUB03
 network 192.168.0.64 255.255.255.224
 default-router 192.168.0.94
!
!
!
ip cef
no ipv6 cef
!
!
!
!
license udi pid CISCO2911/K9 sn FTX15244VUL-
!
!
!
!
!
!
!
!
!
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface GigabitEthernet0/0
 ip address 192.168.0.94 255.255.255.224
 duplex auto
 speed auto
!
interface GigabitEthernet0/1
 ip address 192.168.0.254 255.255.255.224
 duplex auto
 speed auto
!
interface GigabitEthernet0/2
 ip address 192.168.0.189 255.255.255.224
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
 shutdown
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
line con 0
 exec-timeout 0 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
end



----------


 
    
R03(config)#do sh ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
       i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
       * - candidate default, U - per-user static route, o - ODR
       P - periodic downloaded static route

Gateway of last resort is not set

     192.168.0.0/24 is variably subnetted, 6 subnets, 2 masks
C       192.168.0.64/27 is directly connected, GigabitEthernet0/0
L       192.168.0.94/32 is directly connected, GigabitEthernet0/0
C       192.168.0.160/27 is directly connected, GigabitEthernet0/2
L       192.168.0.189/32 is directly connected, GigabitEthernet0/2
C       192.168.0.224/27 is directly connected, GigabitEthernet0/1
L       192.168.0.254/32 is directly connected, GigabitEthernet0/1



=====================
EN

回答 1

Network Engineering用户

回答已采纳

发布于 2023-04-18 20:10:10

路由器需要知道如何到达网络,以便向这些网络发送数据包。DHCP中继正在向其他网络发送数据包。路由器通过三种方式学习路由:

  • 直接连接网络
  • 静态配置路由
  • 来自路由协议的动态路由

由于R1和R2网络没有直接连接到R3,R3要么需要静态配置的路由指向各自的R1路由器和R2路由器,要么需要运行通用路由协议来交换路由信息。

路由器根据其路由表中的内容路由数据包。路由协议不路由数据包,它们被邻居路由器用来交换路由信息,以帮助填充它们的路由表。

关于您的评论的Edit:

请记住,DHCP适用于请求/响应。你的评论:

不是SUB01SUB02,而是R01R02。例如,PC1不需要知道R03在哪里。只是广播而已。这样做时,R01不应该丢弃DHCP数据包,因为IP helper-address是在R01的端口G0/0 (192.168.0.30/27)上配置的,而D19端口D18又将<#>directly连接到R03 ( DHCP )。这就是DHCP继电器的全部想法。对,是这样?

不解决R3需要向PC1发送DHCP响应这一事实,R3也不知道如何到达PC1网络(其中DHCP中继在接口上使用该网络中的地址进行配置),因此R3删除DHCP响应数据包,因为它在其路由表中找不到到达目标网络的路径。

是的,PC1广播DHCP请求,但是来自R3的单播响应需要转到PC1连接的R1接口的地址。

并不是所有的广播都像你所说的那样。广播不跨路由器。PC1广播DHCP请求,即使DHCP服务器位于同一网络上,来自DHCP服务器的响应也是单播。DHCP中继只需捕获广播并将单播请求发送到DHCP服务器,接收单播响应作为回报。这在您的场景中不会发生,因为DHCP中继地址是配置DHCP中继的接口网络中的接口地址。

只需在所有三个路由器上放置以下命令即可配置路由协议:

代码语言:javascript
复制
router ospf 1
 network 0.0.0.0 255.255.255.255 area 0
!

这将启动OSPF并包括OSPF进程中的所有路由器接口。如果您想在PC网络上阻止OSPF hellos (一种良好的实践),只需添加:

代码语言:javascript
复制
passive-interface GigabitEthernet0/0

您也可以在每个路由器上配置静态路由,但这有点复杂,而且不会扩展。

票数 6
EN
页面原文内容由Network Engineering提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://networkengineering.stackexchange.com/questions/82962

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档