DHCP 请求不适用于 inter-vlan - 模拟 -

网络工程 思科 VLAN ipv4 dhcp 数据包追踪器
2021-07-23 23:42:33

我有一个路由器,有一些内部 vlan 连接,路由器连接到交换机,交换机连接到不同 vlan 上的 3 台 PC,然后交换机连接到另一个路由器,即 DHCP 服务器。我似乎无法使 DHCP 请求正常工作。

结构

R1- Switch: 3 PC's(PC1: VLAN30, PC2: VLAN40, PC3: VLAN50), R2 - DHCP Router.

R1 命令

interface GigabitEthernet0/1.30
encapsulation dot1Q 30
ip address 172.16.30.1 255.255.255.224

interface GigaEth0/1.40
encap dot1Q 40
ip add 172.16.40.1 255.255.255.224

int GigaEth0/1.50
encap dot1Q 50
ip add 172.16.50.1 255.255.255.224

切换命令

PC 1 - switchport access vlan 30
PC 2 - switchport access vlan 40
PC 3 - switchport access vlan 50
Link back to R1 - trunk link

DHCP路由器

ip dhcp excluded-address 172.16.30.1
ip dhcp excluded-address 172.16.40.1
ip dhcp excluded-address 172.16.50.1

ip dhcp pool forVLAN30
network 172.16.30.0 255.255.255.224
default-router 172.16.30.1
ip dhcp pool forVLAN40
network 172.16.40.0 255.255.255.224
default-router 172.16.40.1
ip dhcp pool forVLAN50
network 172.16.50.0 255.255.255.224
default-router 172.16.50.1
- link back to switch - 
ip address 172.16.50.2 255.255.255.224

出于某种原因,VLAN50 PC 可以获得 DHCP 请求和 IP,但所有其他人都失败了,我尝试添加helper-addresses以查看是否有帮助,但它们最终到达 DHCP 路由器,然后就放弃了。

2个回答

DHCP 请求通过广播从主机发送到 DHCP 服务器,并且广播通常不会跨越第 3 层边界(路由器)。您可以将 DHCP 服务器直接连接到每个二层域,也可以使用辅助地址。实现此目的的一种方法是使用从交换机到 DHCP 路由器的中继链路(根据链路的需要替换接口):

转变:

interface GigabitEthernet0/1
 switchport trunk encapsulation dot1q
 switchport trunk allowed vlan 30 - 50
 switchport mode trunk
 switchport mode nonegotiate
 no shutdown
!

DHCP 路由器:

interface GigabitEthernet0/1.30
 encapsulation dot1Q 30
 ip address 172.16.30.2 255.255.255.224
 no shutdown
!
interface GigabitEthernet0/1.40
 encapsulation dot1Q 40
 ip address 172.16.40.2 255.255.255.224
 no shutdown
!
interface GigabitEthernet0/1.50
 encapsulation dot1Q 50
 ip address 172.16.50.2 255.255.255.224
 no shutdown
!

另一种方法是将辅助地址放在 R1 接口上:

R1:

interface GigabitEthernet0/1.30
 encapsulation dot1Q 30
 ip address 172.16.30.1 255.255.255.224
 ip helper-address 172.16.50.2
!
interface GigabitEthernet0/1.40
 encapsulation dot1Q 40
 ip address 172.16.40.1 255.255.255.224
 ip helper-address 172.16.50.2
!
interface GigabitEthernet0/1.50
 encapsulation dot1Q 50
 ip addres 172.16.50.1 255.255.255.224
! Helper is not needed since the broadcast need not be routed

感谢@RonMaupin 的帮助。

经过一番尝试后,我意识到虽然我将交换机设置为 R1 作为中继链路,但我没有将交换机设置为 R2 - DHCP 路由器作为中继链路,因此它被设置为接入端口并且只允许VLAN50通过,所以为什么30,40连接不上。

因此,如果您遇到与我类似的问题,请检查您的辅助地址是否已排序,这可能是从一开始就存在的问题,并检查您的中继链接。