从子网以外的池中提取 DHCP

网络工程 思科 dhcp
2022-02-16 20:17:00

我有一个第三层交换机连接到四个第二层交换机,多台 PC 连接到它们。每个接口都分配了自己的 IP 以及关联的 DHCP 池,但是,PC 从随机池中提取 IP。我正在运行以下配置:

!
interface FastEthernet0/10
 no switchport
 ip address 192.168.4.1 255.255.255.0 
 duplex auto
 speed auto
!
interface FastEthernet0/11
 no switchport
 ip address 192.168.0.1 255.255.254.0
 duplex auto
 speed auto
!
interface FastEthernet0/12
 no switchport
 ip address 192.168.6.1 255.255.255.240
 duplex auto
 speed auto
!
interface FastEthernet0/13
 no switchport
 ip address 192.168.5.1 255.255.255.0
 duplex auto
 speed auto
!

ip dhcp pool HQSwitch1Pool
network 192.168.4.0 255.255.255.0
!
ip dhcp excluded-address 192.168.4.1

ip dhcp pool HQSwitch2Pool
 network 192.168.0.0 255.255.254.0
!
ip dhcp excluded-address 192.168.0.1

ip dhcp pool HQSwitch3Pool
 network 192.168.6.0 255.255.255.240
!
ip dhcp excluded-address 192.168.6.1

ip dhcp pool HQSwitch4Pool
 network 192.168.5.0 255.255.255.0
!
ip dhcp excluded-address 192.168.5.1
!

任何帮助,将不胜感激

2个回答

我希望我能发表评论,因为这不是一个真正的答案;更多的故障排除技术。

由于这是一个多层交换机,请尝试将您的 IP 寻址移至虚拟接口,而不是将它们直接分配给交换机端口。

你的配置看起来像:

interface vlan 100
 description "HQ-Switch-1 Gateway"
 ip address 192.168.4.1 255.255.255.0
!
interface vlan 200
 description "HQ-Switch-2 Gateway"
 ip address 192.168.0.1 255.255.255.0
!
interface vlan 300
 description "HQ-Switch-3 Gateway"
 ip address 192.168.6.1 255.255.255.240
!
interface vlan 400
 description "HQ-Switch-4 Gateway"
 ip address 192.168.5.1 255.255.255.0
!
interface FastEthernet0/10
 switchport mode access
 switchport access vlan 100
!
interface FastEthernet0/11
 switchport mode access
 switchport access vlan 200
!
interface FastEthernet0/12
 switchport mode access
 switchport access vlan 300
!
interface FastEthernet0/13
 switchport mode access
 switchport access vlan 400
!
ip dhcp excluded-address 192.168.0.1
ip dhcp excluded-address 192.168.4.1
ip dhcp excluded-address 192.168.6.1
ip dhcp excluded-address 192.168.5.1
!
ip dhcp pool HQSwitch1Pool
network 192.168.4.0 255.255.255.0
!
ip dhcp pool HQSwitch2Pool
 network 192.168.0.0 255.255.254.0
!
ip dhcp pool HQSwitch3Pool
 network 192.168.6.0 255.255.255.240
!
ip dhcp pool HQSwitch4Pool
 network 192.168.5.0 255.255.255.0
!

老实说,假设 f0/10-13 插入其他交换机,您应该使用 802.1q 中继而不是将它们作为访问端口运行(无论如何您现在都在这样做。)

然后,使用您的其他交换机将各个端口分配给适当的 vlan。这里的interface range命令是你的朋友。

除了 Rowshi 所说的之外,您还可以将 default-router 命令添加到您的池中。这会将 DHCP 请求指向虚拟接口 IP 地址。

你的配置看起来像这样:

interface vlan 100
description "HQ-Switch-1 Gateway"
ip address 192.168.4.1 255.255.255.0
!
interface vlan 200
description "HQ-Switch-2 Gateway"
ip address 192.168.0.1 255.255.255.0
!
interface vlan 300
description "HQ-Switch-3 Gateway"
ip address 192.168.6.1 255.255.255.240
!
interface vlan 400
description "HQ-Switch-4 Gateway"
ip address 192.168.5.1 255.255.255.0
!
interface FastEthernet0/10
switchport mode access
switchport access vlan 100
!
interface FastEthernet0/11
switchport mode access
switchport access vlan 200
!
interface FastEthernet0/12
switchport mode access
switchport access vlan 300
!
interface FastEthernet0/13
switchport mode access
switchport access vlan 400
!
ip dhcp excluded-address 192.168.0.1
ip dhcp excluded-address 192.168.4.1
ip dhcp excluded-address 192.168.6.1
ip dhcp excluded-address 192.168.5.1
!
ip dhcp pool HQSwitch1Pool
network 192.168.4.0 255.255.255.0
default-router 192.168.4.1
!
ip dhcp pool HQSwitch2Pool
network 192.168.0.0 255.255.254.0
default-router 192.168.0.1
!
ip dhcp pool HQSwitch3Pool
network 192.168.6.0 255.255.255.240
default-router 192.168.6.1
!
ip dhcp pool HQSwitch4Pool
network 192.168.5.0 255.255.255.0
default-router 192.168.5.1
!