Skip to content

Commit

Permalink
NFtables update for PiOS Bullseye
Browse files Browse the repository at this point in the history
  • Loading branch information
RaspberryConnect committed Feb 2, 2022
1 parent c9ea6b5 commit 26a0f57
Show file tree
Hide file tree
Showing 26 changed files with 359 additions and 264 deletions.
Binary file removed AutoHotspot-Setup.tar.gz
Binary file not shown.
Binary file added AutoHotspot-Setup.tar.xz
Binary file not shown.
8 changes: 7 additions & 1 deletion AutoHotspot-Setup/Autohotspot/ChangeLog-Autohotspot-Setup.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
Change log for autohotspot-setup.sh

0.74
added nft table support for PiOS Bullseye
fixed clipped country code in hostapd.conf if wpa_supplicant created on Windows
code cleanup
upated text and instructions

0.73
Added indents to the child functions in the Forceswitch function.
In dhcpcd.conf for the static Hostspot setup, moved nohooks below the interface wlan0 line
Now only wlan0 is blocked from using wpa_supplicant.conf. Wlan1 can be used to connect to a network but will
not give hotspot connected devices access to the internet. The pi will have network access through wlan1.
not give hotspot connected devices access to the internet. The pi will have wifi network access through wlan1.

0.72
Updated improved handeling of Windows special characters for updating the SSID and Password
Expand Down
4 changes: 4 additions & 0 deletions AutoHotspot-Setup/Autohotspot/ChangeLog-Autohotspot.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Change log for autohotspot and autohotspotN scripts

version 0.97-N/HS-I
added nfttables support for PiOS 11 Bullseye or if nftables are used on Buster.


version 0.961-N/HS-I & version 0.961-N/HS
-Added improved handeling of windows end of line special characters in wpa_supplicant.conf from users who create the file on windows
-Modify ssid handeling for checking. If the ssid contained bash command character treat them as a string and not a command.
Expand Down
93 changes: 47 additions & 46 deletions AutoHotspot-Setup/Autohotspot/ReadMe.txt
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
RaspberryConnect.com
This installer script, the autohotspot and autohotspotN scripts can be shared and modified but all references to RaspberryConnect.com must be kept in place.
This installer script and the autohotspot & autohotspotN scripts can be shared and modified but all references to RaspberryConnect.com must be kept in place.


AutoHotspot Setups:
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 Hotspot/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.
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 access point when a known wifi network is not in range.
This can also be run manually or with a timer to switch between a WiFi network or a WifI access point without a reboot.

This is available in two setups:
1: Internet access available for connected devices when a Ethernet cable is connected for the Raspberry Pi's 3A,3B,3B+ & 4. For Rapberry Pi's A,B, B+,& 2 if an usb Wifi adapter is used.
There are two setups available:
1: Network/Internet access available for connected devices when an ethernet cable is connected for the Raspberry Pi's 3A,3B,3B+ & 4. For Rapberry Pi's A,B, B+,& 2 if an usb Wifi adapter is used.
2: No internet access for connected devices. Designed for the Raspberry Pi Zero W or other Raspberry PI's where only a direct connection to the PI from a phone, tablet or Laptop is required.

There is also setup for permanent hotspot with internet access for connected devices.
There is also a setup for permanent access point with network/internet access from eth0 for WiFi connected devices.

For more information and for the manual setup's see:
https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/157-raspberry-pi-auto-wifi-hotspot-switch-internet
https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/158-raspberry-pi-auto-wifi-hotspot-switch-direct-connection
https://www.raspberryconnect.com/projects/65-raspberrypi-hotspot-accesspoints/168-raspberry-pi-hotspot-access-point-dhcpcd-method

This script will install any of these three setups or allow you to change between setup types.
In addition the Hotspot SSID and Password can be changed, new WiFi networks can be added to the Raspberry PI while in Hotspot Mode. The Pi can be forced between Network mode and Hotspot mode without a reboot. Also there is an uninstaller.
In additionm the Access Point SSID and Password can be changed, new WiFi networks can be added to the Raspberry PI while in access point mode. The Pi can be forced between WiFi Network mode and Access Point mode without a reboot. Also there is an uninstaller.

