An easy installer script for my AutoHotspot and Static Hotspot setups.  Allows a Raspberry Pi to automatically create a WiFi Hotspot when you are out or connect to your home network when you are home.

This script is for installing a Raspberry Pi WiFi setup where the Pi will connect to a previously configured Wifi network when the Pi is in range of the router or Automatically setup a Raspberry Pi WiFi access point when a known wifi network is not in range.
This can also be run manually or with a timer to switch without a reboot.

There are three guides on this website which show the steps on how to install a permanent static access point or two setups that can switch between a Raspberry Pi access point or WiFi network connection without a reboot.

These three guides are now available in an Installer. This guide goes through the steps to setup the installer and what features are available.

Tested on PiOS Bullseye and Buster

Not compatible with PiOS Bookworm. Bookworm version available here


If you have not used the Autohotspot setup's before here is a brief intro to what they can do.


  • When you're home:   On starting the Raspberry Pi it connects to your home routers wifi
  • When you're out: On starting, if any known wifi connection is not found it will generate an access point so a direct wifi connection can be made to the Raspberry Pi by a tablet, phone or laptop.
  • While in access point mode:  if an ethernet cable is connected the Raspberry Pi, then it will have network/internet access along with any wifi device connected to the access point.

Additional Features:

Using a Cron, a timer can be setup so the wifi connection can be regularly checked. It will switch between a wifi router and a access point without a reboot depending on the results. This is useful for

  • Raspberry Pi in car entertainment systems
  • Raspberry Pi Dash Cams
  • If the RPi looses wifi connection in your garden or near your home when using the camera or sensors.
  • You run a script or program at home connected to your router and wish to monitor it while you are out. As a hotspot is generated without a reboot the script/program is not interrupted.

It is also possible to run the script from a GPIO button so you can manually run the script to switch depending on where you are.


This has been tested on PiOS Bullseye (11) & Buster (10). To see which version you have enter the command lsb_release -a. The scripts via the manual guides below have been tested on Jessie and Stretch and work fine, just this installer has only been tested on Bullseye & Buster.  I would say it should work fine on Stretch and Jessie but a computer is involved so you can never be sure!

  • Raspberry Pi 3, RPi 3 B+, RPi4
  • Raspberry Pi 1 or 2 with a Wifi Dongle*,
  • Raspberry Pi Zero W, Zero 2 and Zero with WiFi Dongle* (internet hotspot not useable as it has no ethernet port.
  • Wifi already configured for your home router

*some WiFi dongles don't work in adhoc mode or don't work with with the nl80211 driver used in this guide for RPi4, RPi 3, RPi 3B+, Pi Zero W  & Pi Zero 2 inbuilt wifi, so you may want to check this first before starting

The manual guides can be found here

Autohotspot with Net Access
Autohotspot with NO Net Access
Permanent Static Hotspot with Internet access

Also available at


To use the installer:

open a terminal screen

Download the AutoHotspot-Setup.tar.xz archive to the current folder using the command

curl "" -o AutoHotspot-Setup.tar.xz
Unarchive the file to the curent folder using the command
tar -xvJf AutoHotspot-Setup.tar.xz
If you are using the Desktop then you can right click on the AutoHotspot-Setup.tar.xz file and select Extract Here

change directory to the Autohotspot folder with
cd Autohotspot
Run the script with the command
sudo ./
This script will fail if sudo is not used.

You will presented with these menu option:

1 = Install Autohotspot with eth0 access for Connected Devices
2 = Install Autohotspot with No eth0 for connected devices
3 = Install a Permanent Access Point with eth0 access for connected devices
4 = Uninstall Autohotspot or permanent access point
5 = Add a new wifi network to the Pi (SSID) or update the password for an existing one.
6 = Autohotspot: Force to an access point or connect to WiFi network if a known SSID is in range
7 = Change the access points SSID and password
8 = Exit

Option 1: Install Autohotspot with eth0 access for Connected Devices

Once installed and after a reboot the Raspberry Pi will connect to a router that has previously been connected to and is listed in /etc/wpa_supplicant/wpa_supplicant.conf. If no router is in range then it will generate a WiFi access point.
This will have an SSID of RPiHotspot and password of 1234567890
Use option 7 to change the access point password and also the SSID if required
If an ethernet cable is connected to the Pi with access to the internet then it will allow devices connected to the access point to connect to the internet or local network.
Once a connection to the access point has been made you can access the Raspberry Pi via ssh & VNC with
ssh This email address is being protected from spambots. You need JavaScript enabled to view it..5
for webservers use

Option 2: Install Autohotspot with No eth0 for connected devices

This option is similar to option 1 but connected devices have no network/internet connection if an ethernet cable is connected.
The Pi itself can use the eth0 connection and also be accessed from a device on the etho network.
This has been designed so you can access only the Pi from a Laptop, tablet or phone.
The access point SSID will be RPiHotspot with a password of 1234567890
Once a connection to the access point has been made you can access the Raspberry Pi via ssh & VNC with
ssh pi@
for webservers use

Option 3: Install a Permanent Access Point with eth0 access for connected devices

This is for a permanent WiFi access point with network/internet access for connected devices.
The Raspberry Pi will only have network and internet access when an ethernet cable is connected.
Once a connection to the access point has been made, you can access the Raspberry Pi via ssh & VNC with
ssh This email address is being protected from spambots. You need JavaScript enabled to view it.
for webservers use

Additional setup is required if you wanted to use a second WiFi device to connect to the internet rather than a ethernet conection. This is a planned future option.

Option 4: Uninstall Autohotspot or Permanent Access Point

This will disable the setup of any of the three setups and return the Raspberry Pi to default Wifi settings.
Hostapd & dnsmasq will not be uninstalled just disabled. This is so a hotspot setup can be re-installed without access to the internet.  

Option 5: Add a new wifi network to the Pi (SSID) or update the password for an existing one

If you are using either of the autohotspot setups in access point mode and wish to connect to a local WiFi network. You will be unable to scan for any networks as the desktop wifi option will be disabled, shown as red crosses. You can manually add the details to /etc/wpa_supplicant/wpa_supplicant.conf if you know them.
This option will allow you to scan for local WiFi networks and update the Pi. If you then reboot or use the Force... option 6 ,see below.
This option only works for WiFi networks where only a password is required. If a username is required this will not work.

Option 6: Autohotspot: Force to an access point or Force to WiFi network if a known SSID is in range

This option is only for the Autohotspot setups.
If you are at home and connected to your home network but would like to use the hotspot. This option will force the pi to access point mode and will ignore your home network untill the next reboot. If you use this option again while in access point mode, it will attempt to connect to a known WiFi network. This will go back to the access point if no valid WiFi network is found or there is a connection issue.

Option 7: Change the Pi's access point SSID and Password

By default the access point SSID is RPiHotSpot with a password of 1234567890. Use this option to change either or both SSID and Password.
You will be prompted to change both but if you make no entry and press enter the existing setting will be kept.
The password must be at least 8 characters.

Option 8: Exit

Exit the script.

Complete the Setup:

If you have installed a hotspot setup with options, 1,2 or 3 then Reboot to activate the setup.

To test the Hotspot mode for the Autohotspot setups;  run the installer again and select option 6 to force the Pi into Hotspot mode. You can then test that everything is working ok.

When you have finished either choose option 6 again to reconnect to your router or reboot.

Switching Setups:

You can switch between options 1,2 & 3 at anytime. All configuration will be changed removing the config of the previous setup. Just be aware that each setup has a different IP address for the access point. If you have changed the access points SSID from RPiHotspot or the password from 1234567890 (which is a good idea) it will be reset back to the defaults.

If you find this guide useful and wish to show your appreciation then you are welcome to make a donation or share a link to this article. There is no obligation to do so, this guide is free for use and support is available to everybody as long as I know the answer :)

I am the single developer of this script and website. Any support towards the costs are welcome.



Trouble Shooting

If you are in range of your router but the Pi will only create a hotspot even after a reboot then there will be an issue with connecting to your router. This can be caused by an incorrect password or interference especially if you are using 5Mhz wifi on a PI 3B+ or Pi4. 

To check the password either use option 5 or check /etc/wpa_supplicant/wpa_supplicant.conf

If your are having interference issues or believe this setup is the cause then use option 4 to uninstall the setup. Reboot and try your Pi again. If you still have a connection issue it will be an issue within your home network.

If it is this setup then it may be the format of your SSID from your router. It can contain spaces and special characters but not a comma. so "My SSID" will be fine but "My,SSID" will fail.

If your wpa_supplicant.conf file was created using a text editor on Microsoft Windows, though Cr (Carrage Returns) are handled,  there may be hidden formatting characters other than Cr that are causing the issue. Either just use notepad on Windows or backup and delete /etc/wpa_supplicant/wpa_supplicant.conf and create it again using the Raspbian desktop Wifi settings. Headerless setups can setup WiFi networks in raspi-config.  Option 5 will only work if wpa_supplicant.conf already exists.

/etc/network/interfaces file:

many older access points and network setup guides online add entries to the /etc/network/interfaces file. This file is depreciated in Raspbian & PiOS. Any entry in this file is not compatible with these setups. This installer backup and remove any entries found in this file. They will be restored if the uninstall option is used.

 Video Guide on using the Installer

On this video I go through following the steps in this guide and setting up a static acces point and a autohotspot, then how to connect to the access points on a tablet.




Add comment

Does this set-up work with ifupdown?
Hi Steve.

No it's doesn't use ifup or ifdown. The raspberrypi's don't use the /etc/network/interfaces file as the interfaces are managed through /etc/dhcpcd.conf for PiOS Bullseye and older. So you would need to use "ip link set dev wlan0 down" or "ip link set dev wlan0 up"
No network interfaces
Brand new to this Pi thing. Tried doing the manual install on a fresh install of bullseye (the Access Point only version) and it booted up saying No Network Interfaces found and I didn't know how to fix it to connect back to the internet or anything. Then did another fresh install of Bullseye and went right for the Installer. On bootup, it connected to my home network but I hit "Forget Network", rebooted and now No Network Interfaces again. Another weird thing is it's not connecting my Camera either but I also installed RPI Web Cam Interface so idk if that's why or if it's because the camera clamp isn't good enough.
No network interfaces
Hi Bob.

Welcome to the Pi world. When you are seeing No Network Interfaces, is this in the wifi menu by the clock? If this is the case, then that is correct because when the Access Point is active the software that controls that is disabled. It will re-appear when
it reconnects to your router. Using a phone/laptops wifi, do you see the AccessPoints SSID of RPiHotspot in the list of local networks? If so then it is working ok and you can connect to it there.
Also in a terminal window, if you enter the command "ip a" it wil show the interfaces. If wlan0 has a IP address starting with 192.168.50 then the access point is running.

If when using "ip a" there is no IP address check the line
"wlan0: mtu 1500 qdisc pfifo_fast state UP"
It should say State UP and not state DOWN.

If you can connect a ethernet cable t the Pi you will still be able to use SSH or VNC desktop sharing to access the PI from another computer on your network.

