1

i have a problem with Access Point setup on Pi Zero W. I need just straightforward AP with no Internet connection. I used latest raspbian stretch lite image and followed docs:

https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md

Sadly, the network is just not visible. No errors along the way. I tried multiple other setups that i found on the Internet, but they are all the same. What can I try to debug this issue? Only way that somewhat works (RPi boots slowly but it sets up wifi) is described here:

https://www.raspberrypi.org/forums/viewtopic.php?t=196263#p1227552

Please help me, i have no idea what can be wrong, it seems like a simple feature :/

  • I'm interested in getting this working also. I've read other comments about the first document you referenced, and frankly, some of it just doesn't make sense to me. I don't know why (for example) that it needs to run dhcpd or dnsmasq, and I wonder if it's misleading - or just incorrect. Anyway, let's take some comfort in the fact we're not "breaking new ground" - this has been done on other platforms many many times, so it's just a matter of finding the correct buttons to push. Nothing else for now, just wanted you to know others are following this & will post if we learn anything. – Seamus Apr 10 '18 at 21:44
  • dhcpcd or dnsmasq is not needed to bring up the AP but it is needed when cllients try to connect to it. It's how the clients get their IP address. – John Hawthorne Apr 10 '18 at 21:49
  • Yes, my point exactly... so if I applied fixed IP addresses to both peers, then I could do without dhcpd and dnsmasq - is that correct? – Seamus Apr 10 '18 at 22:25
  • I suppose you could but that's for a very specific purpose. It would mean your client wouldn't be able to connect to another network and it would mean that each client needs to have a static IP defined. It seems needlessly restrictive when you could just use DHCP. – John Hawthorne Apr 11 '18 at 12:56
1

What can I try to debug this issue?

Attach a keyboard and HDMI monitor (much easier than blindly guessing) and then stop the hostapd service and start it manually by calling hostapd directly giving it your configuration file:

sudo hostapd /etc/hostapd/hostapd.conf

Post the output of that here if you are still unsure if it worked or not. That should tell you why it didn't bring up the AP. Also have a look at what is in /var/log/syslog when you are trying to bring up the network.

  • I will try that tonight. I'm connected with serial port, so i have access to shell the whole time :) – KrwawyKefir Apr 11 '18 at 6:31
  • It look like it was my stupid mistake - after manually starting hostapd i noticed, that it simply cannot use wlan0 interface. I had all these lines to try to deny access to interface but i still had some network configuration in wpa_supplicant.conf when i commented it out and rebooted everything worked. Thanks for help! – KrwawyKefir Apr 11 '18 at 18:55
0

