如何为共享交换机的 2 个 VLAN/子网配置 DHCP 池

网络工程 VLAN 思科-ios dhcp cisco 命令 数据包追踪器
2021-07-24 20:52:01

我已经在第 3 层交换机上设置了 DHCP 池,该交换机连接到 13 个第 2 层交换机。其中大多数都有自己的子网和 VLAN,在这种情况下一切正常。但是当有两个 VLAN/子网共享一个交换机时,该 VLAN 或子网上的主机似乎无法获得 DHCP 服务器分配的 IP 地址,而是拥有链路本地地址。我可能做错了什么?

我正在使用 Cisco Catalyst 交换机。我也一直在尝试使用 Packet Tracer 来解决这个问题,但运气不佳。

以下是 vlan 和子网的详细信息:


在此处输入图片说明


下面是一些配置。包括主 L3 交换机,以及一些有问题的交换机。


多层交换机

L3CORE#show run
Building configuration...

Current configuration : 5687 bytes
!
version 12.2(37)SE1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname L3CORE
!
!
!
ip dhcp excluded-address 10.0.0.1
ip dhcp excluded-address 10.0.2.1
ip dhcp excluded-address 10.0.2.65
ip dhcp excluded-address 10.0.2.129
ip dhcp excluded-address 10.0.2.161
ip dhcp excluded-address 10.0.2.193
ip dhcp excluded-address 10.0.2.225
ip dhcp excluded-address 10.0.3.1
ip dhcp excluded-address 10.0.3.33
ip dhcp excluded-address 10.0.3.65
ip dhcp excluded-address 10.0.3.81
ip dhcp excluded-address 10.0.3.97
ip dhcp excluded-address 10.0.3.113
ip dhcp excluded-address 10.0.3.121
!
ip dhcp pool 425
 network 10.0.0.0 255.255.254.0
ip dhcp pool 325
 network 10.0.2.0 255.255.255.192
 default-router 10.0.0.1
ip dhcp pool 350
 network 10.0.3.80 255.255.255.240
 default-router 10.0.0.1
ip dhcp pool vlan350
 network 10.0.3.80 255.255.255.240
 default-router 10.0.3.81
ip dhcp pool 150
 network 10.0.2.192 255.255.255.224
 default-router 10.0.0.1
ip dhcp pool range
ip dhcp pool vlan425
 network 10.0.0.0 255.255.254.0
ip dhcp pool vlan325
 network 10.0.2.0 255.255.255.192
 default-router 10.0.2.1
ip dhcp pool vlan225
 network 10.0.2.64 255.255.255.192
 default-router 10.0.2.65
ip dhcp pool vlan375
 network 10.0.2.128 255.255.255.224
 default-router 10.0.2.129
ip dhcp pool vlan300
 network 10.0.2.160 255.255.255.224
 default-router 10.0.2.161
ip dhcp pool vlan150
 network 10.0.2.192 255.255.255.224
 default-router 10.0.2.193
ip dhcp pool vlan250
 network 10.0.2.224 255.255.255.224
 default-router 10.0.2.225
ip dhcp pool vlan275
 network 10.0.3.0 255.255.255.224
 default-router 10.0.3.1
ip dhcp pool vlan125
 network 10.0.3.32 255.255.255.224
 default-router 10.0.3.33
ip dhcp pool vlan200
 network 10.0.3.64 255.255.255.240
 default-router 10.0.3.65
ip dhcp pool vlan175
 network 10.0.3.96 255.255.255.240
 default-router 10.0.3.97
ip dhcp pool vlan400
 network 10.0.3.120 255.255.255.252
 default-router 10.0.3.121
ip dhcp pool vlan100
 network 10.0.3.112 255.255.255.248
 default-router 10.0.3.113