If it is State DOWN, check that the file /etc/network/interfaces has no entries for any interfaces (ie wlan0, eth0) as this will cause a conflict.
There should just be 3 lines, two starting with a # and one starting with "source".

For your camera, the RPIWeb Cam Interface looks to be out of date as it refers to Jessie and Buster. In Bullseye the cameras started using different libraries to work so any camera software not setup for Bullseye will not work with the cameras. It also seems there where other changes to the camera setup in the latest OS Bookworm.

This link is for the current camera setup, where you can use rpicam-still or rpicam-vid to check your camera works ok.

Camera software written in python needs to be using the picamera2 library for bullseye. Any that use the picamera library will only work in the Buster OS and older.

I hope this helps. If this doesn't resolve the issue with the access point setup please let me know.
pi zero 2 w
Dim question, but for this to work on a pi zero 2 w does it need a WiFi dongle? I have a data logging project where the form factor of a zero is perfect so it would be a pain if the onboard WiFi wont work for this! It's not the end of the world if I need to get an OTG cable and dongle though.
pi zero 2 w
Hi Ian I can confirm It works fine on a Pizero 2 as I have a project running with that setup. It will work on any Pi with wifi (builtin or USB) and Running the OS Bullseye or older. So its perfect for connecting to the Zero 2 via SSH, VNC or accessing a webserver. There is a separate script on this site for a Bookworm version which does also work with a Pizero 2. Though RaspberryPi only recommends that Bookworm is used for a Pi 4 or 5 for now.
Got it working. Thanks for making and documenting such a fantastic and useful script!
pi zero 2 w
You are welcome, good to hear it is up and running.
Any news for bookworm?
Hi Sarah Yes, it is nearly done, the plan was it would be up for this weekend, but time is not on my side. I hope to have it on the website in the next day or two.
Thats great news. Thanks a lot for your work. :)
Hi Sarah Just to let you know the Bookworm version is now available on the homepage.
Autodetect issues
Hello, I have a Pi Zero W and I am out of options. I have been troubleshooting for a week and it is driving me crazy. I install using option 2, and when I reboot, it will not automatically detect my wifi network, and instead deploys the hotspot. It does this no matter what option I choose. There is no issue with wifi range or interference, as i have verified this.autohotspot is the only software on a fresh install with a brand new sd card. If I use option 6 to force it to connect, it has no issue connecting, but as soon as the pi is rebooted, it will no longer detect my wifi network. Once in a blue moon it will act correctly, but only until the pi is restarted, and i see no pattern to this behavior. please help.i am out of ideas
Autodetect issues
Hi Can you confirm what OS you are using please. This is not compatible with the latest PiOs Bookworm, this will only work on Bullseye and older as noted at the top of the article. A Bookworm version is in testing at the moment.
It says bullseye, version 11, however knowing this, I want to reinstall and try without updating all packages
OK that's fine. It shouldn't be an issue updating the packages in Bullseye. Bookworm has a different way to manage the networking so needs a completely new script.

It maybe that some other process is making the wifi device unavailable during boot as it is in use.
The script is one of the last things to be loaded at boot so that networking is available.
It will then scan for your router. If the wifi device is busy then it can't do it's scan, it will try for 20 seconds. It will then go to the hotspot.

Alternately if it connects to your router but has not been assigned a IP address within 20 seconds it will also go to the hotspot.

And lastly it will do the same if the password is wrong, but that's not the issue here.

When you do option 6 I suspect things have settles down and things work as expected.

What you can do is manually run sudo autohotspot or sudo /usr/bin/autohotspot and you will get feedback on what the script is detecting and what it is doing.

Other than looking into what else maybe hogging your wifi device you could setup a timer so the autohotspot script is run once every 2 minutes. Then if it goes to a hotspot when it is near your router it will reconnect two minutes later.

In my "Auto Hotspot Scripts no Network" guide on the home page there is a section on setting up a Timer with the Cron.
Try that.

The Pi zeros can be a bit slow but it does work with my ones.

If this still doesn't help let me know and we can look into it further.
Manual Install
I have installed everything manually this time, including the cron timer. Same result. running sudo autohotspot gives this:

hotspot deactivated, bringing wifi up
checking wifi connection ok
failed to connect to non-global ctrl_ifname:wlan0 error: no such file or directory
wifi failed to connect, falling back to hotspot
autohotspot -----------
creating hotspot
Manual Install

From that error it is reading wpa_supplicant.conf and finding a match with a ssid and one being broadcast.
It shuts down the Hotspot and attempts to connect to the router.
Then it waits 20 seconds and checks to see if the router has assigned an IP address. This is where it fails.
this is the command
wpa_cli -i wlan0 status | grep 'ip_address'

can you check that you wpa_supplicant.conf file is complete.
/etc/wpa_supplicant/wpa_supplicant.conf should look like this
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

the country code should be for your country if not in the UK

If the top 3 lines are the same, in any order, and the network details are correct for your router then it should be fine.

The wpa-cli command will only work when the access point is disabled. You may have to disable the cron timer and use option 6 to shutdown the hotspot to try this.

The only other issue that can be due to the wpa_supplicant file is if on installing the Pis SD the wpa_supplicant.conf file was created on a Windows computer and copied to the Pi's Boot partition on the SD card. The Windows text format can cause issues. If so rewrite the file on the pi in the format above.

Let me know if you still have issues.
DHCP on Eth0
Hi, Very nice tool, love it! But there is one thing i'm missing or maybe it isn't even possible. But i want to use the Raspberry to host OpenSpeedTest and want to connect via Wifi or via Ethernet to test the connection speed of the connected device. Any idea how to do this? Many thanks in advance! Eric
DHCP on Eth0
Hi Eric

Thank you, i'm glad you like it.
I'm not familiar with the setup of OpenSpeedTest and it would also depend on what option you have installed, out of options 1 or 3.
Your title implies that you need the Pi to issue an IP over eth0. The Pi, normally and with this setup, expects the network connected via eth0 to supply the Ip address unless a static IP has been set in /etc/dhcpcd.conf. So if you need that then you can configure that as you need without issue.
It looks like OpenSpeedTest serves a webpage to control it by. If you are checking the speed via a network or internet then I would expect that network to supply the ip address.
So if that is the case, when the Pi is setup as an access point I would connect e.g my phone to the Pi's Wifi Access point and and then in a webbrowser enter the Pi's access point ip with the OpenSpeedTests server page or port. So for option 1 it may be or if for example it serves through port 81.
Then you should be able to check speeds with any eth0 connected network.

You won't be able to test the wifi speed while the pi is an access point from a connected eth0 network as to do that you would need a bridge setup which is out of scope for this setup.

If you have more details of what how the setup works I can maybe give you better details.
Which option are you using 1 or 3?
What type of device will be connected over eth0 and will it have dhcp?
How do you usually check the speed via wifi?
Banana Pi
Banana pi M2 zero and Banana pi P2 zero:

Just to let you know that when Raspbian Buster is installed on the BPI M2 Zero and the BPI P2 Zero, your software works fine.
Banana Pi
Hi Eduard

That's good to know, thank you for for the update :)
Problems Changing Hotspot name
Hi! thanks for the software and support! it works great with default settings, but just after changing the name of the hotspot using option 7 WIFI stops working, if I change the hotspot name back to the default one it works again, I'm using Bullseye on a pi zero w, maybe something changed on newer versions of Pi OS and there is a mismatch somewhere?
Problems Changing Hotspot name
Hi Jose

You are welcome. I have had a look into this. I have installed the latest Bullseye 32bit PiOS with Desktop.
After installing the option 1, I tried option 7, just to change the SSID to "newssid" but just press enter on the password so it wasn't changed.
This worked fine.
Can you give me an example of the style of ssid and password you used, ie was special characters used or spaces.

As you say the wifi stopped working I guess hostapd failed.
If you enter sudo systemctl status hostapd , if there is an error it will be shown there.
Alternately you can look at the config file and edit it directly.
sudo nano /etc/hostapd/hostapd.conf
you want the lines "ssid=" & "wpa_passphrase="

If you are still having issues then let me know what style of ssid and passwords you tried and I will have a go again.
Problems Changing Hotspot name
Password and SSID were the same maybe that was the issue? I was using "Weatherorbs" for both, it seem to be working now with 1234567890 password, or maybe it was a unrelated issue, I 'm sorry to bother you, thanks again!
Problems Changing Hotspot name
Hi Jose
It's no bother at all. I have just had a go with option 7 on the current Bullseye image. I was able to set the ssid and password as you did. Hostapd did except it, as I was able to connect and ssh to the pi.
So you should be able to set it as you wanted. I'm not sure why it failed as I can't replicate that but hopefully it will work next time.

Any further issue then please let me know.
Open hotspot
Thank you for this, setup script.
I would like the auto created hot-spot to be open (no password)
Would everything work OK if I just edit hostapd.conf?
Open hotspot
Hi Dougal

The autohotspots will work with no password but you will need to edit the /etc/hostapd/hostapd.conf file after it is installed
Just remove or comment out these lines
wpa_pairwise=CCMP TKIP

If you edit the hostapd.conf that is in the installer scripts config folder then the md5 check will fail and the script will not continue with the install.
Connect via cable?
Hi I have been using the wifi connection to connect the Pi to a notebook in the field for astrophotography with the Pi as the hotspot. Just come up a thought if I can connect the Pi to the notebook using a LAN cable will the program still assign IP address to the notebook and be connected? Sound stupid but there are time when I need to transfer big files from the pi to the notebook and wifi is too slow.
Connect via cable?
Hi UB_Astro

No that sounds perfectly reasonable as photography and video generate lots of larger files.

You can connect the Notebook to the Pi via Lan. The access point doesn't make any changes to the way the Pi uses eth0 compared to when it is not installed. So the access point setup won't assign an ip to the notebook but when you connect the Pi and notebook they should generate their own ip just for that connection or you can configure a eth0 network in /etc/dhcpcd.conf and your notebook.

