dhcp fails for gateway on different subnet - SIOCADDRT: Network is unreachable

Bug #139217 reported by raboof
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dhcp3 (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

I'm having an issue connecting to my university's WLAN on Feisty. The gateway address and the IP address I receive from the DHCP server are on different subnets and /sbin/dhclient-script is not handling it properly (route add default dev $interface gw $router $metric_arg fails with SIOCADDRT: Network is unreachable). The script should detect this case and add add a route to the gateway before attempting to set the default route.

Here are the relevant variables from /tmp/dhclient-script.debug:

Tue Sep 11 14:09:04 CST 2007: entering dhclient-enter-hooks.d, dumping variables.
reason='REBOOT'
interface='ath0'
medium=''
alias_ip_address=''
new_ip_address='172.18.225.46'
new_subnet_mask='255.255.255.128'
new_domain_name='usask.ca'
new_domain_name_servers='128.233.3.1 128.233.150.126 128.233.119.73'
new_routers='128.233.185.62'
new_static_routes=''
old_ip_address=''
old_subnet_mask=''
old_domain_name=''
old_domain_name_servers=''
old_routers=''
old_static_routes=''

Sorry if my terminology is incorrect. I'm no networking guru.

Thanks.

Revision history for this message
palceksmuk (palceksmuk) wrote :

Ive got the same problem but I don't know how to solve it.
Would you mind writing the commands to manually enter the gateway on a different subnet, because I can't get it working?

Revision history for this message
Paul Donohue (s-launchpad-paulsd-com) wrote :

This bug is either invalid or has been fixed.
/sbin/dhclient-script in Intrepid does the following starting at line 194:
            ifconfig $interface inet $new_ip_address $new_subnet_arg \
                $new_broadcast_arg $mtu_arg

            # point to point
            if [ "$new_subnet_mask" == "255.255.255.255" ]; then
                for router in $new_routers; do
                    route add -host $router dev $interface
                done
            fi

            for router in $new_routers; do
                route add default dev $interface gw $router $metric_arg
            done

Revision history for this message
Rodney Berriman (rodney-optimail) wrote :

It still doesn't seem to work on Optus ADSL (Australia), and I think the reason is that the creation of the host route is conditional on the netmask:

/sbin/dhclient-script:198:
   if [ "$new_subnet_mask" == "255.255.255.255" ]; then ...

because the interface is given an IP address with subnet 255.255.255.0, and a gateway address that
is not in this range.

Why not just remove the conditional line?
No harm in (trying to) creating a host route to the gateway, even if it is redundant?

Revision history for this message
Rodney Berriman (rodney-optimail) wrote :

reading the first post more carefully, I see that the netmask conditional is also the problem in the original report:

  new_subnet_mask='255.255.255.128'

therefore the host route to the gateway is not added because the netmask is not 255.255.255.0

While waiting for this bug report to be addressed, a suggested solution is to add a dhclient exit-hook:

create a file "gateway" in /etc/dhcp3/dhclient-exit-hooks.d, containing this text:

for router in $new_routers; do
  route add -host $router dev $interface
  route add default dev $interface gw $router $metric_arg
done

Revision history for this message
xteejx (xteejx) wrote :

Thank you for taking the time to report this bug and helping to make Ubuntu better. You reported this bug a while ago and there hasn't been any activity in it recently. We were wondering if this is still an issue for you. Can you try with the latest Ubuntu release? Thanks in advance.

Changed in dhcp3 (Ubuntu):
status: New → Incomplete
Revision history for this message
Aaron Kurtz (a.kurtz) wrote :

Teej, this is definitely still a problem in Jaunty, as /sbin/dhclient-script has not changed

DHCPREQUEST of 71.130.218.22 on eth0 to 255.255.255.255 port 67
DHCPACK of 71.130.218.22 from 192.168.1.254
SIOCADDRT: No such process
bound to 71.130.218.22 -- renewal in 78774 seconds.

from /tmp/dhclient-script.debug:

Sat May 30 21:53:02 PDT 2009: entering dhclient-enter-hooks.d, dumping variables.
reason='REBOOT'
interface='eth0'
medium=''
alias_ip_address=''
new_ip_address='71.130.218.22'
new_subnet_mask='255.255.0.0'
new_domain_name=''
new_domain_search='hardsun.net.'
new_domain_name_servers='127.0.0.1'
new_routers='151.164.187.111'
new_static_routes=''

root@roseroar:~# route add default dev eth0 gw 151.164.187.111
SIOCADDRT: No such process

If I remove the if,fi for

            if [ "$new_subnet_mask" == "255.255.255.255" ]; then
                for router in $new_routers; do
                    route add -host $router dev $interface
                done
            fi

then I can connect properly.

Changed in dhcp3 (Ubuntu):
status: Incomplete → Confirmed
Revision history for this message
raboof (raboof) wrote : Re: [Bug 139217] Re: dhcp fails for gateway on different subnet

Haven;t have any problems recently. Thanks.

On Sat, 2009-05-30 at 16:56 +0000, Teej wrote:
> Thank you for taking the time to report this bug and helping to make
> Ubuntu better. You reported this bug a while ago and there hasn't been
> any activity in it recently. We were wondering if this is still an issue
> for you. Can you try with the latest Ubuntu release? Thanks in advance.
>
> ** Changed in: dhcp3 (Ubuntu)
> Status: New => Incomplete
>

xteejx (xteejx)
summary: - dhcp fails for gateway on different subnet
+ dhcp fails for gateway on different subnet - SIOCADDRT: Network is
+ unreachable
Revision history for this message
xteejx (xteejx) wrote :

Thank you raboof for updating us. I shall mark this as Fix Released as you stated that it works after (I assume) an update.
Aaron, I do not believe that this is the same problem, therefore you will need to open a new report, although if I am wrong I apologise. Feel free to reopen this bug if it is still an issue by changing the status back to "New".

Changed in dhcp3 (Ubuntu):
status: Confirmed → Fix Released
Revision history for this message
descary (descary) wrote :

I got the same problem with Ubuntu 9.10 server, trying to connect to DHCP through a Proxy.
I resolve it with Rodney's work around.: editing the file /sbin/dhclient-script

for router in $new_routers; do
  route add -host $router dev $interface
  route add default dev $interface gw $router $metric_arg
done

I did not create 'gateway' file as suggest.

Thank.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.