I have (among other network devices) a RPi

Linux rpi2 4.1.10+ #821 PREEMPT Sat Oct 10 00:12:23 BST 2015 armv6l GNU/Linux

It is connected via WiFi to an access point (like the other devices). A static network configuration works (connection to the AP and TCP/IP traffic).

I now wanted to move it to DHCP by modifying in /etc/network/interfaces the wlan0 stanza from

auto wlan0
iface wlan0 inet static
        wpa-essid "MYSSID"
        wpa-psk "mypassword"


auto wlan0
iface wlan0 inet dhcp
        wpa-essid "MYSSID"
        wpa-psk "mypassword"

The interface connects to the AP (which is visible though iwconfig) but does not get any IP.

  • No request is visible on the server (which runs dnsmasq so I can se all the logs - which include the ones from other devices).
  • other devices on the same AP get addresses without problems
  • a tcpdump does not show any DHCP requests

What could block the RPi to request an IP address?

Answer (summarizing the answer to the question and my further comments): the lack of a client (which I must have removed when reconfiguring the device many times). Installing isc-dhcp-client fixed the issue.

  • You made a comment in response to my comment on the Answer. Yes the 1st will work. Static address will be allocated, but dhcpcd will still run, and allocate IP address from the DHCP server, the result being indeterminate. The second will not run dhcpcd (it will in fact but on detecting DHCP will disable itself as you would see from the logs). Neither is the recommended was of starting a WiFi network. – Milliways Mar 22 '16 at 3:47
  • I am not sure I understand "dhcpcd will still run, and allocate IP address from the DHCP server" -- to which interface? If an interface is declared as static it will not have a DHCP client run against it (whether this is dhcpcd or dhclient). As for the second - it does run the DHCP client as I am getting IP addresses from my DHCP server (as soon as I installed the client which was, as I mentioned, missing). maybe it would be worthwhile to make an answer with the correct way to configure wifi - I would be glad to switch to the right one. – WoJ Mar 22 '16 at 7:19
  • 1
    I gather from your posts that your Raspbian has been "hacked" so it is difficult to know exactly what it has. See my tutorial How do I set up networking/WiFi/Static IP. To attempt to answer setting static in /etc/network/interfaces doesn't work in current Raspbian - the Foundation even includes a comment in the latest versions of the file. dhcpcd allocates IP addresses for ALL interfaces it can find. – Milliways Mar 22 '16 at 7:32
  • @Milliways: this is a very interesting link, thank you. And yet another approach to WiFi configuration (a well articulated on). Beside the man pages, is there a Debian/Ubuntu official doc pointing to this approach? – WoJ Mar 22 '16 at 8:38
  • This is a Raspbian initiative not mainstream Debian/Ubuntu although it is used by many other distributions. The tutorial includes the links I found useful (ArchLinux particularly) as a result of a lot of research. – Milliways Mar 22 '16 at 8:51

you need to execute /sbin/dhclient wlan0 after connecting in post-up or up script in /etc/network/interfaces and you better allow hotplug for wlan0

  • While it was not the exact reason, your answer pointed me to the right direction. I discovered that there was no dhcp client installed at all. Installing it fixed the issue without any changes. Thanks. – WoJ Mar 19 '16 at 21:39
  • @WoJ you're welcome! But one thing is concerning me - as I downloaded Raspbian Jessie from an official sources and installed it, dhclient was on board out-of-the-box... – Alexey Vesnin Mar 19 '16 at 21:40
  • Yes, you are right, this is the case for fresh installs. In the case of this particular RPi there is a long story of hacking around and it was on a static address before. I must have removed the dhcp client at some point. Another install on another RPi yesterday indeed had the client by default. – WoJ Mar 19 '16 at 21:43
  • 1
    This is a collection of misinformation. All recent Raspbian run dhcpcd by default which (among other things0 acts as a DHCP client), although if you disable it dhcpd should work. Neither of the configurations in the question would work (for different reasons). – Milliways Mar 20 '16 at 8:34
  • @Milliways don't mess up a client(dhclient) and a server(dhcpd) – Alexey Vesnin Mar 20 '16 at 10:35

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.