The notebook will be able to connect to the Pi itself vis ssh, vnc etc but won't be able to connect to any device connected to the access point as they are on a separate network.
So you should be able to transfer files to and from the pi over lan no problem.
Synchronziatio of time
Automatic synchronization of Time in case of AccessPoint ( would be fine
WLAN0 has no IP after reboot

Thanks for the work! I tried running the script on RasPi OS Buster, latest updates, and firmware on a RasPi 4 8Gig. The script installs fine and seems to configure all the needed "conf" files. However, when I run ifconfig, WLAN0 has no IP.

Tried options 1 and 3, ran uninstaller each time but no change.

WLAN0 has no IP after reboot
Hi Peter

With option 1 or 2:
Are you seeing the SSID RPiHotSpot when it is out of range of your known routers? If so what happens if you try to connect to it?
Does it connect to your router ok? This will also confirm the service is working as you would get no wifi otherwise.

I know Raspberry Pi are making changes to the wifi but that has not been activated yet. Can you confirm you that dhcpcd is running.
sudo systemctl status dhcpcd
it should be running.

As you have the 8GB Pi4, are you using the 64bit PiOS?
Though I have tested it on the 64 bit version and all was fine I have not actively used it recently but also I have had no reports that it doesn't work properly, at least yet.

Generally a re-install will do the trick if for some strange reason it is not working as the script does check all the setup of the pi. I know you have done this a couple of times but it does do the checks that are done manually.

Manually check that these services are running without error when the Access Point is up and running.
You can use option 6 for force it to an access point if you are near your router.
sudo systemctl status hostapd
sudo systemctl status dnsmasq
sudo systemctl status autohotspot

For option 3: This is just configuration and has a different setup so should just work but again check
sudo systemctl status hostapd
sudo systemctl status dnsmasq

Let me know if anything shows up and I will see what we can do to resolve any issues.
Fixed it
Sorry for the later reply, in the end I just reinstalled the Rasping OS with Bullseye and it solved the issue.
Fixed it
Thanks for letting me know. Not sure what the issue was but glad its up and running now.
Multiple Pi's in Close Proximity
Hi roboberry,

Your work is outstanding! I aim to have multiple Pis in close proximity, all using install option 3. Ideally, I want to use VNC to connect to each Pi. I have tried assigning a new ip, ssid to each, but if I edit the autohotspotN file then returns a checksum error and won't let me proceed. I have followed the instructions you've previously given. I made sure that the ip and dhcpcd ranges match across autohotspotN, /etc/dnsmasq.conf and /etc/dhcpcd.conf. Am I missing a step? Should I ignore the checksum warning and proceed anyway?

Thanks for your help,
Multiple Pi's in Close Proximity
Hi Will

Thank you, i'm glad have found it useful.

The script is setup so that you edit them after they are installed. The config folder has the checksum to make sure all files are present and unchanged before the installer starts. It won't start unless all is good.

Option 3 configures a Permanent Access point so just configures the pi for an access point and doesn't use the autohotspot scripts. autohotspotN is for option 1, autohotspot is option 2.

To change the ip address for option 3 change /etc/dhcpcd.conf
static ip_address=
static routers=
make sure the first 3 digits match.

and as you know make the required changes in /etc/dnsmasq.conf

Only the SSID's need changing so you can identify which Pi you are connecting to. Though the IP's are the same they are all independent from each other, but thats unless you have a specific need to change the IP.

That should get you up and running
Hostname not recognized anymore
As always I do change the standard hostname 'raspberrypi' into 'clearview' and all was okay, even after installing Autohotspot.
But now I do counter a problem that when I'm hooked up to my local network, I cannot SSH into the raspberry pi zero with just http://clearview. Although it works fine when typing the IP address.
Good to know that I made changings in the file /etc/hosts localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

# clearview clearview
Hostname not recognized anymore
Hi Eduard

There seems to have been a change in how PiOS changes the hostname in Bullseye. If you use raspi-config or the desktop configuration menu and change the hostname you will be able to connect via the hostname clearview but for /etc/hosts on ip it doesn't seem to work anymore.

PiOS now uses the hostnamectl program to set the hostname;
hostnamectl set-hostname clearview
This is just for the Pi while it is connected to a network.

Dnsmasq still uses /etc/hosts so for the access point you will still need to set clearview in /etc/hosts

I'm not sure when this change happened but came across the issue a couple of months back, Hopefully this will be the cause of your issue.
Question about adguard
Hi, This is a really good software you made (the only one working for me)

i added an adguard home server on the same rpi4 B, and as it is not on the same subnet, it seems that wifi client dont use this local adguard for dns request, do you have any suggestion to solve it ?

bridge-utils dont work too, and my DHCP Server is on the internet box

Question about adguard
Hi Bouxi

Thanks, I'm glad you have found it useful.
You can change the IP address for the access point but it depends on which option is installed.

You will need to change the dhcp-range in /etc/dnsmasq.conf,,,12h
change to x's to what you need.

If you are using the static access point you need to change
in /etc/dhcpcd.conf to match what is done in dnsmasq.conf

If using the autohotspots then the ip is set in the scripts. /usr/bin/autohotspot or autohotspotN

Bridging won't work with the autohotspots they need specific changes to the scripts.
For the static access point, hostapd.conf needs the bridge= device adding and dnsmasq disabling if dhcp is managed from Ethernet. Bridging is outside the scope of the setup but this should point you in the right direction.
Success and now VPN
Success thanks on a Bullseye + 3B. Much easier than hand setting up.
Two suggestions.
a) Would it not be more normal to set the access point on
b) I am going to use this to as anti-geolocation so my next step is to install a VPN client so that I can have a connection back to my Router at home which will act as a VPN server/endpoint. I suspect that is will be a common need, so perhaps time for another option for simple PPTP VPN for all data going in and out including DNS searches.

Anyway thanks

Success and now VPN
Hi John

I'm glad you have found it useful.

Maybe it is more normal to use .1 but I have 3 published access point setups and some customised versions so it is easier for me to have different ip address, then I know what i'm working with when I access my Pi's and what scripts people are asking me questions about.
It can be changed in /usr/bin/autohotspotN if you need a different ip. Though make sure /etc/dnsmasq.conf has the same ###.###.## ip i'm dhcp-range=

I have used it with OpenVPN which worked fine.
You will probably need to change the eth0 interface in /usr/bin/autohotspotN to tun0

see this section near the top:
wifidev="wlan0" #device name to use. Default is wlan0.
ethdev="eth0" #Ethernet port to use with IP tables
#use the command: iw dev ,to see wifi interface name

I am currently writing a new version of which VPN's are a consideration among other features.
Using another NIC?
Is it possible to configure this to use another network interface? I'm trying to configure this with my RTL8814AU and I can't find a reference to wlan0 in the code (though I suspect more would need to be changed). Thanks for your great program!!
Using another NIC?
Hi Bjorn

Yes it can be changed to wlan1 for the access point.

Change the references to wlan0 in

/usr/bin/autohotspotN (for option1)
/usr/bin/autohotspot (for option 2)
in these two files is this line near the top of the file
wifidev="wlan0" #device name to use. Default is wlan0.

You can reference the manual guides on the website for further information as this shows you how it is all installed.

Let me know if you need further info.
Works perfect!
Thanks for the great tool! I use it on a Pi Zero W in combination with the RPi-Cam-Web-Interface as a baby camera monitor. At home I use my private wifi, but in other places (e.g. during vacation), I use the AP of the Pi Zero W.
Just one question: In AP mode, I cannot access the RPi cam web interface from my Android when mobile data is activated, since the chrome browser always tries to use the mobile data internet connection because the AP wifi from the Pi Zero has not internet connection. Any ideas how this could be solved?
Works perfect!
Hi Simon

I know android data is an issue when using ssh, I have to switch off mobile data to use ssh but for VNC and webservers I have not had a problem.

If you have to enter a hostname in chrome to access the Cam Web Interface it may be that, as the access point doesn't have a hostname so Chrome will try and find it on the net instead. You have to use the ap's ip address. The Pi's hostname is only available when the AP is not active. The hostname for the AP can be set in /etc/hosts by adding the ip address and hostname. This doesn't have to match the normal hostname.

If that doesn't help let me know how you are accessing the webserver and I will look into it.
Power increase
I would like to increase the Wi-Fi transmission power, I clarify that I am not an expert but I defend myself, if someone knows how to do it, I appreciate it. Best regards.
Power increase
Hi Dario

There is a command to change the power for the wifi but in my experience it makes no difference.
Have a look into "iw dev wlan0 set txpower" for more details.
If you need more powerful wifi then it is probably better to go for a USB wifi device.

Also make sure the Pi is receiving enough amps for it's use as low power will weaken the wifi.

Other than trying the usual methods of changing the channel in /etc/hostapd.conf for the access point or your router for home connections to avoid some local wifi interference or testing in a different location in case of external signal interference.

how does it work ?
Using a Cron, a timer can be setup so the wifi connection can be regularly checked. It will switch between a wifi router and a access point without a reboot depending on the results.

Regards Andreas
Hi Andreas

The cron can be accessed from the terminal with crontab -e
at the bottom of the page enter the command
*/5 * * * * sudo /usr/bin/autohotspotN >/dev/null 2>&1

This will rerun the autohotspotN script (option 1 in the menu) every 5 minutes.
change /5 to the amount of minutes you want. If you want once a minute then just use a star *

then save. This will be activated straight away and will be active at every boot up.

There is slightly more details on the manual guides on the homepage.
"With Network" for option 1 and "no Network for option 2. near the bottom of the articles.
Using UFW
Hi David

I have not used ufw so I can't say. It may depend on the OS you are using, Buster can use IPtables and Bullseye uses NFtables.

The autohotspot in option 1 will check if NFtables is active and apply NFtables rules. If you have IPtables installed as well then there will be a conflict.
If you only have either IPtables or NFtables installed then the script will use the correct tables.

If you use option 2, no tables are used at all and you can separately setup a firewall which may solve the problem.

The tables entries are in the main script at /usr/bin/autohotspotN if you need to add to them directly.
Using UFW
I just started using ufw for basic firewall and have rules setup to allow ports 80 and 443. Works fine when accessing my Rasbpi connected to Wifi. But once i switch to hotspot mode i can see the network but none of my devices are connecting to the network. I'm still searching around google to see why and debug but curious if this is a common issue and/or you know the ufw settings i need to allow access via the hotspot with the firewall. Without ufw everything works great in my setup.
USB ports not working
I have a set of four Pi Zero 2W boards, and after running the automatic hotspot configuration on them, none of them has working USB ports. I'm running the latest "bullseye" Raspbios distribution.

(Note: If I run a raw bullseye installation, w/o the autohotspot, the USB ports do work.)

If I connect a USB device (say a mouse) to any of the USB ports, the device's LED lights up, but there is nothing registered in the USB device list (as shown by lsusb -v).

I checked my /boot/config.txt, and it has this line enabled:

The contents of /boot/cmdline.txt are:
console=serial0,115200 console=tty1 root=PARTUUID=5ae7dd51-02 rootfstype=ext4 rootwait quiet splash plymouth.ignore-serial-consoles

Is there something else I've overlooked?
USB ports not working
Hi Alex

I would suspect your issue is to do with the power supply. Usually when the USB ports don't function properly it's because there is not enough amps to use them.

When the autohotspot is connected to the router there is no difference compared to when it is not installed. All that is different is wifi is brought up later in the boot process beyond that nothing else is running in addition to a normal setup. The changes only happen when it goes to an access point.
It may be that the access point uses slightly more power but I can't say I have ever checked that.

I have a Pi Zero 2, (using Buster at the moment as I have a project on there), running off a 5v battery and the Autohotspot installed, there is also a gpio hat added. I checked this with a USB memory stick and that wasn't detected at all. No entry in /media/pi/ or lsusb
I then tried again with a 5v 2amp rated mains plug. I could read the USB's directory with Network wifi but not with the access point running as the USB wasn't detected again.
When I tried a 2.4 amp mains plug I got the usb memory stick working properly in both modes.

If that doesn't help then let me know and I will try bullseye on my Pi Zero 2.
USB ports not working
Yes, even a 5.1V 2.0A mains plug isn't sufficient! When I plugged in a 5.0V 2.5A unit, the USB ports began to work again! Wow, these little Pi Zeros are power-hungry little beasts! I never would have guessed that this was the problem.

