Can dedicated DHCP server assign a default gateway address to router

dhcp

I have built a very simple LAN in Packet Tracer: a PC, a dedicated DHCP server, a switch and a router.

http://i.stack.imgur.com/Zvx3X.jpg – here is this LAN

The router is meant to be a default gateway in the LAN, and all I want is that the DHCP server would always assign a default gateway address, that it sends to all devices in the LAN, to the router. Router FastEthernet port is configured to get an address from the DHCP server too, using:

Router(config-if)#ip address dhcp

Is it possible to do so, and if yes, how? If no, why? Thank you!

Best Answer

You don't say what DHCP server code you're running, but it's definitely something allowed for in the DHCP spec. In ISC's dhcpd, you'd use the routers option, perhaps as follows:

subnet 192.168.3.0 netmask 255.255.255.0 {
 range 192.168.3.101 192.168.3.200 ;
 option routers 192.168.3.1 ;
 [...]
}

which will set the default route for all the clients to 192.168.3.1.

Since your router also gets its address via DHCP, you'll need to set up a special lease for the router's MAC address, so that it always gets the 192.168.3.1 address (to match that set in the routers option above), and so that it doesn't get fed its own address as a default route.

Related Topic