Feb 102013
 

So, I figured out why wlan0 doesn’t get an IP address when hostapd starts up.
ifplugd messes about with the interfaces when they go up and down, so the simplest solution is to disable ifplugd for wlan0 !
in /etc/default/ifplugd, the default configuration is this

INTERFACES="auto"
HOTPLUG_INTERFACES="all"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

Simply changing it to this

INTERFACES="eth0"
HOTPLUG_INTERFACES="eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"

will ensure that wlan0 will not lose it’s static IP address that’s configured in /etc/network/interfaces when wlan0 goes up.

Share

  55 Responses to “How To : Use The Raspberry Pi As A Wireless Access Point/Router Part 3…B!”

  1. You saved my day! I had exactly this issue on my Pi and now I am a happy camper! Thank you!

  2. Same problem here with the “vanishing” IP address if hostapd comes up. But I also don’t (and don’t think I need) /etc/default/ifplugd

    Are there other solutions?

  3. […] Help with hostapd and IP: http://sirlagz.net/2013/02/10/how-to-use-the-raspberry-pi-as-a-wireless-access-pointrouter-part-3b/ […]

  4. Very helpful, this also solved my problem, cheers mate!

  5. I have to say that to make Raspberry Pi to really work as AP I had to come a long way. I hope others will find this page faster. Every article how to make raspberry PI wifi AP (hostapd + isc-dhcp-server ) should have a link to this page

  6. God bless you!!! So many nerve cell killed on this stupid issue…

  7. Thank you for the solution to the final step in my journey towards RPI AP. Madman you may be but hopefully this wil stop me going the same way. 8)

  8. God bless you man 😀

    This joke has turned me crazy for almost a full day. The problem is that I did the same configuration (a RasPi in AP mode) nearly 6 months ago, without any problem, but using an Occidentalis distro at that time. It seems that updates brought by NOOBS Raspbian has broken something (kernel is not the same BTW).

    Peta-thanks to you for providing us this workaround.

  9. very helpful, thanks!

  10. Awesome, thanks for sharing =)

  11. Thank you SO MUCH for this. I wish I found this before I burned a whole day…

  12. Hi,

    can you tell me, how your /etc/network/interfaces looks?

    I configured this:
    GNU nano 2.2.6 Datei: /etc/network/interfaces

    auto lo
    iface lo inet loopback

    iface eth0 inet static
    address 192.168.178.123
    netmask 255.255.255.0
    gateway 192.168.178.1

    iface wlan0 inet static
    adress 192.168.2.1
    netmask 255.255.255.0

    but when the system is rebootet, there is no wlan0 up:
    ifconfig says:

    eth0 Link encap:Ethernet Hardware Adresse xx:xx:xx:xx:xx:xx
    inet Adresse:192.168.1.122 Bcast:192.168.1.255 Maske:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metrik:1
    RX packets:881 errors:0 dropped:0 overruns:0 frame:0
    TX packets:567 errors:0 dropped:0 overruns:0 carrier:0
    Kollisionen:0 Sendewarteschlangenlänge:1000
    RX bytes:89254 (87.1 KiB) TX bytes:147534 (144.0 KiB)

    lo Link encap:Lokale Schleife
    inet Adresse:127.0.0.1 Maske:255.0.0.0
    UP LOOPBACK RUNNING MTU:65536 Metrik:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    Kollisionen:0 Sendewarteschlangenlänge:0
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

    When I try sudo ifup wlan0 it says
    Missing required variable: address
    Missing required configuration variables for interface wlan0/inet.
    Failed to bring up wlan0.

    After I do sudo ifconfig wlan0 192.168.2.1 netmask 255.255.255.0
    The wlan0 is up.

    wlan0 Link encap:Ethernet Hardware Adresse xx:xx:xx:xx:xx:xx
    inet Adresse:192.168.2.1 Bcast:192.168.2.255 Maske:255.255.255.0
    UP BROADCAST MULTICAST MTU:1500 Metrik:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    Kollisionen:0 Sendewarteschlangenlänge:1000
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)

    After a reboot, I have set the IP again.

    What I doing wrong?
    sorry….

    Theo

  13. I habe a solution now,

    In /etc/rc.local addet
    sudo ifconfig wlan0 192.168.2.1 netmask 255.255.255.0

    now the network wlan0 is up after everry reboot.

  14. My goodness, thank you for this! ^^
    Was wondering what was happening w/ my Pi

  15. Perfect

  16. Great Tutorial really easy to follow! I have just started out with the Pi and found this book very interesting/helpful it details everything you need for starting out (not that you need it by the looks of things!) http://amzn.to/1zJaBnN

  17. you are the fucking master!!, thanks a lot!

  18. Ahhhhhhhhh! I can’t believe that finally did it. Days on & off wasted on this one.

    I had restorted to an ugly /etc/rc.local hack taking down my 2nd interface, killing it & restarting was the only way I could get wlan0 back up after hostapd started up on wlan1.

    I’m doing with this two wireless interfaces… and it’s working smoothly. Thanks a million!

    +1

    • Hi sanner,
      this is exactly what I am looking for.
      I am very new to Raspi and Linux.
      Could you tell me more about how you did this / what steps I have to take / what settings to modify to make it work with two wireless interfaces?
      Will clients be able to connect to wlan1 and work with the Raspi even if wlan0 is down / Interrnet connection lost in your setup?
      Thank you, Klaus

  19. Cheers buddy!!

  20. Thank you!!
    this is exactly what was happening to me. i think the hostapd was causing the wlan0 interface to bounce so it lost it IP and broke my DHCP service. took me an hour to spot it!
    thanks!

  21. Thank you very much for saving my sleepless nights.

    I went crazy when each time I connect to wlan1, wlan0 will drop.

    I will link to your site from my awesome website: http://www.linuxcircle.com

  22. […] with wlan0 no ip – see this page dnsmasq-dhcp[2297]: DHCP packet received on wlan0 which has no address in /etc/default/ifplugd, the […]

  23. […] found the answer just following the instructions on the last page of a sirlagz post. I did this and it […]

  24. I tried all the above and no success.
    It worked only if I add the line in the service daemon itself
    /etc/rc.local & /etc/default/ifplugd were not touched.


    case "$1" in
    start)
    test_config
    log_daemon_msg "Starting $DESC" "$NAME"
    ####################### added next line #################
    sudo ifconfig wlan0 10.0.1.1 netmask 255.255.255.0

    start-stop-daemon --start --quiet --pidfile "$DHCPD_PID" \
    --exec /usr/sbin/dhcpd -- \
    -q $OPTIONS -cf "$DHCPD_CONF" -pf "$DHCPD_PID" $INTERFACES

    • Perhaps things have changed since I’ve written the post.

      I’ll get another Raspberry Pi working as an AP and revisit this post 🙂

  25. OMG Thanks for this, wasted a day of my life before I found this solution! Hostapd now working

  26. Thanks so much for this!!

    I had a very odd problem where hostapd would work fine if my raspberry pi was booted with a hdmi monitor connected – but wouldn’t work if the hdmi wasn’t connected. This fix has solved it. I assume the hdmi monitor did something to the boot sequence which also fixed the problem.

  27. Forgive me if this isn’t the right place to make this post but I’m getting desperate. I’m trying to make my Raspberry Pi B+ running Raspian-Jessie into an 802.11ac access point using an Edimax EW-7811UAC adapter. Edimax tech support provided me with a pre-compiled binary and it seems to work fine when I’m using the Pi as a client on my home network.

    However, after following the procedure on another website to make my Pi an access point, I get to the point where my mobile client can see the access point and can report the speed of the connection but is unable to obtain an IP address. None of the solutions offered on the other website helped which is how I ended up here.

    The solution offered here involves editing the /etc/default/ifplugd file but my /etc/default directory has no file by that name. I suspect your using a different way of handling DHCP but I can’t seem to find Parts 1 & 2 of your procedure to try it out. Can anyone offer any suggestions on how to fix my problem or at least provide a link to your complete procedure?

  28. I don’t understand, I did sudo nano /etc/default/ifplugd and found that this file is empty on my own Raspberry2+…

    • What distribution are you using? Also, newer versions of Raspbian (which I used) may have changed.

      • I have the same problem with /etc/default/ifplugd. it doesn’t exist on the raspberry pi two. the raspian version that I use is for November 2016. can anyone upload the text file in /etc/default/ifplugd ??

  29. How would I do this with two WLAN interfaces instead of eth0 and wlan0?
    (Raspi 2B+ with 2 Edimax adapaters)
    wlan0 connects to a router for Internet access and clients connect to wlan1
    The clients should maintain connection to Raspi regardless of whether wlan0 is connected or not.

    I am very new to Raspi and Linux – obviously.
    sanner (post 24) figured it out but didn’t elaborate.

  30. when i run
    sudo service isc-dhcp-server start
    i get
    job for isc-dhcp-server start failed
    what to do to start the server..??

  31. I have the same problem with /etc/default/ifplugd. it doesn’t exist on the raspberry pi two. the raspian version that I use is for November 2016. can anyone upload the text file in /etc/default/ifplugd ??

    thanks,

  32. Hello, I followed this tutorial: https://learn.adafruit.com/setting-up-a-raspberry-pi-as-a-wifi-access-point/install-software however, how much do I try to run sudo service isc-dhcp -server start I get the following error: Job for isc-dhcp-server.service failed. See ‘systemctl status isc-dhcp-server.service’ and ‘journalctl -xn’ for details.

    sudo systemctl status isc-dhcp-server.service
    ● isc-dhcp-server.service – LSB: DHCP server
    Loaded: loaded (/etc/init.d/isc-dhcp-server)
    Active: failed (Result: exit-code) since Sat 2017-03-04 13:14:18 UTC; 5 days ago
    Process: 1329 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited, status=1/FAILURE)

    Mar 04 13:14:16 raspberrypi dhcpd[1338]: you want, please write a subnet dec…n
    Mar 04 13:14:16 raspberrypi dhcpd[1338]: in your dhcpd.conf file for the net…t
    Mar 04 13:14:16 raspberrypi dhcpd[1338]: to which interface wlan0 is attache…*
    Mar 04 13:14:16 raspberrypi dhcpd[1338]:
    Mar 04 13:14:16 raspberrypi dhcpd[1338]:
    Mar 04 13:14:18 raspberrypi isc-dhcp-server[1329]: Starting ISC DHCP server: …
    Mar 04 13:14:18 raspberrypi isc-dhcp-server[1329]: failed!
    Mar 04 13:14:18 raspberrypi systemd[1]: isc-dhcp-server.service: control pro…1
    Mar 04 13:14:18 raspberrypi systemd[1]: Failed to start LSB: DHCP server.
    Mar 04 13:14:18 raspberrypi systemd[1]: Unit isc-dhcp-server.service entered….
    Hint: Some lines were ellipsized, use -l to show in full.

    sudo journalctl -xn
    — Logs begin at Sat 2017-03-04 13:11:55 UTC, end at Thu 2017-03-09 17:32:25 UTC
    Mar 04 13:14:24 raspberrypi avahi-daemon[462]: Withdrawing address record for fe
    Mar 04 13:14:25 raspberrypi ntpd[590]: Listen normally on 10 eth0 2801:8c:7:ae20
    Mar 04 13:14:25 raspberrypi ntpd[590]: peers refreshed
    Mar 09 17:27:29 raspberrypi systemd[754]: Time has been changed
    — Subject: Time change
    — Defined-By: systemd
    — Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

    — The system clock has been changed to REALTIME microseconds after January 1st,
    Mar 09 17:27:29 raspberrypi systemd[1]: Time has been changed
    — Subject: Time change
    — Defined-By: systemd
    — Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel

    — The system clock has been changed to REALTIME microseconds after January 1st,
    Mar 09 17:30:07 raspberrypi sudo[1708]: pi : TTY=pts/0 ; PWD=/ ; USER=root ; COM
    Mar 09 17:30:07 raspberrypi sudo[1708]: pam_unix(sudo:session): session opened f
    Mar 09 17:30:07 raspberrypi sudo[1708]: pam_unix(sudo:session): session closed f
    Mar 09 17:32:25 raspberrypi sudo[1786]: pi : TTY=pts/0 ; PWD=/ ; USER=root ; COM
    Mar 09 17:32:25 raspberrypi sudo[1786]: pam_unix(sudo:session): session opened f
    lines 1-21/21 (END)

    Can someone help me?
    Thanks

    • etc/network/interfaces :

      source-directory /etc/network/interfaces.d

      auto lo
      iface lo inet loopback

      #iface eth0 inet dhcp
      auto eth0
      allow-hotplug eth0
      iface eth0 inet manual

      allow-hostplug wlan0
      iface wlan0 inet static
      address 192.168.42.1
      netmask 255.255.255.0

      #allow-hotplug wlan0
      #iface wlan0 inet manual
      # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

      #allow-hotplug wlan1
      #iface wlan1 inet manual
      # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

      etc/dhcp/dhcpd.conf:

      default-lease-time 600;
      max-lease-time 7200;
      authoritative;

      subnet 192.168.42.0 netmask 255.255.255.0 {
      range 192.168.42.10 192.168.42.50;
      option broadcast-address 192.168.42.255;
      option routers 192.168.42.1;
      default-lease-time 600;
      max-lease-time 7200;
      option domain-name “local”;
      option domain-name-servers 8.8.8.8, 8.8.4.4;
      }

      etc/hostapd/hostapd.conf:

      # This is the name of the WiFi interface we configured above
      interface=wlan0

      # Use the nl80211 driver with the brcmfmac driver
      driver=nl80211

      # This is the name of the network
      ssid=RASPBERRY

      # Use the 2.4GHz band
      hw_mode=g

      # Use channel 6
      channel=6

      # Enable 802.11n
      ieee80211n=1

      # Enable WMM
      wmm_enabled=1

      # Enable 40MHz channels with 20ns guard interval
      ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]

      # Accept all MAC addresses
      macaddr_acl=0

      # Use WPA authentication
      auth_algs=1

      # Require clients to know the network name
      ignore_broadcast_ssid=0

      # Use WPA2
      wpa=2

      # Use a pre-shared key
      wpa_key_mgmt=WPA-PSK

      # The network passphrase
      wpa_passphrase=raspberry

      # Use AES, instead of TKIP
      rsn_pairwise=CCMP

    • You’ll need to paste the proper log with journalctl -xnl to see why isc-dhcp-server isn’t starting.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

This site uses Akismet to reduce spam. Learn how your comment data is processed.