12

I have a DHCP server (Linux, IPCop, dnsmasq) running on my default gateway server 192.168.0.1. I have a VPN endpoint on another server in the network (192.168.0.4). Is it possible to configure the DHCP server so it sends not only the default gateway but also routing information for the VPN (192.168.1.*) to DHCP clients when they request an IP address? The DHCP clients run Windows and Linux.

I tried to find something in the official documentation (http://www.ipcop.org/2.0.0/en/admin/html/custom-dnsmasq-local.html) but failed. The existence of RFC3442 indicates that it might be possible somehow.

2

3 Answers 3

14

This can be done by adding the following lines to dhcpd.conf:

option rfc3442-classless-static-routes code 121 = array of integer 8;
option rfc3442-classless-static-routes 24, 192, 168, 1, 192, 168, 0, 4;
option ms-classless-static-routes code 249 = array of integer 8;
option ms-classless-static-routes 24, 192, 168, 1, 192, 168, 0, 4;

This distributes a route entry for network 192.168.1.0/24 using the gateway 192.168.0.4.

The meaning of the bytes is (in brackets the value from the example above):

WW, D1, D2, D3, R1, R2, R3, R4
WW      = destination network mask width (24)
D1..D3  = destination network address (192.168.1.*)
R1..R4  = router address (192.168.0.4)

Note: The number of D1..DN bytes varies depending on the network mask. See RFC3442 for details.

2
1

The syntax of the RFC 3442 option is a bit unusual. This is a representation of blerontin's answer in a more graphical way, which some might find easier to understand.

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

# Route                             to     192.168.1.0/24 through 192.168.0.4;
#                                       ┌───────────────┘
#                                       |   |   |  |   
option rfc3442-classless-static-routes 24, 192,168,1,             192,168,0,4;
option      ms-classless-static-routes 24, 192,168,1,             192,168,0,4;
0

If you want to define multiple static routes....

If you specify the option multiple times.. only 1 (probably the last) will apply.

Instead, just concatenate the entries.. eg

option rfc3442-classless-static-routes X, X,X,X,X, X,X,X,X;
option rfc3442-classless-static-routes Y, Y,Y,Y,Y, Y,Y,Y,Y;

but

option rfc3442-classless-static-routes X, X,X,X,X, X,X,X,X, Y, Y,Y,Y,Y, Y,Y,Y,Y;

You must log in to answer this question.

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