1

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 ?

1 Answer 1

3

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.

0

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