cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1093
Views
10
Helpful
9
Replies

DHCP server in Cisco Router - how it works

SJ K
Level 5
Level 5

Hi all,

 

Just a simple question,  I am trying to use my router as a DHCP server and I am able to create many dhcp pools in the router.

In each pool I am able to define the network/mask for the IPs range that i wanted the DHCP to server.

 

However, I am thinking that, my router might be connected to many networks through its interfaces.

q1) how does the router know which dhcp pool to assign to incoming requests ? is it base on the interface's network that the requests are coming from ?

q2) if there is no dhcp pool created for a particular interface/network, what will happen ?

 

Regards,
Noob

2 Accepted Solutions

Accepted Solutions

Richard Burts
Hall of Fame
Hall of Fame

Noob

 

Both of these questions have fairly simple answers. 

q1) If a DHCP request from a client is received on the router interface then the router looks for a DHCP pool that matches the IP address of the interface on which the request was received.

q2) If a DHCP request from a client is received on the router interface and if there is no DHCP pool that matches the interface then the router will not supply an IP address to the client.

 

If there is another device on that network that is acting as a DHCP server, then the device would also receive a copy of the DHCP request from the client (since DHCP requests are sent as broadcasts) and the DHCP server could supply an IP address to the client.

 

HTH

 

Rick 

HTH

Rick

View solution in original post

Noob

 

In this case you are thinking too hard. It is really quite simple - when the router receives a frame and puts it into a buffer for processing it will mark from which interface the frame was received.

 

HTH

 

Rick

HTH

Rick

View solution in original post

9 Replies 9

Richard Burts
Hall of Fame
Hall of Fame

Noob

 

Both of these questions have fairly simple answers. 

q1) If a DHCP request from a client is received on the router interface then the router looks for a DHCP pool that matches the IP address of the interface on which the request was received.

q2) If a DHCP request from a client is received on the router interface and if there is no DHCP pool that matches the interface then the router will not supply an IP address to the client.

 

If there is another device on that network that is acting as a DHCP server, then the device would also receive a copy of the DHCP request from the client (since DHCP requests are sent as broadcasts) and the DHCP server could supply an IP address to the client.

 

HTH

 

Rick 

HTH

Rick

Duly noted. Rick

 

Thanks

Regards,

Noob

Hi Rick,

 

Suddenly while configuring dhcp server, a thought just flashes in my mind.

q1) If a DHCP request from a client is received on the router interface then the router looks for a DHCP pool that matches the IP address of the interface on which the request was received.

Of where in the DHCP DISCOVER frame, that the router/dhcp server know it receive this particular frame from which interface.

Via the SRC mac address of the DHCP cilent, then from the ARP table, see which interface is this MAC address learned on, then check the network of that interface ?

 

Am i thinking too much :/`

 

Regards,
Noob

Noob

 

In this case you are thinking too hard. It is really quite simple - when the router receives a frame and puts it into a buffer for processing it will mark from which interface the frame was received.

 

HTH

 

Rick

HTH

Rick

Hi Rick,

 

In that case, it is not using the frame itself to make a judgement on which dhcp pool to allocate ip, but rather on the interface that receive the frame - isn't it ?

 

In the case of a ip helper-address, it will base on the source ip in the packet then ?

 

p.s sorry for the slow reply on the native vlan thread, i discover something that i would like to share after more testing.

 

Thank you.

Noob

 

In the case of DHCP Discover frame sent as a local broadcast the router is just processing based on which interface received the request.

 

I am not clear about your question about ip helper-address. Are you talking about a router configured with helper address which receives a DHCP request and forwards it based on the configured helper address or are you asking about a router configured with a DHCP scope for a subnet that is not locally connected, that receives a DHCP request forwarded from some other router based on the helper address configured on the remote router? So let me try to answer the question this way.

If a router receives a DHCP request sent as a local broadcast and that router is configured with ip helper-address then the router will forward the DHCP request using the configured helper address and the router will put its interface address into a field of the request for Gateway Address. When the remote DHCP server (could be a real server configured with DHCP or could be a router configured with the appropriate DHCP scope) receives the request that was forwarded to it, then it will look in the request for the Gateway Address and will look for a scope that matches the Gateway Address and will assign an address from that scope. 

 

HTH

 

Rick

HTH

Rick

Hi Rick,

 

Yeap, actually i am asking about both. About a router configured with a ip helper-address receiving a dhcp request and forwarding out to the actual dhcp server (which happen to be a router too). 

 

So the DHCP server now cannot determine the ip pool to allocate base on the received frame's interface.

 

On my packet tracer, i saw that when a router configured with ip helper-address receive a dhcp request on its interface (e.g fa0/1), it will forward it out (e.g fa0/2) to the actual dhcp server (listed in the helper address) with its src ip set as the (fa0/1 's IP). So i thought that SRC IP (192,168.1.1) will be use by the DHCP server, to determine which ip pool to allocate.

Didn't have an actual device, so can't really see where is the Request for Gateway portion though (below is an outbound frame from the router to the dhcp server)

 

Regards,
Noob

Noob

 

I attempted to explain both parts in my previous response but let me add a little to it and I hope it will be helpful.

 

When a router is configured with helper address and receives a DHCP request it will forward the request to the address specified in the helper address. The router fills in some fields in the packet including a field that I frequently see referred to as the Gateway address. I believe that in the packet layout you are working from it is called the Relay Agent Address.

 

When the forwarded request is received at the server (which could be a router configured with the appropriate scope) the server processes the request. The server may examine several pieces of information about the request (which might include the interface received on, and the Relay Agent Address among other things). In this case the interface received on is not helpful in determining which scope to use. But the Relay Agent Address will identify which scope is to be used.

 

HTH

Rick

HTH

Rick

Hi Rick,

 

Sorry for the late reply.

 

Thanks for the explanation. I got it. Initially i thought the DHCP server was using the SRC ip address in the above case to identify the scope to be use and i believe in the Relay Agent Address will contain the same IP ;)

 

Regards,
Noob