1

Does anyone know if it is possible to add static routes with dhcp? I know that there is option 121 in dhcp but I read that it can set routing via some gateway IP, and I need to set routing via device. Manually I can do that in linux with:

ip route add xxx.xxx.xxx.xxx dev eth0

But I have no idea if it is possible (and how) with dhcp. I'm now using udhcpd.

2
  • 1
    You might want to explain why you want to do this or what problem you are trying to solve. A DHCP server setting a route to an exit interface sounds a bit weird... How would a DHCP server know anything about which interfaces exist on some client and what networks can be reached through them?
    – Gerben
    Commented May 7, 2014 at 20:47
  • I need it to set routing for network via gateway. I can't configure "normally" this network and it must be configured as /32. Ofcourse dhcp server can't know which interface is existing on client but it will be enought for me if every client will set routing via interface from which dhcp response comes.
    – Slawek
    Commented May 7, 2014 at 20:49

1 Answer 1

2

With DHCP for IPv4 this is possible. With DHCP for IPv6 not.

The option you are looking for is classless-routes specified in RFC3442.

Not sure if you can configure this option on udhcpd but I've seen and used it with ISC DHCP Server. The syntax for this option is a little strange and is described in the RFC.

Note: I think there are some problems with older Versions of Windows which will request another DHCP option.

2
  • 1
    Thanks a lot for help. I know this option (it is option 121 in rfc and for older windows is option 249 called in udhcpd msstaticroutes). Problem is that this option is on client side parsed with extra script (on Ubuntu it is /etc/dhcp/dhclient-exit-hooks.d/rfc3442-classless-routes) and this script can't set routing via device. I modify it on my ubuntu and now it is setting correct routing for me.
    – Slawek
    Commented May 8, 2014 at 20:35
  • "I've seen and used it with ISC DHCP Server. The syntax for this option is a little strange and is described in the RFC." - Can you provide an example of how to use it?
    – Bolong
    Commented May 8 at 7:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .