0

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
        address 10.10.10.5
        netmask 255.255.255.0
        gateway 10.10.10.254
        wpa-essid "MYSSID"
        wpa-psk "mypassword"

to

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.

WoJ
  • 515
  • 2
  • 6
  • 15
  • 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 03: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 07: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](http://raspberrypi.stackexchange.com/a/37921/8697). 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 07: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 08: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 08:51

1 Answers1

1

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

Alexey Vesnin
  • 926
  • 9
  • 16
  • 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 08:34
  • @Milliways don't mess up a client(`dhclient`) and a server(`dhcpd`) – Alexey Vesnin Mar 20 '16 at 10:35
  • @Milliways: and yet, they do. The static one was working without problems (no DHCP involved) and the second one started when I re-installed the DHCP client. Where is the misinformation? – WoJ Mar 21 '16 at 12:38