classless static routes

Hi,

I have setup my DHCP server to hand out static routes by adding the following lines into my dhcpd.conf:

option rfc3442-classless-static-routes code 121 = array of integer 8;
option ms-classless-static-routes code 249 = array of integer 8;
option rfc3442-classless-static-routes 23, 10, 6, 0, 10, 5, 5, 10;
option ms-classless-static-routes 23, 10, 6, 0, 10, 5, 5, 10;

I have a mixed environment with OpenSUSE and Debian being the main distro’s being used. For Debian and others this static routing by DHCP works perfectly. With OpenSUSE it adds the route required but does not even try to add the default route anymore, if I hash out the above lines from dhcpd.conf then retry it adds the default route fine. Here are the log entries from when it’s adding the route:

Nov 8 16:49:46 ayima19 dhcpcd[4437]: eth0: leased 10.5.5.19 for 600 seconds
Nov 8 16:49:46 ayima19 dhcpcd[4437]: eth0: adding IP address 10.5.5.19/24
Nov 8 16:49:46 ayima19 dhcpcd[4437]: eth0: adding route to 10.6.0.0/23 via 10.5.5.10 metric 0

Notice that there is no attempt to add the default route. I’m sure this must be easy to fix as it works fine with most other distro’s, I just need to know where to look, tried googling but couldn’t find anything useful.

BTW I was using openSUSE 11.2 (x86_64) to test this.

Any help would be much appreciated. :slight_smile:

Thanks,

Charlie

On 11/08/2010 11:36 AM, charlieclark wrote:
>
> Hi,
>
> I have setup my DHCP server to hand out static routes by adding the
> following lines into my dhcpd.conf:
>
> option rfc3442-classless-static-routes code 121 = array of integer 8;
> option ms-classless-static-routes code 249 = array of integer 8;
> option rfc3442-classless-static-routes 23, 10, 6, 0, 10, 5, 5, 10;
> option ms-classless-static-routes 23, 10, 6, 0, 10, 5, 5, 10;
>
> I have a mixed environment with OpenSUSE and Debian being the main
> distro’s being used. For Debian and others this static routing by DHCP
> works perfectly. With OpenSUSE it adds the route required but does not
> even try to add the default route anymore, if I hash out the above lines
> from dhcpd.conf then retry it adds the default route fine. Here are the
> log entries from when it’s adding the route:
>
> Nov 8 16:49:46 ayima19 dhcpcd[4437]: eth0: leased 10.5.5.19 for 600
> seconds
> Nov 8 16:49:46 ayima19 dhcpcd[4437]: eth0: adding IP address
> 10.5.5.19/24
> Nov 8 16:49:46 ayima19 dhcpcd[4437]: eth0: adding route to 10.6.0.0/23
> via 10.5.5.10 metric 0
>
> Notice that there is no attempt to add the default route. I’m sure this
> must be easy to fix as it works fine with most other distro’s, I just
> need to know where to look, tried googling but couldn’t find anything
> useful.
>
> BTW I was using openSUSE 11.2 (x86_64) to test this.
>
> Any help would be much appreciated. :slight_smile:

This level of DHCP is way beyond me, but I would determine what client and
version that are being used by the other distros, download, and build that one
for openSUSE. I do not know what changes there are between 11.2 and 11.3, or if
this problem would be solved by an upgrade.

You might want to look at the DHCP config files generated by YaST. IIRC YaST does things a certain way and cannot cater for complex use cases so you might want to take control and edit dhcpd.conf yourself.

Thanks for you’re replies.
I got it working, I am going to outline how to get it working below for anyone who wants to do that same thing, by the way, I am doing this on openSUSE 11.2 (x86_64) but can’t imagine it would be any different on any recent openSUSE version:

  • Firstly you will need to install dhclient by installing the package dhcp-client, you might be able to get it to work with the native dhcpcd but I couldn’t figure it out.
  • Now you need to make openSUSE use dhclient by default instead of dhcpcd by editing /etc/sysconfig/network/dhcp and changing the line:
    DHCLIENT_BIN=""
    to
    DHCLIENT_BIN="/sbin/dhclient"
  • You will need to change /etc/dhclient.conf, it might be best to delete the original and replace with the following:
    option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

send host-name “<hostname>”;

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

  • Lastly you need an exit hook to run by creating/editing /etc/dhclient-exit-hooks (If it already exists then just append the following to the end):
    if [ “$new_rfc3442_classless_static_routes” != “” ]; then
    if [ “$reason” = “BOUND” ] || [ “$reason” = “REBOOT” ]; then
    rfc_routes=($new_rfc3442_classless_static_routes)

                      for(( i=0; i &lt; ${#rfc_routes[@]}; )); do
                              net_length=${rfc_routes[$i]}
    
                              ((i++))
    
                              net_address=(0 0 0 0)
                              for(( j=0; j &lt; $[$net_length / 8 + \
                                  ($net_length % 8 ? 1 : 0)]; j++, i++)); do
    
                                      net_address[$j]=${rfc_routes[$i]}
                              done
    
                              gateway=(0 0 0 0)
                              for (( j=0; j &lt; 4; j++, i++ )); do
                                      gateway[$j]=${rfc_routes[$i]}
                              done
    
                              old_IFS="$IFS"
                              IFS='.'
                              if [ "$net_length" == "32" ]; then
                                      /sbin/route add -host "${net_address[li]}" gw "${gateway[*]}"[/li]                                else
                                      /sbin/route add -net "${net_address[li]}/$net_length" gw "${gateway[*]}"[/li]                                fi
                              IFS="$old_IFS"
    
                      done
              fi
    

fi

  • And that’s it, you should now be able to push static routes using methods outlined in rfc3442 from your DHCP server to the openSUSE machine without loosing your default route.

Regards,

Charlie