Thanks so much for sharing your insight.
USB ports not working
Alex, most probably it's not due to power consumption. I guess it's more a power control thing from the Raspberry board.
Have fun.
Static IP adress by option1
first of all many thanks for this successful script. Very good work! Everything works as it should.
I have a question about option 1 and need a tip on this.
When the RPi is connected to the router via wifi, the RPi gets its IP from the DHCP pool of the router. How can I teach the RPi to always take a specific IP and not the DHCP suggested IP.

I know this can cause problems, but makes sense in my case. I also know that I can have the router associate the MAC address of the RPi with a static IP. However, this is not a solution in this particular case, because new RPi's are always flashed with the same image.

Help would be great.
Static IP adress by option1
Hi Thorsten

You can set a static ip in /etc/dhcpcd.conf. When the Pi is connected to a router it can be configured as normal through dhcpcd.conf for interface wlan0. When it goes to an AP it will disables dhcpcd for wlan0 so those settings are automatically dropped.

in /etc/dhcpcd.conf to set the required ip enter:

interface wlan0
static ip_address=

It will use this from the next reboot or switch from AP to Wifi Network.
Connection refused
Hi, I'm using a RPi 4B + Bullseye. I chose Option 3. The hotspot does show up, but it refuses any connection attempts:

$ ssh
ssh: connect to host port 22: Connection refused.

The RPi can't even connect to itself.

In /etc/services it has the line: ssh 22/tcp
and ps shows the ssh-agent process is running.

What could be going wrong?
RE: Connection refused
I guess your command is wrong?

$ ssh pi@

Is the default ip not ?

Hope it helps.
Connection refused
Hi Alex

SSH connection refused as far as i am aware is usually because SSH is not running on the Pi or the details that are being used to make the connection are incorrect.

if ssh is being used then it will fail as their is no user name. try ssh pi@ or replace pi with what user is on the Pi.

If ps shows it is running then it will be enabled in raspi-config so that's all is needed. You can also check with sudo systemctl status ssh

I'm not sure what you mean by "The RPi can't even connect to itself." Are you using ssh from a device connected to the Pi's wifi Access Point?

If a Phone, laptop etc is connected to the Pi's wifi Access Point then that is working. This will be a separate issue with ssh setup. You should be able to ping to the pi from the connected device to show the connection to the pi is ok.
Hi there, I forced the Pi to AutoHotspot (option 6) and I see the SSID. I try to connected and its stating "Couldn't connect to network". I tried on my phone and PC. Any advice for troubleshooting? I made sure country_code was correct, same for the hw_mode and channel.

Thanks! Any advice will help. So far this is the closest I've gotten to turning this into an AP. Great idea!

Hi Roman

What happens if you don't use option 6? try moving out of range of the router or manually changing the ssid to an invalid one in /etc/wpa_supplicant/wpa_supplicant.conf.
Then run sudo /usr/bin/autohotspotN (option 1 setup) sudo /usr/bin/autohotspot (option 2 setup)

Option 6 is a hybrid of the main script works slightly differently, but that shouldn't stop it from working correctly.

Has there been any changes to the files or is it just as it was installed?

The error is probably related to dnsmasq not working correctly. try sudo systemctl status dnsmasq for any error messages.

Can you confirm which option was installed and what OS is used please.

Let me know and I will look into it further.
Thanks for the quick response. So I did a fresh install and I'm able to connect to the access point now. The only thing I would like more details about is...

If I plug the ethernet into my Raspberry Pi, it is still connected to my wireless router and the AP is not broadcasting. This is still the case after I reboot the device.

I installed using option 1, I'm running the latest update of Raspbian.
Hi Roman

The autohotspot only automatically creates an Access point when it can't find the know wifi router.
Then if Ethernet is connected that has internet access the devices connected to the AP also get internet.
If a known wifi network is in range then you will get as you see both Ethernet and wifi connected to the router.

Maybe option 3 is of interest. That will give a permanent access point and ignores the wifi router. This can't be used with option 6 though. That only works for 1 & 2.

Let me know if you need further details
Whoops, that is right. Thanks so much for you help and this awesome tool! I've already told 3 people about how nice it is. Hopefully we get you some donations for incredible work.

Thanks again!
You are welcome, Thank you for spreading the word and for your very generous donation.
It happened again, I'll explain better.

> Installed Option 1
> Turned off SSID from my Wireless Router
> Plugged RPi into router with ethernet

With this, I can access my RPi-AP from my computer and cell phone

> Unplugged ethernet from router
> changed the name of SSID "myWiFioff" and saved (sudo nano /etc/wpa_supplicant/wpa_supplicant.conf)
> Restarted RPi
> I can see RPi-AP broadcasting on my phone and PC - BUT cannot connect

"The error is probably related to dnsmasq not working correctly. try sudo systemctl status dnsmasq for any error messages."

only error was:
"no severs found in /run/dnsmasq/resolv.conf, will retry
"read /etc/hosts - 5 addresses
"Started dnsmasq - A lightweight DHCP and caching DNS servver"

It says "active (running)"

Any suggestions?

Hi Roman

It looks like dnsmasq is running ok, Those remarks are normal.
and if you are seeing the AP SSID then hostapd is working.

It's a bit strange that you where able to connect which suggest the setup is fine. So it it is a bit odd that you can't now.

Connection issues are usually because the IP address has been updated in dnsmasq but not in /usr/bin/autohotspotN so there is a missmatch.

Hostapd config has been altered and introduced an error, password shorter than 8 characters, missing or invalid country code.

/etc/network/interfaces contains config

/etc/dhcpcd.conf contains old Access Point config from other guides.
this should only need nohook wpa_supplicant
for this setup.
Other devices such as eth0, can have config but there shouldn't be anything starting with
interface wlan0
and additional config underneath (this is usually at the bottom of the file)

As you have used the installer and option 1 all these issues will be the installers files except /etc/dhcpcd.conf which only makes changes. So can you just double check there is no reference to interface wlan0
if there is then put a # infront of each line.

Connecting and disconnection the Ethernet will not cause any issues as that is handled separately by the Pi and will not stop the AP from working.

You can try getting your phone or laptop to forget the network. Then try connecting again using the password in /etc/hostapd/hostapd.conf. 1234567890 by default.

The only recent change that could be related is to remove an older setting from hostapd.

in /etc/hostapd/hostapd.conf ther is a line
try changing it to
wpa_pairwise=CCMP TKIP

and try again.

Otherwise with a screen ssh through eth0:
edit your ssid to myssidoff
run /usr/bin/autohotspotN
see if it creates a AP or shows any errors it doesn't resolve.
Then again try connecting to the AP.
if still an issue check
sudo systemctl status hostapd

Are you using PiOS Buster or Bullseye?
let me know if this helps. You can contact me via email admin at this site, and we can discuss further if this dosn't help.
Hi Roman

Have you been able to solve the issue. If not you can email me to look into it.
Thanks for checking in. After looking at the prices of a new Raspberry Pi4, I decided to use my RPi for something else and just purchase a Wi-Fi AP to create a guest-network. It ended up being a lot cheaper. Once the price goes back down, I might jump in here again and work with your script. Thanks again for all your support, this is by far the best guide I've seen online!

Cheers! Have a great one!
Thank you, Ok let me know if you need any further support in the future. :)
Pi user
Good day. I am trying to use option 3 on a Pi 3b+ running Bullseye. I have an active eth0 input from my router ( and can see the RPiHotpot ssid. However I can't connect to it as the authentication never gets through to the point I can enter a pw. Any suggestions?
Pi User
Hi Mark

Usually if the connection fails to authenticate that would point to an issue with the /etc/dnsmasq.conf entries such as the ip range not in the same subnet as the entries in /etc/dhcpcd.conf but as you are using the installer I wouldn't expect it to be that.
I am not able to reproduce that issue on my setup.

you can see if there is any issue with dnsmasq with sudo systemctl status dnsmasq. It should say "Active: active (running)" near the top of the output.

It can be caused by other network setup on the Pi also being configured for ip address 192.168.50.#
you can check with ip -a
and see if no other ip address start the same.

If the wlan0 ip address starts with 169.254 then there has been an internal issue and no ip could be created for wlan0. Most likely dnsmasq.conf again.

/etc/dhcpcd.conf has the entry "nohook wpa_supplicant"
that should be there but if it is not the pi will also try to connect to your router so will cause the connection issue.

Have you tried to connect with more than one wifi device?

Let me know if any of this helps, otherwise I will look into it further.
loption 6 can't load country
This is a fresh build with current os on raspbery pi zero W. My initial setup is headless through wifi. works ok. raspi-config set country to us. install autohotspot. set option 1. reboot. Goes to hotspot not wifi network. Tried option 6 "error no country set". Checked raspi-config tried setting country gives error "could not communicate with wpa_supplicant". Check wpa_supplicant.conf and country was there. What am I doing wrong.
loption 6 can't load country
Hi Steven

It doesn't sound like you have done anything wrong.
Raspi-config should have set the country in /etc/wpa_supplicant/wpa_supplicant.conf as
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

Then when you installed option 1 it takes the two digits at the end of the country line (US) and adds them to


You won't be able to update the wifi country while the Access Point is active because it shuts down wpa_supplicant.
So you need to be in wifi network mode for wpa_supplicant to be active again.

If you manually check both the files above are correct and the country is in upper case it should work on the next reboot.

I have used raspi-config and changed my wifi country and installed option 1 and wasn't able to reproduce the issue.

Was your wpa_supplicant.conf file created in windows and put in the boot folder when you created the SD image?
RPI Zero 2W
I have tried to install the hotspot, with and without internet but it did not work. No SSID showed up after a reboot. I installed of course a fresh Raspberry OS and performed a "update" and "full-upgrade".
What I like to achieve is a standalone hotspot where I can connect my laptop or phone to and observe my MotionEye camera's.
motionEye is a web-based frontend for motion.
RPI Zero 2W
Hi Ed

Have you used option 3 from the installer. If you have used it with and without internet, i am guessing you have tried options 1 and 2, These only create an access point when your wifi router is off or you are away from it whne the Pi is started. Option 3 is a permanent access point and will always broadcast the ssid.

Looking at Motion eye I presume you are using PiOS Buster rather than PiOS Bullseye. Im currently updating the access point to work with Buster. They will still create a SSID but currently any connected devices can't connect to a network or Internet through eth0. Though the Pi itself can. Buster is fully working.

With option 3. Once your laptop or phone is connected to the access point you can enter in a webbrowser to see the motion eye webpage.

if you would like to use a hostname such as "motion" instead of the ip address, so you enter http://motion:8765 instead
then add the line motion
to /etc/hosts

If this didn't help then can you confirm which option you have used and if you are using Bullseye or Buster.
Also check
sudo systemctl status hostapd
and see if there are any errors shown.
RPI Zero 2W
Thanks for the help, all works fine now. The only remark I have is that it takes a few minutes before the SSID shows up. Could this be a channel issue?
With the new RPI zero 2W at 25 frames/sec and 1280x720, there is no noticeable delay. at 1920x1080 < 0.5 sec
RPI Zero 2W
Hi Ed

Glad it working for you now.
It shouldn't take a couple of minutes, it should be within 30 second of powering it.
I have tested my Zero W 2 with option 3 (Permanent Access point) from both a battery and mains. I use a Wifi analyser on my phone which showed the SSiD available within 30 seconds.

That being said, just generally with any of my Pi's even when they are connected to my router over wifi the Hostname or IP doesn't always show quickly on my network. On occasions I have to do a network scan from my phone or PC before they show up. But I put this down to a weak Pi signal from it's location, using a battery or unknown interference. This is not consistent and it can all work fine for months.

The permanent access point starts as soon as the network is ready.
The Autohotspots (option 1 & 2) wait for the Pi to fully boot so they can take 10-20 seconds longer but you shouldn't need to wait for minutes.

You can try a different channel in /etc/hostapd/hostapd.conf
also check your boot up times and see if there is something else slowing things down.

sudo systemd-analyze critical-chain
sudo systemd-analyze time
sudo systemd-analyze blame

I have boot times in PiOS Buster of 22-26 seconds with the access point active.

Do you get the same result at different times of the day and in different locations?
fixed ip address for connected devices
Hi, I am using your nice script to create a wifi hotspot for my Pi 3B+, using option 2. I can connect my phone etc to the Pi with I am thinking of sharing a folder on the notebook to the Pi while connected. I am not sure how to assign a fixed ip address to the notebook so that I can create the samba or nfs parameters. Please advise if this is feasible.
fixed ip address for connected devices
Hi fuherb

Yes that can be done. Static ip's can be set in /etc/dnsmasq.conf for the mac address or the hostname of the device connecting to the access point.

add the line below where ##:##:##:##:##:## is your notebooks wifi mac address

make sure the ip is in the range set in the line

if your notebook had a hostname of MyNoteBook then you can also use

Next time the access point is created this will be used.
Option 3 (Permanent Hotspot) with Stati eth0 IP
Hi :o)
Thank you so much for this script.