Here is how to create an AP on your raspberry:

  1. Before we get started installing and setting up our packages, we will first run an update on the Raspberry Pi by running the following two commands.

        $ sudo apt-get upgrade
        $ sudo apt-get update
    
  2. With that done we can now install our two packages, run the following to commands to install hostapd and dnsmasq.

    $ sudo apt-get install hostapd
    $ sudo apt-get install dnsmasq
    
  3. With the packages now installed we will want to ensure that we are actually given a static IP address for our Raspberry Pi, one of the ways of doing this is by making some modifications to the dhcpcd configuration, in here we can specify a specific IP Address we want the Raspberry Pi to sit on as well as IP we want our routers to operate on.

    To do this lets begin modifying the dhpcd.conf file by running the following command on our Raspberry Pi.

    $ sudo nano /etc/dhcpcd.conf
    
  4. Within this file we need to add the following line to the bottom, this will setup our wlan0 interface to the way we want it for our tutorial.

    interface wlan0
    static ip_address=192.168.2.1/24
    static routers=192.168.2.0
    

    Now we can save and quit out of the file by pressing Ctrl +X then pressing Y and then Enter.

  5. Now we need to restart our dhcpd service so it will load in all our configuration changes, we also need to reload our wlan0 interface to make sure it’s loaded in our interface changes. Run the following command to reload the dhcpd service:

    $ sudo service dhcpcd restart
    
  6. Next, we need to adjust our hostapd configuration, to do this we need to begin editing the config file with the following command:

    $ sudo nano /etc/hostapd/hostapd.conf
    
  7. In this file we need to write out the following lines, these basically set up how we want to interact with the wlan device. The only real lines you should worry about in this file is the ssid= line and the wpa_passphrase= line.

    interface=wlan0
    driver=nl80211
    
    hw_mode=g
    channel=6
    ieee80211n=1
    wmm_enabled=1
    ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
    macaddr_acl=0
    ignore_broadcast_ssid=0
    
    # Use WPA2
    auth_algs=1
    wpa=2
    wpa_key_mgmt=WPA-PSK
    rsn_pairwise=CCMP
    
    # This is the name of the network
    ssid=Pi3-AP
    # The network passphrase
    wpa_passphrase=raspberry
    

    Remember to change wpa_passphrase to your own password, make sure you set it to something secure so random people can’t just connect into your Wi-Fi access point.

    Now we can save and quit out of the file by pressing Ctrl +X then pressing Y and then Enter.

  8. With that done we should now have our hostapd configuration, but before it can be used we need to edit two files. These files are what hostapd will read to find our new configuration file. To begin editing the first of these two files run the following command:

    $ sudo nano /etc/default/hostapd
    
  9. In this file, we need to find the following line and replace it:

    Find:

    #DAEMON_CONF="" 
    

    Replace with:

    DAEMON_CONF="/etc/hostapd/hostapd.conf"
    

    Now we can save and quit out of the file by pressing Ctrl +X then pressing Y and then Enter.

  10. Now we need to edit the second configuration file, this file is located within the init.d folder. We can edit the file with the following command:

    $ sudo nano /etc/init.d/hostapd
    
  11. In this file, we need to find the following line and replace it:

    Find:

    DAEMON_CONF= 
    

    Replace with:

    DAEMON_CONF=/etc/hostapd/hostapd.conf
    

    Now we can save and quit out of the file by pressing Ctrl +X then pressing Y and then Enter.

  12. With hostapd now set up we need to move onto setting up dnsmasq, before we begin editing its configuration we will move the default one to a new location. We can do this with the following command:

    $ sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
    
  13. Now that the original configuration file is moved out of the way we can begin by creating our own new configuration file. We will create and edit the new file with the following command:

    $ sudo nano /etc/dnsmasq.conf
    
  14. To this file add the following lines, these lines basically tell the dnsmasq service how to handle all the connections coming through.

    interface=wlan0       # Use interface wlan0  
    listen-address=192.168.2.1   # Specify the address to listen on  
    bind-interfaces      # Bind to the interface
    server=8.8.8.8       # Use Google DNS or an other one
    domain-needed        # Don't forward short names  
    bogus-priv           # Drop the non-routed address spaces.  
    dhcp-range=192.168.2.50,192.168.2.150,12h # IP range and lease time  
    
  15. Set the dnsmasq to start. Edit the file:

    $ sudo nano /lib/systemd/system/dnsmasq.service
    

    Add the following line before “ExecStartPre=/sur/sbin/dnsmasq –test”:

    ExecStartPre=/bin/sleep 30
    

    Now we can save and quit out of the file by pressing Ctrl +X then pressing Y and then Enter.

  16. Enable automatic startup with the following command:

    $ sudo systemctl enable dnsmasq.service
    
  17. Now you should finally have a fully operational Raspberry Pi wireless access point, you can ensure this is working by using any of your wireless devices and connecting to your new access point using the SSID and WPA Passphrase that was set earlier on in the tutorial.

    To ensure everything will run smoothly it’s best to try rebooting now. This will ensure that everything will successfully re-enable when the Raspberry Pi is started back up. Run the following command to reboot the Raspberry Pi:

    $ sudo reboot
    

You can find the original tutorial here

  • Thank you for elaborative walktrough... with this setup I dont have hostapd startable at boot ... it waits for wlan0 link down (I can see it in journalctl -xe) and fails to put wlan0 device up because some other process is using it most probably... when I do airmon-ng check kill ... it kills all processes that use wlan interfaces then hostapd starts fine manually... so my tip is wpa_supplicant of dhcpd despite I added the necessary lines into its config. After hostapd started manually dnsmasq is not giving any dhcp leases despite it is started... any first shot ideas? – Michal Hainc Sep 9 at 11:41

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.