14

I am trying to debug DHCP on my laptop (I am using dhcping and dhcdump to see what the DHCP server sends back). Following is my /etc/dhcp/dhclient.conf.

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

send host-name = gethostname();

request subnet-mask, broadcast-address, time-offset, routers,
domain-name-servers, interface-mtu,
rfc3442-classless-static-routes;

I think, I have an idea what all these options mean, except for rfc3442-classless-static-routes. Also, I don't see anything pertaining to rfc3442-classless-static-routes in the DHCP replies.

What is the meaning of rfc3442-classless-static-routes and in what situation would I make use of it?

(the documentation makes no sense whatsoever)

2 Answers 2

22

The original DHCP specification (RFC 2131 and 2132) defines an option (33) that allows the administrator of the DHCP service to issue static routes to the client if needed.

Unfortunately, that original design is flawed these days as it assumes classful network addresses, which is rarely used.

The rfc3442-classless-static-routes option allows you to use classless network addresses (or CIDR) instead.

CIDR requires a subnet mask to be explicitly stated, but the original DHCP option 33 doesn't have space for this. Therefore, this option (as defined in RFC 3442) simply enables an newer replacement DHCP option (option 121) which defines static routes using CIDR notation.

Basically, if you need to issue static routes to your devices using DHCP and these static routes use CIDR then you need to enable this option.

A static routes can be used if you have split a network into to multiple smaller networks and need to inform each routers about how traffic gets from one to another without using one of the many dynamic routing protocols available. You basically set up each router with a statement to the effect of "to get to network a.b.c.d, send traffic through f.g.h.i".

If the route you set up in the router are classful, then you do not need to enable this option. However, if the routes are CIDR then you will need to enable this option. Fortunately, many home/cafe network use the 192.168.0.0 network with a subnet of 255.255.255.0 (or /24), which is a true Class-C network, therefore you can avoid this option.

On the other hand, some home/cafe networks run on the 10.0.0.0 network. This is a Class-A network by default. If you are breaking this into many 10.0.x.0 sub-nets for example, then these will all be CIDR networks which means you will need to enable this option.

The above is only true if you also need to issue this routing information to your hosts via DHCP. Whether you need to issue these static routing information to your hosts is defined by the design of your network. I'd hazard a guess that a basic home/cafe network doesn't need it as static routes are usually defined at the routers.

The configuration you have above simply defines a new option (there are many predefined options that dhclient already understands) as option 121 which consists of an array of 8-bit unsigned integers. It then configures the client to request this option if it is set on the DHCP server.

If the DHCP server returns a value for this option a dhclient exit hook script (/etc/dhclient/dhclient-exit-hooks.d/rfc3442-classless-routes) reads the value and configures the routing table accordingly.

3
  • Typo: the "8 unsigned integers" should be "8-bit unsigned integers".
    – user242579
    Jun 19, 2021 at 12:47
  • @user242579 - well spotted ;-) Thank you. Jun 20, 2021 at 7:27
  • Thank YOU! your answer helped me fix an issue with the DHCP setup on my network that'd been bothering me for a while. It was mostly-working, but it turns out some hosts (that were having trouble) were following the RFC correctly.
    – user242579
    Jun 21, 2021 at 9:22
0

In dhclient.conf you can use it like this:

supersede rfc3442-classless-static-routes 25,1,2,3,0,192,168,240,1;

for adding route 1.2.3.0/25 via 192.168.240.1 .

rfc3442-classless-static-routes overrides routers, so you need to add default route if there is one, whith leading zero as a netmask.

In hook scripts you can use it like this:

if [ "$reason" = 'BOUND' ]; then
        new_routers_rfc=$( echo "$new_routers" | tr '.' ' ' )
#       new_rfc3442_classless_static_routes="16 192 168 192 168 240 1 8 10 192 168 240 1 0 192 168 241 120"
        new_rfc3442_classless_static_routes="16 192 168 $new_routers_rfc 8 10 $new_routers_rfc 0 192 168 241 120"
fi

for adding routes

default via 192.168.241.120
10.0.0.0/8 via 192.168.240.1
192.168.0.0/16 via 192.168.240.1

This script replaces default route and uses default route from dhcp to access local networks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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