!
!
ip routing
!
!
!
!
!
!
!
!
!
!
!
!
no ip domain-lookup
!
!
spanning-tree mode pvst
!
!
!
!
!
!
interface FastEthernet0/1
 switchport trunk allowed vlan 100,350,375,400,425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/2
 switchport trunk allowed vlan 325,425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/3
 switchport trunk allowed vlan 225,275,425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/4
 switchport trunk allowed vlan 150,425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/5
 switchport trunk allowed vlan 175,425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/6
 switchport trunk allowed vlan 250,425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/7
 switchport trunk allowed vlan 425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/8
 switchport trunk allowed vlan 375,425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/9
 switchport trunk allowed vlan 425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/10
 switchport trunk allowed vlan 425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/11
 switchport trunk allowed vlan 325,425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/12
 switchport trunk allowed vlan 300,425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/13
 switchport trunk allowed vlan 200,425
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/14
 switchport trunk encapsulation dot1q
 switchport mode trunk
!
interface FastEthernet0/15
!
interface FastEthernet0/16
!
interface FastEthernet0/17
!
interface FastEthernet0/18
!
interface FastEthernet0/19
!
interface FastEthernet0/20
!
interface FastEthernet0/21
!
interface FastEthernet0/22
!
interface FastEthernet0/23
!
interface FastEthernet0/24
!
interface GigabitEthernet0/1
!
interface GigabitEthernet0/2
!
interface Vlan1
 no ip address
 shutdown
!
interface Vlan100
 mac-address 00e0.8f6d.4301
 ip address 10.0.3.113 255.255.255.248
!
interface Vlan125
 mac-address 00e0.8f6d.4302
 ip address 10.0.3.33 255.255.255.224
!
interface Vlan150
 mac-address 00e0.8f6d.4303
 ip address 10.0.2.193 255.255.255.224
!
interface Vlan175
 mac-address 00e0.8f6d.4304
 ip address 10.0.3.97 255.255.255.240
!
interface Vlan200
 mac-address 00e0.8f6d.4305
 ip address 10.0.3.65 255.255.255.240
!
interface Vlan225
 mac-address 00e0.8f6d.4306
 ip address 10.0.2.65 255.255.255.192
!
interface Vlan250
 mac-address 00e0.8f6d.4307
 ip address 10.0.2.225 255.255.255.224
!
interface Vlan275
 mac-address 00e0.8f6d.4308
 ip address 10.0.3.1 255.255.255.224
!
interface Vlan300
 mac-address 00e0.8f6d.4309
 ip address 10.0.2.161 255.255.255.224
!
interface Vlan325
 mac-address 00e0.8f6d.430a
 ip address 10.0.2.1 255.255.255.192
!
interface Vlan350
 mac-address 00e0.8f6d.430b
 ip address 10.0.3.81 255.255.255.240
!
interface Vlan375
 mac-address 00e0.8f6d.430c
 ip address 10.0.2.129 255.255.255.224
!
interface Vlan400
 mac-address 00e0.8f6d.430d
 ip address 10.0.3.121 255.255.255.252
!
interface Vlan425
 mac-address 00e0.8f6d.430e
 ip address 10.0.0.1 255.255.254.0
!
router rip
 network 10.0.0.0
!
ip classless
!
ip flow-export version 9
!
!
!
!
!
!
!
!
line con 0
!
line aux 0
!
line vty 0 4
 login
!
!
!
!
end

开关03

S03#show run
Building configuration...

Current configuration : 2485 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname S03
!
!
!
clock timezone awst 8
!
no ip domain-lookup
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
interface FastEthernet0/1
 switchport access vlan 275
 switchport mode access
!
interface FastEthernet0/2
 switchport access vlan 275
 switchport mode access
!
interface FastEthernet0/3
 switchport access vlan 275
 switchport mode access
!
interface FastEthernet0/4
 switchport access vlan 275
 switchport mode access
!
interface FastEthernet0/5
 switchport access vlan 275
 switchport mode access
!
interface FastEthernet0/6
 switchport access vlan 275
 switchport mode access
!
interface FastEthernet0/7
 switchport access vlan 275
 switchport mode access
!
interface FastEthernet0/8
 switchport access vlan 275
 switchport mode access
