Cisco VLAN – Troubleshooting DHCP Requests Not Working with Inter-VLAN

ciscodhcpipv4packet-tracervlan

I have a router with some inter-vlan connections on, the router is connected to a switch, which is connected to 3 PC's on different vlans and then the switch is connected to another router which is the DHCP server. I cannot seem to get the DHCP requests working.

Structure

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

R1 Commands

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

Switch commands

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 Router

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

For some reason the VLAN50 PC can get the DHCP request and IP but all others fail, I have tried adding helper-addresses to see if that helps but they end up at the DHCP router and then just give up.

Best Answer

DHCP requests are sent from the hosts to the DHCP server via broadcast, and broadcasts don't normally cross a layer-3 boundary (router). You can either directly connect the DHCP server to each layer-2 domain, or you can use helper addresses. One way to achieve this is to use a trunk link from the switch to the DHCP router (replace interfaces as needed for the link):

Switch:

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

DHCP Router:

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
!

Another way is to put helper addresses on the R1 interfaces:

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