To use the installer:

Download the AutoHotspot-Setup.tar.xz archive from
curl "https://www.raspberryconnect.com/images/hsinstaller/AutoHotspot-Setup.tar.gz" -o AutoHotspot-Setup.tar.gz

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

open a terminal screen and navigate to the Autohotspot folder. If this is in your home directory then use
open a terminal window and navigate to the Autohotspot folder. If this is in your home directory then use
cd Autohotspot
if this is your desktop then use
cd ./Desktop/Autohotspot
Expand All @@ -37,74 +39,73 @@ This script will fail if sudo is not used.

You will presented with a menu with these options

1 = Install Autohotspot with Internet for Connected Devices
2 = Install Autohotspot with No Internet for connected devices
3 = Install a Permanent Hotspot with Internet for connected devices
4 = Uninstall Autohotspot or Permanent Hotspot
5 = Add or Change a WiFi network (SSID)
6 = Autohotspot: Force to a Hotspot or Force to Network if SSID in Range
7 = Change the Hotspots SSID and Password
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 Internet 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 hotspot.
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 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 hotspot access to the internet or local network.
Once a connection to the hotspot has been made you can access the Raspberry Pi via ssh & VNC with
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 [email protected]
vnc: 192.168.50.5::5900
for webservers use http://192.168.50.5/

Option 2: Install Autohotspot with No Internet for connected devices
This option is similar to option 1 but connected devices have no internet connection if an ethernet cable is connected.
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 hotspot SSID will be RPiHotspot with a password of 1234567890
Once a connection to the hotspot has been made you can access the Raspberry Pi via ssh & VNC with
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 [email protected]
vnc: 10.0.0.5::5900
for webservers use http://10.0.0.5/

Otion 3: Install a Permanent Hotspot with Internet for connected devices
This is for a permanent WiFi hotspot with internet access for connected devices.
The Raspberry Pi will only have network or internet access when an ethernet cable is connected.
Once a connection to the hotspot has been made you can access the Raspberry Pi via ssh & VNC with
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 [email protected]
vnc: 192.168.50.10::5900
for webservers use http://192.168.50.10/

Additional setup is required if you wanted to use a second WiFi device to connect to the internet rather than a ethernet conection. This will be a future option.
Additional setup is required if you wanted to use a second WiFi device to connect to a network or internet rather than a ethernet conection.
This requires changing the references in the iptables or fftables files from eth0 to wlan1
/etc/iptables-hs (PiOS version 10 or lower , Buster)
/etc/nftables/nft-stat-ap.nft (PiOS version 11 or higher, Bullseye)

Option 4: Uninstall Autohotspot or Permanent Hotspot
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.

Option 5: Add or Change a WiFi network (SSID)
If you are using either of the autohotspot setups in hotspot modes 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 ,see below.
This option only works for WiFi networks where only a password is required. If a username is required this will not work. (Future update)
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 a Hotspot or Force to Network if SSID in Range
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 hotspot mode and will ignore your home network untill the next reboot. If you use this option again while in hotspot mode it will attempt to connect to a known network. This will go back to the hotspot if no valid WiFi network is found or there is a connection issue.
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 Hotspots SSID and Password
By default the hotspot ssid is RPiHotSpot with a password of 1234567890. Use this option to change either or both SSID and Password.
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.


NFtables Warning.
This setup uses iptables for routing the Hotspots to the internet, options 1 & 3. From Raspbian 10 Buster, IPtables are depreciated in place of NFtables. By default NFtables will handle IPtable rules.
If you know you are using NFtables for a Firewall or other routing rules then don't use the internet routed hotspots and only use option 2, Autohotspot without internet. Otherwise there will be a conflict with your routing tables.
NFtables will be implemented shortly in the next main update of the installer and scripts.
Raspbian Stretch (9) & Jessie (8) only use IPtables.
You will be warned when you initally run the installer script if NFtables are active.

/etc/network/interfaces file:
many older hotspot and network setup guides online add entries to the /etc/network/interfaces file. This file is depreciated in Raspbian and 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.
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.

RaspberryConnect.com

Jan 29th 2022
Loading

0 comments on commit 26a0f57

Please sign in to comment.