I'm using it for a ps3netsrv and the option 3 works well for my case.

The PS3 is connected to the LAN (eth0) and I can access the permanent hotspot from my laptop or my arcade bartop.

The problem is that the eth0 ip changes everytime I restart my ps3, and so I have to change the settings of the PS3 (and Webman MOD + Multiman) everytime.

I've tried adding these lines to the /etc/dhcpcd.conf:

interface eth0
static ip_address=
static routers=
static domain_name_servers=

and the ps3 got this IP, but somehow it cannot connect to the library anymore.

I'm missing something?

How should I modify the script, to have a static IP with option 3 (Permanent HOTSPOT)?

Thank you so much again :)
Option 3 (Permanent Hotspot) with Stati eth0 IP
Hi Rosario

No problem, im glad you find it useful.

I'm not familiar with your setup but the issue will be to do with using the 192.168.50 ip.
The Wifi Hotspot is using the 192.168.50.# ip's. eth0 will be on a different network as the Pi is essentially dealing with two separate networks.

The eth0 ip should be based on whatever is issuing the IP address to the Pi over eth0, whether this is a router or a direct connection with the PS3.

For my setup the Pi would be connected to my router via eth0. The router is on network So any static IP setup in dhcpcd.conf for eth0 should start with 192.168.0

If your PS3 is issuing and ip address to the PI then make sure that the Pi's eth0 static IP is in the same network ###.##.##

I have not configured a direct lan connection between two devices but if that is the setup then again make sure both devices are on the same network and not using 192.168.50.

What you entered in dhcpcd.conf is correct, it just needs to be a separate ip range to the Wifi Hotspot.

Sorry I can't be more specific but hopefully that helps you.
update wifi
I want to be able to update the pi to connect to a router after connecting to it as a hotspot.

So, power up pi. It pops up a hotspot, then connect to it. SSH in, then I want to be able to connect it to a wifi router. I am using a zero, so want a way to connect it to a router when it's not connected without having to do the net sup file.

I tried going in and using raspi config, but it doesn't work because the link is active.
Hi Nod

If you have used the installer script on this page then that has the features to do that.
just cd to the Autohptspot folder and then sudo ./
If the router you want to connect to is new to your Pi then choose option 5
This will allow you to pick a nearby routers from a list and enter the password. This won't work if the router needs a Username and Password such a public wifi.

Once the router is setup then choose option 6. This will force the Access Point to stop and the Pi will connect to a known router in range.

Option 6 also allows you to disconnect from a router and create an access point even if you are still in range of a router.
thx i have been trying to use pi at school
the school wifi dose not allow for localhost or raspberrypi.local
Pi at School
Hi Logan

Presuming the schools firewall is not blocking your access. Check if you can ping the Pi's wifi using it's ip address
If you don't know the Pi's wlan0 ip address, I doubt if you will find it doing a network scan as there will be too many devices on the school network. So without a screen or some way to display the IP on the Pi you will find that difficult to work out.

Try changing the host name from raspberrypi as there may be others with the same host name on the network so it will have connection issues. Either change the Hostname in "Raspberry Pi Configuration" to something more unique. This can also be done in /etc/hosts
sudo nano /etc/hosts raspberrypi

The hostname isn't always available on a network or doesn't always show up so the ip address is the only way if the pi is visible to other devices on the network.

There are guides online that show you how to get the Pi's led to flash and count out the Pi's ip address if that helps.
AP not working - "country_code = E" issue
Tested with Rpi zero w:
The Accesspoint (Option 2) did not work any longer.
FIX (The code for germany was set incorrect!):
sudo nano /etc/hostapd/hostapd.conf -> country_code = DE
AP not working - "country_code = E" issue
Hi mastersnoop

Thanks for letting ,me know.
I tested it by changing the "Set WLAN Country" to "DE Germany" in the "Raspberry Pi configuration". On using the Autohotspot installer it correctly used DE for hostapd.conf

It gets the country code from /etc/wpa_supplicant/wpa_supplicant.conf which is where "Set WLAN Country" updates it to.
Do you know if yours wpa_supplicant.conf file was created manually or was the country added with the configuration settings?
raspberry pi 4 connectivity
I have done your tutorial to the letter multiple times. I can connect my windows laptop and android phone, but there's no internet. Do I need a LTE modem or does this process imply that one is not needed?
raspberry pi 4 connectivity
Hi stryker296

The internet is available when you connect a Network cable to the Pi via the Ethernet port which is connected to an internet connected router.

You can add a 4G Mobile network card to USB and change the reference to eth0 in the AutohotspotN script to whatever device name they use.

You can not use a second WiFi usb adaptor (wlan1) for internet for the autohotspotN script as it won't be able to switch between access point and network connection any longer.

You can use wlan1 Wifi that is connected to a Internet connection with the Static access point only. Change dhcpcd.conf to show:

interface wlan0
nohook wpa_supplicant

instead of
nohook wpa_supplicant
interface wlan0

That will allow wlan1 to be used to connected to the internet via a Wifi router.

Let me know if you need further info.
raspberry pi 4 connectivity
Ok that makes sense. However I'd like to use the Pi outside of any wifi network (camping or in my vehicle). I'd assume the Pi does not make its own signal. How can I use the hotspot away from my internet source?

The internet is available when you connect a Network cable to the Pi via the Ethernet port which is connected to an internet connected router.

You can add a 4G Mobile network card to USB and change the reference to eth0 in the AutohotspotN script to whatever device name they use.

You can not use a second WiFi usb adaptor (wlan1) for internet for the autohotspotN script as it won't be able to switch between access point and network connection any longer.

You can use wlan1 Wifi that is connected to a Internet connection with the Static access point only. Change dhcpcd.conf to show:

interface wlan0
nohook wpa_supplicant

instead of
nohook wpa_supplicant
interface wlan0

That will allow wlan1 to be used to connected to the internet via a Wifi router.

Let me know if you need further info.
raspberry pi 4 connectivity
Hi stryker296

It depend on how you are using it. If you just want access to the Pi then connect a laptop/phone/tablet to the Pi's Wifi signal RPiHotspotN then you can use VNC desktop sharing or SSH to access the PI, there just won't be any internet.

If you need the Pi to have internet access as well then you can Tether your phone via a usb cable to the PI and the Pi can use the Mobiles internet Data. You will need to know the device name of the tether, such as usb0 and then change the entries in the /usr/bin/autohotspotN script from eth0 to usb0. This can be found on the Pi with the command ip a

Here is the part to change at the top if the script /usr/bin/autohotspotN
ethdev="eth0" #Ethernet port to use with IP tables
ethdev="usb0" #Ethernet port to use with IP tables
if yours is not usb0 then use what ip a shows.

The other option is to buy an addon Mobile network card for the Pi that you buy a mobile sim for. This gives the Pi direct access to mobile data. Then using the changes described above change eth0 to the device name and the Pi will use mobile data at the same time you can connect a laptop to the pi's hotspot.

Some mobile companies don't allow tethering of data so thats something to look out for.
Change eth0 to wwan0 in hotspot, no ssh possible
Hi Roboberry
First of all. Thank you so much for your code. This masterpiece saved me a lot work in several projects. It is just awesome.
In my current project I make a webcam to track the progress of a construction site. I use a raspberryZero with a standard picam to do this. Because there is no ethernet and no router in around 1km I use a 4G module (SIM7600G-H 4G HAT (B)) connected to the raspberry. The module is connected and everything works well. When I'm at home my raspberry is connected through the regular wifi. When I'm on the construction site the raspberry goes into the hotspot mode and I can easily connect to him and do modifications or some tests.

Now the issue:
For unknown reasons I'm not able to ssh to my web server if I'm in the hotspot mode and the connection to internet is provided via wwan0.
What I already did is, changing in /usr/bin/autohotspotN ethdev to wwan0. But it didn’t helped. Is there something else I missed or do you think it is more provider related?
Change eth0 to wwan0 in hotspot, no ssh possible
If anybody else has this issue with a Mobile network, it seems the Mobile Network in this case didn't allow an ssh connections.
Wifi configuration website
Hi there, has anyone have a hotspot wifi configuration website ? I have tried to develop a configuration website but it doesn't work properly. If someone has a prototype of website to set up the wifi connection, please let me know :)
Thanks in advance.
I'm doing a new LED project with my rpi. I found this script and IT IS AMAZING. Thanks a lot.
For my project, I did a webapi to configure networks, hostspot, force hotspot/wifi, etc.
I've seen many comments for this so I did a fork of my project with just the relevant stuff for network/hotspot configuration.

Enjoy !
Hi MaxThom

Thanks for letting us know about the webapi, that will be a useful addition.
I'm glad you like the script and thanks for the credits.
Switch between AP (hotspot) and Station (Router) mode yet?
I've been following for a year and on and off try to learn more about how Linux handles networking, but still don't quite get it. ;) I need the ability to switch between AP mode and STA mode. Click a button and all the settings necessary to setup an AP with a set SSID and PW and an IP like are in place. Click a batch file on the screen or run a menu app and select the second option and it switches to Station/Client mode and lets you connect to your home router with DHCP. The local network would assign an IP with the regular "1" subnet:
It can remember whichever mode was last set until you change it. I don't mind having to reboot if necessary to switch modes. I've tried this with AT commands into an ESP8266 chip, but don't know how to do it through an OS like Pi Linux.
AP Mode
Hi Fred