!
interface FastEthernet0/9
 switchport access vlan 275
 switchport mode access
!
interface FastEthernet0/10
 switchport access vlan 275
 switchport mode access
!
interface FastEthernet0/11
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/12
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/13
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/14
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/15
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/16
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/17
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/18
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/19
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/20
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/21
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/22
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/23
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/24
 switchport access vlan 225
 switchport mode access
!
interface GigabitEthernet0/1
 switchport trunk allowed vlan 225,275,425
 switchport mode trunk
!
interface GigabitEthernet0/2
 switchport access vlan 425
 switchport mode access
!
interface Vlan1
 no ip address
 shutdown
!
!
!
!
line con 0
!
line vty 0 4
 login
line vty 5 15
 login
!
!
!
!
end

开关07

S07#show run
Building configuration...

Current configuration : 2511 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname S07
!
!
!
clock timezone awst 8
!
no ip domain-lookup
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
interface FastEthernet0/1
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/2
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/3
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/4
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/5
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/6
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/7
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/8
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/9
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/10
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/11
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/12
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/13
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/14
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/15
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/16
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/17
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/18
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/19
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/20
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/21
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/22
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/23
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/24
 switchport access vlan 225
 switchport mode access
!
interface GigabitEthernet0/1
 switchport trunk allowed vlan 225,425
 switchport mode trunk
!
interface GigabitEthernet0/2
 switchport access vlan 425
 switchport mode access
!
interface Vlan1
 no ip address
 shutdown
!
ip default-gateway 10.0.0.1
!
!
!
!
line con 0
!
line vty 0 4
 login
line vty 5 15
 login
!
!
!
!
end

开关08

S08#show run

Building configuration...

Current configuration : 2582 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname S08
!
!
ip dhcp excluded-address 10.0.2.65
!
clock timezone awst 8
!
no ip domain-lookup
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
interface FastEthernet0/1
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/2
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/3
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/4
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/5
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/6
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/7
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/8
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/9
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/10
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/11
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/12
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/13
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/14
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/15
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/16
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/17
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/18
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/19
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/20
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/21
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/22
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/23
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/24
 switchport access vlan 225
 switchport mode access
!
interface GigabitEthernet0/1
 switchport trunk allowed vlan 225,425
 switchport mode trunk
!
interface GigabitEthernet0/2
 switchport access vlan 425
 switchport mode access
!
interface Vlan1
 no ip address
 shutdown
!
interface Vlan225
 mac-address 0007.ec6d.3c01
 no ip address
!
!
!
!
line con 0
!
line vty 0 4
 login
line vty 5 15
 login
!
!
!
!
end

开关09

S09#show run
Building configuration...

Current configuration : 2481 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname S09
!
!
!
clock timezone awst 8
!
no ip domain-lookup
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
interface FastEthernet0/1
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/2
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/3
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/4
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/5
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/6
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/7
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/8
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/9
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/10
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/11
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/12
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/13
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/14
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/15
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/16
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/17
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/18
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/19
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/20
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/21
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/22
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/23
 switchport access vlan 225
 switchport mode access
!
interface FastEthernet0/24
 switchport access vlan 225
 switchport mode access
!
interface GigabitEthernet0/1
 switchport trunk allowed vlan 225,425
 switchport mode trunk
!
interface GigabitEthernet0/2
 switchport access vlan 425
 switchport mode access
!
interface Vlan1
 no ip address
 shutdown
!
!
!
!
line con 0
!
line vty 0 4
 login
line vty 5 15
 login
!
!
!
!
end

在此处输入图片说明

1个回答

我认为一个大问题是您没有在接入交换机上定义 VLAN。是的,您有 VLAN 的 SVI,但您没有全局定义 VLAN。

例如:

Vlan 225
 name Production
exit
!
Vlan 275
 name Finance
exit
!

忘记这样做通常会导致您描述的问题。再加上您在第 3 层交换机上遇到的所有 DHCP 服务器问题,您就真的一团糟。

有关相同问题,请参阅问题,答案是定义 VLAN。