Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

/etc/dhcpd.conf on host node.

subnet 0.0.0.0 netmask 0.0.0.0 {
authoritative;
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 111.111.111.254;
option subnet-mask 255.255.255.0;
fixed-address 123.123.123.2;
option domain-name-servers 8.8.8.8,8.8.4.4;
}

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 123.123.123.2 IP with the gateway in 111.111.111.254.

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 111.111.111.254 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 111.111.111.254/32 dev eth0

route add default gw 111.111.111.254

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 111.111.111.254/32 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.

add comment

1 Answer

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 111.111.111.254 on-link with the dhcp assigned address and keep the default router of 111.111.111.254. The special router value 0.0.0.0 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, 123.123.123.254) 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
add comment

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