It is a bit of a mine field trying to get the correct info with so many outdated guides online.
The general rule for the PIOS is if it mentions /etc/network/interfaces then don't use it.
dhcpcd is the network manager so avoid guides for dhcp. wpa_supplicant is used for connecting to your router. Though wpa_supplicant can be used for AP mode, it is more common to use a combination of hostapd and dnsmasq.

The PiOS is not able to act as a AP without additional configuration and then it is usually the case you will have a it as a permeant AP. Which is why I wrote the script to be able to switch between the two. By design it will only go to an AP if you are not in range of known network.

Option 6 for the Installer script on this page will allow the autohotspot scripts to be switched between AP and STA on command but this was written more for testing the setup than having it as a feature. A secondary script is used for option 6 which works alongside the autohotspot scripts.

You can reconfigure the autohotspot scripts to a AP ip address of your choice. This is done in two places.
/usr/bin/aoutohotspotN (option 1) or /usr/bin/autohotspot (option 2)
change the ip address to one of your choice here:

echo "Creating Hotspot"
ip link set dev "$wifidev" down
ip a add brd + dev "$wifidev"

then in /etc/dnsmasq.conf
change the dhcpcd-range to the same ip range.

so for

you want
echo "Creating Hotspot"
ip link set dev "$wifidev" down
ip a add brd + dev "$wifidev"
and dnsmasq.conf
Connected devices will be given an ip in this range. You can make the range from 2 to 255 but not necessary.
AP Mode Cont
The switch doesn't need a reboot as the required settings are enabled and disabled on command but there is no feature to remember the last state.
If you haven't already, have a look at the full autohotspot guides on the home page.
You could probably modify the autohotspot scripts for your personal use and add a log as to the last current mode which it can check and boot to that.

First of all, thx for the script! Really appreciate the effort you've put into it!
I do have a question concerning option #3:
Is there a specific reason why you chose to disable network access when the ethernet cable gets disconnected?
I was wondering if it would be possible to keep network access to the RasPi, even when the ethernet cable gets disconnected (for some reaseon) or the internet access of the connected ethernet cable goes down.
I simulated this event and it seems the devices connected to the permanent hotspot are not able to communicate anymore with the RasPi?

Best regards,
Hi Domi
You are welcome.

The permanent hotspot is setup so that it works regardless of any ethernet connection. The wifi device connected to the hotspot can communicate with the Pi and each other with no Ethernet connected. When it is connected, and presuming it goes to the net, they will all get internet access.

Could you give me more details about what you are experiencing please so I can see if I can reproduce it.

So, I had better luck with the manual setup, that is, flashing raspian on the uSD and stepping through the update, hostapd, and dnsmasq, but even then I have only seen a fully working switch once out of 6 attempts. I suspect that the MS EOL is the falkiness. I was hoping the auto script was the answer. But, it is probably just me, I see most everyone is happy with your efforts, congrats.
Hi Cy Drollinger

If it has worked once then MS EOL is not and issue. if the format of wpa_supplicant.conf was wrong it would never work. The script does deal with standard MS EOL stuff.

When the Pi scans for wifi it only does for a short time so only the strongest signals will show up. So if there are too many signals then that may be an issue.

run the script manually a few times and look for the signals listed as
SSID: \x00\x00 ......

if it doesn't show then the script won't try to connect to it and stay as an access point.

If it does detect it,
If the Pi hasn't received an Ip address from the router within 20 seconds it will jump back to the access point. You can increase this and see if it helps.

in /usr/bin/autohotspot or /usr/bin/autohotspotN look for

echo "Checking WiFi connection ok"
sleep 20 #give time for connection to be completed to router

and change sleep 20 to the number of seconds you want to try. 20 should be enough though.

The simplest option would be to not have it hidden but that is probably out of your control.
on my raspberry pi zero w the option 6 doesn't work, it stay on the line "Cleaning wifi files and Activating Hotspot" indefinitely.
The option installed was the number 2 (hotspot without internet), any idea? Thanks!
Hi Stefano.
I presume you are connected to the Pizero via SSH when you use option 6?
The Pi will be disconnecting from your router and creating the hotspot so you will loose the network connection to the Pi at that point and the SSH session ends.

You need to connect to the Wifi Hotspot (RPiHotspot) and then use ssh pi@ to reconnect via ssh.

Then the opposite will happen if you use option 6 again. The Pi will deactivate the hotspot and reconnect to your router so you will loose ssh then as well.

This is how it works as you are moving between two separate networks.
The problem is that i'm unable to connect via ssh (from my phone using JuiceSSH) to pi@ (obviously i have connected my phone to RPiHotspot ssid) Thanks!
Hi Stefano

On Android you have to switch Mobile Data off to connect via ssh. I also use Juice, Android blocks the ssh connection if Data is on. It will happily let you use VNC with data on though.
WTH you are right ! :-D
GREAT Software! Thanks again for that GREAT work!
Cool, I'm glad you are up and running and you are welcome.
This is a great script! Thanks so much for putting it together!

I did have a couple of issues though. Firstly when autodetecting the wifi country (au in my case) I only get the last letter, not both. I think it may be because it is counting the newline at the end. Would it be possible to split this on the = instead? eg

IFS== read -ra cc
Hi Simon,
Thanks for the feedback, I will check that out.

How was the country entered into wpa_supplicant.conf on your setup, was it the localisation settings or manually created?
This is great! It does exactly what I wanted and was super easy to set up.

You mention being able to set it up to switch with a button or switch. Do you have any examples of that? I think I figured out how to run _a_ script from a button push, but I still haven't figured out how to automate running _this_ script. Any insights would be helpful
Hi Science400

Im glad you find it useful.

I haven't specifically got an example but all you need to do is find a python script online for a Raspberry Pi shutdown buton.

as part of the script will be a line like this:
os.system("sudo shutdown -h now")

replace this with
os.system("sudo /usr/bin/autohotspotN")
this is for the internet version and
os.system("sudo /usr/bin/autohotspot")
for the direct version.

Then to run it use a service like the one used to start the autohotspot script in the manual setup article.

in /etc/systemd/system/
add a fill called autohotspotbutton.service

and add this code
Description=Autohotspot Switch Button

then enable it with sudo systemctl enable autohotspotbutton

now put you python button script in /usr/bin and call it
next make it executable with
sudo chmod +x /usr/bin/

After you reboot the button will be available.

The script will run but will only switch to an access point if you are away from your router. Then only reconnect to your router if you press the button in range of your router.
Cheers, mate. Your installer works and is super easy to use. I have one question, though. Is it possible to change the default SSID, passwords, and addresses the installer sets?

Many thanks
Hi Jude,

thanks for the feedback.

The SSID and Password can be changed with option 7 or you can do it manually in /etc/hostapd/hostapd.conf

The ip addresses will depend on which setup you are using.
These have to be changed in two places and have to be in the same subnet.

In /etc/dnsmasq.conf the ip range for connected devices with

for the autohotspots in /usr/bin/autohotspot or /usr/bin/autohotspotN

look for this section
echo "Creating Hotspot"
ip link set dev "$wifidev" down
ip a add brd + dev "$wifidev"

and change the ip for the access point.


ip a add brd + dev

ip a add brd + dev

For the Permanent access point change the ip address in /etc/dnsmasq.conf and /etc/dhcpcd.conf
static ip_address=
Hello, I have successfully setup a stand alone hotspot with an IP of, and it works well. Now I want to setup a Mumble server on the same PI, and I can’t get any clients to connect. If I setup a client on this PI and move the server to another, all works well. Any ideas? Or is that outside of the scope of this project? Thanks.
Hi Frank

In theory it should work, all ports are allowed. I see there are several reports online of people having connection refused on a Pi with wlan but it works fine with Lan so there main be another issue on some setups.

Sometime with the access point and VPN's you have to change the IP tables route but it looks like mumble doesn't need any of that as long as the port is available.

I can try it out, at least to get a connection. Have you used the mumble-server and client that is available through apt or from another source?
Hello again, thanks for your response, and thanks for looking into this. I didn’t see the email about your response. (Please disregard the question I just sent again.) Yes, I used the apt method to install Mumble-server with all the default settings on the Hotspot Pi. And then apt for the client. Thanks for any help you might have.
Hi Frank

I did try a mumble server on one Pi and tried to connect from a Linux PC and got no connection but vnc and other connections are fine. I will give it another go with a couple of Pi's and see what happens. This may not be for a about a week but i will let you know.
Thanks for looking into this. I don’t know if this would help, but someone else was able to make it work. I was going to try it tomorrow. His details are at the bottom of the page. Perhaps this would give you a clue. .
Hello Frank
Sorry for the delay getting back to you.
The link was not available by the time I got to look at it.

I have set up a Pi with the access point (Pi1) running the Mumble server using apt install. The access point has ip

I then connected a second Pi (Pi2) to the Pi1 access point over wifi. This has the mumble client installed. I connected with
This connected ok after the mumble-server password was entered.

I then made a wifi connection with a PC running Ubuntu (PC1) to the access point. This was also running the mumble client installed via apt.
I again connected mumble with
This also connected successfully.
I was able to send messages between Pi2 and PC1 fine so it looks like it all worked over the access point without any changes.

I didn't try the audio options as the Pi's don't have that set up.

So from this it seems it works fine.

The Pi's OS are fully up to date. I hope this is useful and you are able to get setup.
Trying to use this with ExpressVPN I'm a total Raspberry Pi newb.

Basically I want to run this hotspot and connect to the vpn and then connect to the hotspot with my Roku so I can watch tv.

But as soon as I connect the VPN I can't connect to the internet.

If I disconnect from the VPN I can connect to the internet and stream with the hotspot... just doesn't work with the vpn.

Is this something that's possible or no?
Hi James

Yes the setup does work with VPN's but it seems different VPN's have slightly different settings. I have used it with OpenVPN without any changes.

What it may be is ExpressVPN is using a bridge or a custom network device to redirect traffic to the vpn other than eth0. The access point is directing the internet to eth0. If you run the command: ip a
it will list the devices, you should have , lo, wlan0, eth0
if you have a 4th device that is only available when the vpn is active then you need to change some settings from eth0 to the new device.
I don't know if you have installed the static hotspot or a autohotspot but I will presume the static one.

In file /etc/iptables-hs
change any reference to eth0 to the new device and then reboot. Then try the VPN again.

If this dosn't help can you let me know what setup you have installed and what the output to "ip a" and "route" are both with and without the vpn active.
Ok, did

sudo nano iptables-hs

Then I changed all of the eth0 to tun0

tun0 was the fourth device that showed up when connected to ExpressVPN

Still has the same behavior though... once I connect to the VPN I don't have internet.

The fourth device under ip a is "tun0"

The data under the route command is

Flags UG
Metric 0
Ref 0
Use 0
Iface tun0
Hi James

That all look fine as far as I can see should work correctly. The other thing you could check is that ip forwarding is still enabled.

in /etc/sysctl.conf

look for the section below and check there is no # in front of the command as shown here.

# Uncomment the next line to enable packet forwarding for IPv4

