Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to connect my to my wlan without the use of NetworkManager. I run the following commands after boot:

iwconfig wlan0 enc <WEP passwd> mode managed essid <name> channel 6
ifconfig wlan0 up
dhclient wlan0

At this point, dhclient stalls for ages (perhaps 2 minutes), then it returns with

PING ( from wlan0: 56(84) bytes of data.

--- ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3000ms
pipe 3

.. The strange thing is that when I run pkill dhclient; dhclient wlan0 right after this, it connects in about <3 seconds.

Any idea what could be the cause of this problem?

Edit: oh, and I did try using the -timeout flag on dhclient but that didn't seem to make any difference (it still stalled for ages).

share|improve this question
up vote 2 down vote accepted

That is an issue of obsolete dhclient that is still implemented in all Linux distributions. The dhclient script have to deal with Lease Timeout. When you access a wireless network, and run dhclient, it binds an IP address and Subnet mask, DNS server and some other options to your wireless interface (wlan0). The DHCP server leases that IP to your interface for a limited time (lease time). When you turn off the computer, or the dhclient script crashes by any reason, the client lease time counter stops. And then you boot up the computer, or run dhclient again. Then, dhclient finds a Prebind configuration, that refers to old lease, and it doesn't know if that lease still valid, or not. There comes the issue. The way that dhclient solve this problem is to binding interface with Prebind, and trying to ping the router (gateway). If ping success, the Prebind is valid and is applied to wireless interface (wlan0). Else, the Prebind isn't valid, and it discarded.

This explains the reason of the sleep ("dhclient stalls for ages"), it is waiting for a DHCP server response. And if it doesn't happens, after aprox 2 minutes, it tries assuming Prebind configuration and pings the old router ("PING").

I had the same issue in my Slackware, and found all information at dhclient-script man page.

(man dhclient-script):

TIMEOUT The DHCP client has been unable to contact any DHCP servers. However, an old lease has been identified, and its parameters have been passed in as with BOUND. The client configuration script should test these parameters and, if it has reason to believe they are valid, should exit with a value of zero. If not, it should exit with a nonzero value. The usual way to test a lease is to set up the network as with REBIND (since this may be called to test more than one lease) and then ping the first router defined in $routers. If a response is received, the lease must be valid for the network to which the interface is currently connected. It would be more complete to try to ping all of the routers listed in $new_routers, as well as those listed in $new_static_routes, but current scripts do not do this.

share|improve this answer

Make sure the NetworkManager service is not started at all if you are manually configuring your connection. I have experienced in the past that it tries to take over continuously reverting my configuration changes.

share|improve this answer

You must log in to answer this question.

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