Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a dedi with an IP range of, the problem is the gateway address: and it's on completely different subnet. I have already setup a bridge and KVM virtualization.

/etc/dhcpd.conf on host node.

subnet netmask {
default-lease-time 21600000;
max-lease-time 432000000;
 ddns-update-style ad-hoc;

host kvm111.0 {
hardware ethernet 02:00:00:ce:fd:ab;
option routers;
option subnet-mask;
option domain-name-servers,;

Then I setup a KVM virtual machine (VM) on that HWID, with Windows OS and dhcp on. It's working good. The Windows VM got IP with the gateway in

But when I change the OS of VM to Debian 6, it doesn't work. I login to VM and found that the gateway is not assigned. When I type route add default gw the answer is:

SIOADDCART: no such process

That's because the gateway is in different subnet than the assigned IP address. So I had to do this on the VM:

route add dev eth0

route add default gw

and then it will work. But since I want an automation via the host node (not doing it manually via VM), I had to do it via /etc/dhcpd.conf

Does anyone know how to do route add dev eth0 via /etc/dhcpd.conf ?

share|improve this question

closed as unclear what you're asking by Ward, mdpc, dawud, RolandoMySQLDBA, Tim Brigham Sep 10 '13 at 11:37

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

up vote 1 down vote accepted

The answer is Classless Static Routes (RFC3442). In the isc dhcp server, you have to specify the option manually.

This website states concisely how to do it in a way that works for both windows and linux clients.

Here's the abbreviated version:

Add the following to dhcpd.conf at the top

option rfc3442-classless-static-routes code 121 = array of integer 8;
option ms-classless-static-routes code 249 = array of integer 8;

In the appropriate subnet block add the following two option lines

option rfc3442-classless-static-routes 32, 111, 111, 111, 254, 0, 0, 0, 0, 111, 111, 111, 254;
option ms-classless-static-routes 32, 111, 111, 111, 254, 0, 0, 0, 0, 111, 111, 111, 254;

That should create a static route for on-link with the dhcp assigned address and keep the default router of The special router value means on-link. The rfc states that clients are not required to implement classless static routes, but windows does via their ms option, linux's dhclient (tested debian7, rhel6.4) does and all my IPMI and PXE clients happen to as well. You should test to make sure it works with your clients, but I'm fairly confident it will work. dhclient can be made to interpret option 121 with an exit hook, if it doesn't already support it out of the box.

Worst case, on the host node, you can add an IP that is in the lan range (in your example, and tell the clients to use that as the default gateway.

share|improve this answer
Thanks for answer. This is what I looking for. –  lakscm Sep 27 '13 at 17:49

Not the answer you're looking for? Browse other questions tagged or ask your own question.