Let me know if that doesn't help and I will see if I can find a solution.
Yeah there isn't a hashtag in front of that so it is on I guess... just not working
HI James

Ok, try just removing my ip rules as ExpressVPN may set something that means it is not working together.

ExpressVPN uses OpenVPN. It works ok with OpenVPN to a private vpn but the VPN paid services have different settings.

disable my iptables with
sudo systemctl disable hs-iptables
and reboot.

If that is not working then with the vpn active can you post the output of
sudo iptables -S
-N xvpn
-N xvpn_dns
-N xvpn_dns_iface_exceptions
-N xvpn_dns_ip_exceptions
-N xvpn_ks
-N xvpn_ks_iface_exceptions
-N xvpn_ks_ip_exceptions
-A OUTPUT -j xvpn
-A xvpn -j xvpn_dns
-A xvpn -j xvpn_ks
-A xvpn_dns -j xvpn_dns_iface_exceptions
-A xvpn_dns -j xvpn_dns_ip_exceptions
-A xvpn_dns ! -o lo -p udp -m udp --dport 53 -j DROP
-A xvpn_dns_ip_exceptions -d -p udp -m udp --dport 53 -j ACCEPT
-A xvpn_ks -j xvpn_ks_iface_exceptions
-A xvpn_ks -j xvpn_ks_ip_exceptions
-A xvpn_ks -p udp -m udp --dport 67:68 -j ACCEPT
-A xvpn_ks ! -o lo -j DROP
-A xvpn_ks_iface_exceptions -o tun0 -j ACCEPT
-A xvpn_ks_ip_exceptions -d -j ACCEPT
-A xvpn_ks_ip_exceptions -d -j ACCEPT
-A xvpn_ks_ip_exceptions -d -j ACCEPT
-A xvpn_ks_ip_exceptions -d -j ACCEPT
-A xvpn_ks_ip_exceptions -d -j ACCEPT
-A xvpn_ks_ip_exceptions -d -j ACCEPT
Hi James

I would need to try a paid for VPN on the setup to know what to change. I know it works with some other vpn service that have been used and OpenVPN out of the box. I would expect it to work when the hs iptables are disabled. Sorry i can't help further.
Ok no worries, thanks for trying to help :)

Oh the ExpressVPN has a 30-day trial period if you want to try... If not I guess I'll cancel my 30 day trial :)
Hi James

I would be interesting to know what is different. I did see they had a pay up front trial rather than a try before you buy trial. If I get chance over the weekend I will take a look into it further and try it out. I will let you know if I have any luck.
Awesome man sounds good :)
Hi James

Just to let you know, time hasn't been on my side lately but I setup ExpressVPN today and will let you know if I find a solution
Hi James

I have tried ExpressVPN with the static access point and the /etc/iptables-hs file changed from eth0 to tun0.
This has worked fine.

Setup: Pi4 Buster, Static Access Point from the Installer on this page. /etc/iptables-hs modified so eth0 is tun0 in all three references.
eth0 connected to home router via cable, wlan0 as access point Tablet connected to wifi access point. ExpressVPN running on Pi.
Pi and Tablet use VPN for net access while eth0 connected.

Searching for "my ip" online. Both the tablet and the pi report an ip starting with 85 while my PC connected to my internet provider reports an ip starting with 31. So it works for me with just a change to the IP tables from eth0 to tun0.

I have also tried it changing protocol between udp and tcp of which it worked for both so that's not an issue.

When you start expressvpn it says if the vpn drops it will block internet traffic. use 'expressvpn preferences set network_lock off' I don't know if that is worth a try.

Let me know if you have any progress, I will keep my account open for a week or so in case we need to try anything else.
wireguard vpm & no internet connection
No internet connect with wireguard VPN :
Really nice autohotspot scripts & code for the Pi APs !!
Hi there I spent quite a bit of time trying to get my wireguard VPN working with the internet.I installed autohotspot & kept getting "connected" but "no internet connection".
After much searching I came across the solution which does work, this requires a little knowledge of wireguard config files .
For info ,my wireguard network has all peers on 192.168.2.x.
Replace AllowedIPs , the default,which forces all traffic through the wireguard tunnel, with . That way only wireguard traffic goes through the tunnel to other wireguard peers (192.168.2.x) & internet traffic (which will be anything but 192.168.2.x) will go directly to the internet not via the tunnel.

My wg0.conf file :
Address =
PrivateKey = ***********************
ListenPort = 49150
PublicKey = ************************
Endpoint = ------------
AllowedIPs =
PersistentKeepalive = 20

I find wireguard light & efficient and runs on all Pi Os's.
I hope this helps Pi users using RaspiOS ,a hotspot & wireguard VPN
wireguard vpm & no internet connection
Hi Nick

Thank you very much for wireguard VPN settings. I'm sure that will be useful.
Will this work on other sbc, like OrangePi ?
Hi Andrei

This installer is set to only work on Raspberry PI OS (Raspbian) specifically. As Linux uses different network managers I can't guarantee it will work on other setup as it required dhcpcd.

I see Orange Pi has Debian as a listed OS. If that version is using dhcpcd as the network manger instead of dhcp or other network manager then the script will most likely work. The file /etc/network/interfaces must not be used with this as it will conflict. Lots of older guides online will use this file for network config.

you can check with sudo systemctl status dhcpcd

if it returns with Active: active (running) then it probably work if you follow the manual guides.
I would be interested to know if you do try it.

I will look at other OS at a future point and see what needs be modified.
Switching between wifi and hotspot works but does not give internet for connected devices. Connected to 5GHz Wifi before change to option 1 but there is no Internet available after hotspot is activated. Also, when doing a "switch" between 2.4GHz to 5GHz, Pi requires a reboot.
Hi DragProt

When the hotspot is active are you able to use ssh or VNC to access the Pi? Just to confirm that side is working ok.

Do you have a VPN setup that is using a device such as tun0 to route traffic through then LAN connection? if so your default route may be incorrect.
When the hotspot is active enter route into a terminal
There should be a destination "Default" for "Iface" eth0
This has been tested with openvpn and it works without any changes but not all VPN's are the same.

Can you give me more detail on your setup please, what Pi it is, if you are using a USB wifi adapter, which OS are you using?

The hotspot is only setup for 2.4Ghz connections so I presume you are having issues switching between 5GHZ & 2.4GHZ to your router? When the Pi connects to the router is using standard the wifi setup as your default Wifi settings. As long as your Wifi country is set in Raspi-config or the desktop preferences/Raspbery Pi Config it should be not different than without the autohotspot setup.

Could you give me more details on how you are switching between the two wifi speeds please, and I will look into it further.
No VPN setup (yet).
route returns:
Kernel IP routing table
Destination Gateway Genmask Flags Metric ect all with nothing in columns.
No USB wifi adapter - using internal network wifi chip
Current configuration:
Raspberry PI 4 8GB USB Boot from 512GB 3D NVMeM.2 2280 SSD in TDBT Case
OS is:
VERSION="10 (buster)"
Tried with 2.4GHz wifi only. Still does same:
No VNC connection works - no sh either
Wifi RPiHotspot is available and can connect
VPC connection does not connect
Windows machine does not get IP Address from PI, but even hard coding to does not connect with DNS and Gateway set to

When on normal Wifi on PI, auto connects to 5GHz and 2.4GHz with no issues.
If changing between 5G and 2.4G, requires a reboot - which I don't like.
Wifi country is set to US and works fine.

I attempted the installation first with complete manual steps and everything worked the same. Have tried this on 2 different boot cards with same results. Both from scratch, made headless, then loaded only the Hotspot - 1 manually, 1 with scripts. Get same results. My initial concerns were:
1. can't switch between 2.4 and 5 without a reboot
2. client connection to hotspot gets no address
3. client hard coded IP still no connection through VNC Viewer
4. network throughput on wireless is at 10% of wired 36 vs. 360 regardless of 2.4 or 5 connection.

Bad PI? Weird Network issues?
About run the gambit on what I can think of....
After a bit more fussing, I decided to go back to a Base PI load I started from:
The first thing I noticed was I could switch between 2.4GHz and 5GHz wireless with no issues.
To answer questions in order.
1. Hotspot active - VNC or ssh work
No. Client does not get compatible IP but even when hard coded, unable to VNC or ssh to PI
2. No VPN installed
3. route command returns no default device
4. PI setup:
PI 4 8GB booted from TDBT case w/ 512GB NVMe Gen3x4 SSD
raspi-config set to US/English
WLan - US
Interfacing Options - Camera, SSH, VNC
5. Attempted different methods to switch between wifi speeds
Console click select
Script run sudo to replace wpa_supplicant.conf with either 5GHz or 2.4GHz settings
Also changed priority so started on 2.4GHz as default based on your suggestions.

Overall Project Plan is a bit grandiose at this point to go into here, but testing multiple platforms to see where pieces can work together. One key piece here is requirement to maintain network connection and failover to hotspot or other network connection capability if network/internet unavailable. The lack of high speed wireless connection may kill this as

Finding the wired/wireless connections interesting as it appears both are 'active' on the base when Ethernet is plugged in.
ifconfig show both eth0 and wlan0 connected with 2 different addresses on base configuration - which would be good. Obviously 2 different network chips/services.

All input would be appreciated....
Hi DragProt

Thanks for the update.
If VNC and SSH are not working then either Hostapd is not working or the autohotspot script has not run.
The IP is set in the autohotspotN script so if that isn't available then it also suggest the above.

It does seem odd that you are having the same issue with multiple installs.

The installer checks various things are installed ok but can you do some manual checks.

run the autohotspot script manually sudo /usr/bin/autohotspotN
this should tell you its connected to a network.
then change rename your routers ssid in /etc/wpa_supplicant/wpa_supplicant.conf to an unknown ssid so your router is not found.
and run the autohotspotN script again.

You will get feedback as it does the switch.
If no errors then check hostapd is running

sudo systemctl status hostapd, it should say
Active: active (running) in the response.

Let me know what response you get.

for route you should get a default when you are connected to your router and the hotspot but we will deal with the above first.

There will be a separate ip for wifi and eth0 in both setups so you will be able to ssh through eth0 while wifi plays up.

Nothing else in your setup looks to like it would be an issue.

you are welcome to email admin at this site.
An no you are not spamming me I generally answer in the evenings :)
OK. All working on Base PI running 64bit OS. Now back to test on previous setup.
Getting a better understanding of why. So, unless I have a wired connection, there will be no internet even with 2 Wireless adapters. I'll need to work on that as can only use wireless for my project.
Client connection did get assigned correct IP so was able to connect through wireless and get to internet with Ethernet plugged in.
One caveat to this - the second USB WiFi adapter was no longer available on the menu bar, but does show in ifconfig. Can switch default Pi WiFi to any WiFi network now, but unable to associate USB WiFi to a network at all. wlan1 shows in menu pop-up as "Not Associated", but will no longer allow me to associate in menu as I was able to before loading Autohotspot. Further digging obviously required here....
Hi DragProt

