Cisco – How to configure DHCP Relay Agent with multiple VLANs

ciscodhcppacket-tracervlan

I have a network with 2 routers.
Router 0 is a DHCP server and Router 1 I assume should be a relay agent. The routing protocol I use is EIGRP.

The problem is that PC in vlan 15 and vlan 20 cannot get the ip addresses from the dhcp server. I found out that we can configure ip-helper on the switch but it didn't work either. sh ip route command shows that it can see all networks. I have configured dhcp pools for vlans 15 and 20.

I think I missed some information about vlans or something. Can somebody point me where the problem is?

Here is my topology:
Network Topology

Here are some of the configurations that I've used in my topology:

Switch0

en 
conf t
int fa 0/1
switchport access vlan 5
!
int fa 0/2
switchport access vlan 10
!
int gig 0/1
switchport mode trunk
!
int range fa 0/3 - 24
switchport access vlan 99
!
int gig 0/2 
switchport access vlan 99
!
end

Router

en
conf t
int gig 0/1
no shut
!
int gig 0/1.5
encapsulation dot1q 5 
ip address 195.165.85.62 255.255.255.224
!
int gig 0/1.10
encapsulation dot1q 10
ip address 195.165.85.94 255.255.255.224
!
exit
!
ip dhcp pool vlan5
network 195.165.85.32 255.255.255.224
default-router 195.165.85.62
!
ip dhcp pool vlan10
network 195.165.85.64 255.255.255.224
default-router 195.165.85.94
!
end

Router 1 'show-running config'

interface GigabitEthernet0/0
ip address 195.165.85.30 255.255.255.252
duplex auto
speed auto
!
interface GigabitEthernet0/1
no ip address
ip helper-address 195.165.85.29
duplex auto
speed auto
!
interface GigabitEthernet0/1.15
encapsulation dot1Q 15
ip address 195.165.85.126 255.255.255.224
!
interface GigabitEthernet0/1.20
encapsulation dot1Q 20
ip address 195.165.85.158 255.255.255.224
!

Best Answer

Configuring a DHCP relay on Cisco routers is pretty simple. You use the ip helper-address <DHCP server address> command on the layer-3 interface. The address for the helper address must be reachable from the router on which the helper address is configured, e.g. the Router0 interface toward Router1.

You are putting the helper address on the physical interface for which there are no VLANs. You need to put the helper address on the individual subinterfaces (each subinterface could use a different DHCP server).

Your DHCP server must have a scope for each of the networks for which it is the DHCP server.

By the way, never use a picture for text in your question. Just copy the text and paste it into your question, highlight the text, and use the Pre-formatted Text button: {}.

Edit:

Your Router0 needs scopes for VLANs 15 and 20:

ip dhcp pool vlan15
 network 195.165.85.96 255.255.255.224
 default-router 195.165.85.126

ip dhcp pool vlan20
 network 195.165.85.128 255.255.255.224
 default-router 195.165.85.158

Router1 needs helper addresses on the interfaces:

interface GigabitEthernet0/1.15
 encapsulation dot1Q 15
 ip address 195.165.85.126 255.255.255.224
 ip helper-address 195.165.85.29

interface GigabitEthernet0/1.20
 encapsulation dot1Q 20
 ip address 195.165.85.158 255.255.255.224
 ip helper-address 195.165.85.29

You also need to make sure that Router0 can ping the G0/1.15 and G0/1.20 interfaces in Router1.