ifup - dhcp does not set default gateway

I have a problem when I start my wlan0 interface with ifup. I configured it to use dhcp. Ifup sets an IP, netmaks, etc. but no default gateway.

linux-ssouffri:/home/ssouffri # ifup wlan0
    wlan0     device: Intel Corporation PRO/Wireless 4965 AG or AGN Network Connection (rev 61)
    wlan0     warning: WPA configured but may be unsupported
    wlan0     warning: by this device
    wlan0     starting wpa_supplicant
WEXT auth param 4 value 0x0 - ioctl[SIOCSIWAUTH]: Operation not supported
Starting DHCP Client Daemon on wlan0... . . . . . IP/Netmask: '192.168.0.4' / '255.255.255.0'
linux-ssouffri:/home/ssouffri # route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     *               255.255.255.0   U     0      0        0 wlan0
link-local      *               255.255.0.0     U     0      0        0 wlan0
loopback        *               255.0.0.0       U     0      0        0 lo

However, when i run dhclient it does set one and the connection is set up perfectly.

linux-ssouffri:/home/ssouffri # dhclient
Internet Systems Consortium DHCP Client V3.0.6
Copyright 2004-2007 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

wmaster0: unknown hardware address type 801
wmaster0: unknown hardware address type 801
Listening on LPF/wmaster0/
Sending on   LPF/wmaster0/
Listening on LPF/eth0/00:1b:24:5f:d5:7f
Sending on   LPF/eth0/00:1b:24:5f:d5:7f
Listening on LPF/wlan0/00:13:e8:42:00:83
Sending on   LPF/wlan0/00:13:e8:42:00:83
Sending on   Socket/fallback
DHCPDISCOVER on wmaster0 to 255.255.255.255 port 67 interval 3
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.1
bound to 192.168.0.4 -- renewal in 1697 seconds.
linux-ssouffri:/home/ssouffri # route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.0.0     *               255.255.255.0   U     0      0        0 wlan0
loopback        *               255.0.0.0       U     0      0        0 lo
default         stijn           0.0.0.0         UG    0      0        0 wlan0

Any suggestions? Running dhclient everytime on boot is kind of annoying.

Here is my ifcfg-wlan0 config file.

linux-ssouffri:/home/ssouffri # cat /etc/sysconfig/network/ifcfg-wlan0
BOOTPROTO='dhcp'
BROADCAST=''
ETHTOOL_OPTIONS=''
IPADDR=''
MTU=''
NAME='PRO/Wireless 4965 AG or AGN Network Connection'
NETMASK=''
NETWORK=''
REMOTE_IPADDR=''
STARTMODE='auto'
USERCONTROL='yes'
WIRELESS_AP=''
WIRELESS_AUTH_MODE='psk'
WIRELESS_BITRATE='auto'
WIRELESS_CA_CERT=''
WIRELESS_CHANNEL=''
WIRELESS_CLIENT_CERT=''
WIRELESS_CLIENT_KEY=''
WIRELESS_CLIENT_KEY_PASSWORD=''
WIRELESS_DEFAULT_KEY='0'
WIRELESS_EAP_AUTH=''
WIRELESS_EAP_MODE=''
WIRELESS_ESSID='DI-624+'
WIRELESS_FREQUENCY=''
WIRELESS_KEY=''
WIRELESS_KEY_0=''
WIRELESS_KEY_1=''
WIRELESS_KEY_2=''
WIRELESS_KEY_3=''
WIRELESS_KEY_LENGTH='128'
WIRELESS_MODE='Managed'
WIRELESS_NICK=''
WIRELESS_NWID=''
WIRELESS_PEAP_VERSION=''
WIRELESS_POWER='yes'
WIRELESS_WPA_ANONID=''
WIRELESS_WPA_IDENTITY=''
WIRELESS_WPA_PASSWORD=''
WIRELESS_WPA_PSK='*************'

I have a similar problem with the default gateway.

Immediately after booting I get

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.182.0   *               255.255.255.0   U     0      0        0 wlan0
192.168.200.0   *               255.255.255.0   U     0      0        0 eth0 
link-local      *               255.255.0.0     U     0      0        0 eth0 
loopback        *               255.0.0.0       U     0      0        0 lo   
default         fritz.fonwlan.b 0.0.0.0         UG    0      0        0 eth0 

I do not understand the last line. fritz.fonwlan.b is my WLAN router, but why is the interface eth0?

Then I have to do a weird combination of route/ifup/ifdown to get my WLAN working. In contrast to the original posting, dhclient does not set the default gateway:


# dhclient                                                          
...]
bound to 192.168.182.25 -- renewal in 1707 seconds.

# route                                
Kernel IP routing table                         
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.182.0   *               255.255.255.0   U     0      0        0 wlan0
loopback        *               255.0.0.0       U     0      0        0 lo   


# route add default gw wlan0                                     

wlan0: Unknown host                                                       

# route add default wlan0                                     

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.182.0   *               255.255.255.0   U     0      0        0 wlan0
loopback        *               255.0.0.0       U     0      0        0 lo   
default         *               0.0.0.0         U     0      0        0 wlan0

# route add default gw wlan0

^C
(I had to press CTRL-C here)

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.182.0   *               255.255.255.0   U     0      0        0 wlan0
loopback        *               255.0.0.0       U     0      0        0 lo
default         *               0.0.0.0         U     0      0        0 wlan0

# ifdown wlan0
    wlan0     device: RaLink RT2500 802.11g Cardbus/mini-PCI (rev 01)

# ifup wlan0
    wlan0     device: RaLink RT2500 802.11g Cardbus/mini-PCI (rev 01)
    wlan0     starting wpa_supplicant
Starting DHCP4 client on wlan0. .
    wlan0     IP address: 192.168.182.22/24

# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.182.0   *               255.255.255.0   U     0      0        0 wlan0
link-local      *               255.255.0.0     U     0      0        0 wlan0
loopback        *               255.0.0.0       U     0      0        0 lo
default         fritz.fonwlan.b 0.0.0.0         UG    0      0        0 wlan0

Only after this series of commands, I can ping any host beyond my router.

I think I found a thread dealing with the same problem here. (I’ve copied the key reply just in case the link would break.) Sadly, the thread implies that it is a dhcp-server issue that can only be fixed at the server side.

------- Comment #7 From Roy Marples (RETIRED) 2007-04-18 19:56:55 0000 [reply] -------

You’ve set Classless Static Routes on the DHCP server.
This overrides any static routes and routers provided. You need to include
your default route in your CSR option.

See RFC3442 - DHCP Client Behaviour

If the DHCP server returns both a Classless Static Routes option and
a Router option, the DHCP client MUST ignore the Router option.

Similarly, if the DHCP server returns both a Classless Static Routes
option and a Static Routes option, the DHCP client MUST ignore the
Static Routes option