I'm glad you have it all working now.
The setup is designed to get internet through an Ethernet cable for the devices connected to the wifi. So the script can detect if you are connected to a router, wifi is only available for 1 wifi device. This can be changed to wlan1 by changing some of the config but only 1 wifi device will be available.

The permanent hotspot can be reconfigured to run through two wifi devices but currently not the Autohotspot scripts.

I believe it is possible to rewrite some of the script and setup to use wlan0 and wlan1 rather than wlan0 and eth0 which is on my list of future updates but currently I have not looked at that.

If you want to know how to use wlan1 instead of wlan0 let me know but it sounds like it's not quite what you need unfortunately.
Thanks... getting me a bit further. Appreciate all the help.
Just as another little side note. After the installation of this, you can not change the network options in raspi-config to add an additional network device or attach an additional network device to the network. While wlan1 is seen by the system, attempted changes result in "Could not communicate with wpa_supplicant".
HI Dragprot

While the hotspot is active wpa_supplicant is disabled otherwise it would conflict with the hotspot and override it.
You can add a new network, ssid, with option 5. Otherwise you have to switch back to network wifi, presuming your router is in range with option 6, and wpa_supplicant will be available again.

When network is available wlan1 and other devices will be available again and disabled during the hotspot.
Lots of thanks for sharing your script. I tried it this morning and it works great! Something I noticed, however, and wanted to ask if it’s normal or if I did something wrong is thE boot time. Boot Time on my zero w is now considerably longer. The script alone adds about 25 seconds. Does this happen to you too?
Hi coldnpale, The boot time can be slower on some setups. The autohotspot service starts once they system is fully up. Normally wifi would be available once the network devices are ready. So if you have another app that is slow to load but allows you to use the Pi you may notice it but then the script loads after.

What you can do is change the service so it starts once the network is available which is earlier in the boot sequence. This may not be suitable for everybody but could be fine for you.

I don't know which script you are using, but I presume the direct version.

in /etc/systemd/system/autohotspot.service

change to

Description=Automatically generates an internet Hotspot when a valid ssid is not in range


Description=Automatically generates an internet Hotspot when a valid ssid is not in range

Then after you reboot it should come up a bit quicker.

This is down to the OS on the SD card as I have a setup that is slower than others run on the same Pi

Let me know if you have any issues.
Hi - The script worked great. I chose option 2.

I changed the IP to be, modified the dhcp range, SSID and password. I need to add a second IP static IP address to the wifi of How can this be done?

Thank you
Hi Dale,

You can set a static IP for when it is connected to your router by adding the ip address to /etc/dhcpcd.conf

interface wlan0
static ip_address=

For the access point, wlan0 in dhcpcd.conf is disabled, so those settings will then be ignored. wlan0 control is moved to /etc/dnsmasq.conf and the autohotspot script. I don't believe you can set a second IP address for the access point. If this is what you are after can you give me more detail of what you are trying to set up please.
Thanks for the quick reply.

I want to add a secondary IP to the interface. Similar to how you can add multiple IPs to eth0 like:
ip address add dev eth0

These are for IoT devices. When activated for the first time they look for instructions from IP port xxxx.
Hi Dale

That's not something I have looked at before but can be done. In the /usr/bin/autohotspot script where you changed the ip address, add the new IP to the line underneath.

echo "Creating Hotspot"
ip link set dev "$wifidev" down
ip a add brd + dev "$wifidev"
ip a add dev "$wifidev"
ip link set dev "$wifidev" up
dhcpcd -k "$wifidev" >/dev/null 2>&1
systemctl start dnsmasq
systemctl start hostapd

This will make both IP's available for the access point.

You will not be able to use option 6 on the installer to force the hotspot as that option gets the ip from the first ip line of the autohotspot script.

It will work fine when the pi is booted out of the range of your router.
alternately when your in range of your router, change the ssid in /etc/wpa_supplicant/wpa_supplicant.conf from network={

to network={

and reboot or run sudo /usr/bin/autohotspot
Thanks for this. I used option 2 to create the access point on my Raspberry Pi model B+ with the Pi Hut wifi dongle. I can now drive my Lego mounted zoom lens while streaming Raspivid to my laptop with zero lag compared to nearly 20 seconds lag via my home router.
Hi Dan,
You're welcome, Thanks for the feedback. I'm glad you have found it useful.
hi, i add this at begin of your script to have ever hotspot while eth0 connected on local lan


myeth0=$(ifconfig eth0 | grep inet | tr -s " " | cut -d " " -f 3)

if [ "$myeth0" = $myipeth ]; then
echo "eth0 connected: set hotspot"
ip link set dev "$wifidev" down
ip a add "$myiphot" brd + dev "$wifidev"
ip link set dev "$wifidev" up
dhcpcd -k "$wifidev" >/dev/null 2>&1
systemctl start dnsmasq
systemctl start hostapd

echo "eth0 not found: coninue to autohotspot"

ps: thank you for your script, it working very good

Thank you for sharing your modification.
Thank you for this, Worked perfectly on my PizeroW robot on the 1st try. Been looking for an easy way to do this for awhile.
Hi Jeff

You're welcome, Thanks for the feedback, i'm glad it's useful to you.
For me, the ideal would have 4 options, 1. Change Network settings. 2. Change hotspot settings 3. Use Network 4. Use Hotspot. After an initial setup, you don't ever need 1 or 2 again unless you change something. The automatic feature might be nice where if on power up, it sees no listed network, it goes into hotspot mode from the saved hotspot settings. But when at home, you could override the network wifi mode, test something as a hotspot, and then go back to the network and have it login again to your home wifi. Would it be hard to get the script to do that? I've been trying to learn the scripting language and all network services and settings, but it has been difficult. It is 700 lines of code in a new language. The bottom line for me is to try to prevent a user from having to do anything other than select a simple option. So it needs to be able to create a network or scan for one to enter as the default network, it can't have them open a text file manually and try to enter settings for a previously known network. I'll keep playing in the code. Thanks again!
Hi Fred

The intention of the script is to install and setup the access point and autohotspot scripts guides found on this site. An alternative option to working through the guide with a few extra features for testing and changing basic settings. It is not intended as a script you would use regularly.

I wrote the script for my own use as I don't want a permanent access point but would like one when im out just to access the Pi.

Using a cron timer it is able to switch between network and access point as it moves in out of range of a router.

Option 6 to force the switch back and forth between access point and Network. The script can't do it automatically as it will always check if the router is range, so never go to a hotspot. So this is the only way to force the access point at home.

You say:
"So it needs to be able to create a network or scan for one to enter as the default network, it can't have them open a text file manually and try to enter settings for a previously known network."

I'm not clear on what you mean here.

If it finds no know wifi network it will create an access point. If you are in a location where there is a wifi network you want to use, you can use option 5, select the wifi ssid in the list and add the password. Then use option 6 to connect to the new network.

The future option that will be added is when it is in Access Point mode it will serve a webpage that these settings can be changed in.

If you email me more details of what the issue is I can tell you if it is possible and what needs changing.
Sorry, I re-read and looked at the script. I see it can switch back and forth. So my only real question is how not to obliterate the existing AP setting. Or do I just write down the ID, PW and IP and put that in the script?
Nathan, I did have another question. I have an image that has all sorts of things setup on it, VNC, SSH, etc. It also comes setup with a working hotspot (AP). It has no networking setup yet. Can the script keep the existing settings for the AP and then add networking to find my home network when at home? And lastly, if I am home, but want to connect to the AP instead and then switch back, can I do it?
Hi Fred

The Autohotspots for option 1 & 2 wouldn't work with an existing Access Point as the some of the access point setting are needed in the script. If you need a specific ip address setup then the dhcpc-range in dnsmasq needs to be changed along with the IP address in the autohotspot/N script.

You also can't set access point settings in dhcpcd.conf as they won't be used only network settings can be set there.

It really depends on what you are trying to achieve.
why if i install openvpn, the connection is not accessible?
Hi Omar

It depends on what you have setup and which mode it is in. If you have the Autohotspot setup and connected to your router via WiFi then it should work fine. If the autohotspot is in Hotspot mode with an ethernet connection or you are using the static hotspot then as far as I know VPN needs additional routing for Devices connected to the hotspot. The Pi should itself be using the VPN just not connected devices.

It is possible, if this is your issue, but I don't have VPN access to see what is required.
I really like your script. This is fantastic. I've wasted hours on this problem with less skill than you and so things go a lot slower :) I really really want to connect a second wireless card to connect to a network. I'm not using eth0, I just want the Pi to be able to access the internet through wlan1, and an AP hosted on wlan0. The idea being that I can login and administer the Pi through ssh and VNC but I don't need it to pass internet through to wlan0. Could you point me in the direction of the best way to accomplish this with your fantastic code. I'm going to plug in and try and just direct connect, or install wicd and try and use that to connect wlan1 to a network.
Hi Nathan. Thanks, i'm glad you found it useful.

A wlan0 to Wlan1 setup can only be done on the Permanent Hotspot (option 3) as the Autohotspots (option 1 & 2) shutdown the network wifi to work. This will make wlan1 unavailable to connect to your router.

For the Permanant Hotspot only:
in /etc/dhcpcd.conf replace all the lines under RaspberryConnect with

denyinterface wlan0
interface wlan0
static ip_address=
nohook wpa_supplicant wlan0

This will allow wlan1 to be used alongside the permanent hotspot.
then in /etc/iptables-hs
replace the eth0 entries with wlan1

It looks like wicd is a network manager which won't work with the autohotspot scripts either as they work with dhcpcd only. I don't know if it will work with the permanent hotspot though.

I plan to add wlan1 support for the permanent hotspot and also see if the autohotspots can be adapted to do that as well at a later date.
Thanks again, that solution worked beautifully. I was hoping to make one refinement: I would like to route traffic from localhost/wlan0 to eth0 if eth0 is connected, otherwise to wlan1.

I think this is accomplished mainly through /etc/iptables-hs

iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE
iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan0 -o wlan1 -j ACCEPT

should this be changed to:
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE
iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan0 -o wlan1 -j ACCEPT
This is really helpful and very well done, thanks!
Page states:
ssh pi@
code uses
I believe there is a bug in the /Autohotspot/config/hostapd file. This line:
should be:
Hi Andy
Thanks for pointing those out. The /default/hostapd file is not required in Buster so didn't show up. I presume you are using Stretch. That's fixed now.
I found the VNC line was 50.10 instead of 50.5 on option1 guide, so I presume that's what you mean. The others look fine. Thanks.
50.10 is showing on this page under the "Option 3" heading.
Hi Andy
that's correct for option 3. The static Hotspot is 50.10. The Auto with net is 50.5 and the auto direct is 0.5.
It's so I can tell them apart when using them and when people ask questions :)

You're welcome, Thanks
error in /Autohotspot/config/hostapd
Not fixed. Checksum error if I try to change it.
error in /Autohotspot/config/hostapd
Hi Rob

Thanks I see it is back in the zip file again, the versions on my PC seem to be correct. The hostapd file is not used in Buster or Bullseye it is just needed for older OS's so it shouldn't be causing much of an issue now but I will update it once I check my source folders.

The config folder on github has the correct hostapd version and checksum file. The link is in the Requirements section. You can copy that over your config folder to get it working.