Einrichten AccessPoint (180430) ====================== apt update apt upgrade sudo apt-get install hostapd ( zzgl. libnl-route-3-200, hostapd libnl-route-3-200 ) sudo apt-get install dnsmasq ( zzgl. dns-root-data dnsmasq-base libmnl0 libnetfilter-conntrack3 ) The installers will have set up the programme so they run when the pi is started. For this setup they only need to be started if the home router is not found. So automatic startup needs to be disabled. This is done with the following commands: sudo systemctl disable hostapd (warning: insserv: warning: current start runlevel(s) (empty) of script `hostapd' overrides LSB defaults (2 3 4 5). insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `hostapd' overrides LSB defaults (0 1 6). ) sudo systemctl disable dnsmasq (warning: insserv: warning: current start runlevel(s) (empty) of script `dnsmasq' overrides LSB defaults (2 3 4 5). insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `dnsmasq' overrides LSB defaults (0 1 6). ) Hostapd Configuration nano /etc/hostapd/hostapd.conf ----- begin interface=wlan0 ssid=RPI3hot hw_mode=g channel=9 wmm_enabled=0 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=Drdnfss13 wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP/usr/bin/autohotspot Enter this script. (last modified 30th May 2017) #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ss/usr/bin/autohotspot Enter this script. (last modified 30th May 2017) #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2')/usr/bin/autohotspot Enter this script. (last modified 30th May 2017) #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2') #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd }/usr/bin/autohotspot Enter this script. (last modified 30th May 2017) #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2')/usr/bin/autohotspot Enter this script. (last modified 30th May 2017) #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ss/usr/bin/autohotspot Enter this script. (last modified 30th May 2017) #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2') #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down/usr/bin/autohotspot Enter this script. (last modified 30th May 2017) #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2') #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down/usr/bin/autohotspot Enter this script. (last modified 30th May 2017) #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2') #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd }/usr/bin/autohotspot Enter this script. (last modified 30th May 2017) #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2')/usr/bin/autohotspot Enter this script. (last modified 30th May 2017) /usr/bin/autohotspot Enter this script. (last modified 30th May 2017) #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2') #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd } connected=false for ssid in "${ssids[@]}" do if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fi #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2') #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd } connected=false for ssid in "${ssids[@]}" do if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fi #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd } connected=false for ssid in "${ssids[@]}" do if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fi connected=false for ssid in "${ssids[@]}" do if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fi ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd } connected=false for ssid in "${ssids[@]}" do if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fi ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd } connected=false for ssid in "${ssids[@]}" do if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fiid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2') #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd } connected=false for ssid in "${ssids[@]}" do if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fi #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd } connected=false for ssid in "${ssids[@]}" do if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fi connected=false for ssid in "${ssids[@]}" do if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fi #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd } connected=false for ssid in "${ssids[@]}" do if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fiid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2') #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd } connected=false for ssid in "${ssids[@]}" do if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fi ----- end The interface will be wlan0 The driver nl80211 works with the Raspberry Pi 3 onboard WiFi but you will need to check that your wifi dongle is compatable and can use Access Point mode. The SSID is the name of the WiFi signal broadcast from the RPi, which you will connect to with your Tablet or phones WiFi settings. Channel can be set between 1 and 13. If you are having trouble connection because of to many wifi signals in your area are using channel 6 then try another channel. Wpa_passphrase is the password you will need to enter when you first connect a device to your Raspberry Pi's hotspot. Now the defaults file needs to be updated to point to where the config file is stored. In terminal enter the command sudo nano /etc/default/hostapd Change: #DAEMON_CONF="" to DAEMON_CONF="/etc/hostapd/hostapd.conf" And save. dnsmasq configuration Next dnsmasq need to be configured to allow the PI to act as a router and issue IP addresses. sudo nano /etc/dnsmasq.conf Go to the bottom of the file and add the following lines #Pi3Hotspot Config #stop DNSmasq from using resolv.conf no-resolv #Interface to use interface=wlan0 bind-interfaces dhcp-range=10.0.0.3,10.0.0.20,12h And then save Open the interfaces file with the command sudo nano /etc/network/interfaces edit the following lines as below auto lo wlan0 iface lo inet loopback allow-hotplug wlan0 iface wlan0 inet manual # wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf now save These details need to be in the wpa_supplicant.conf file to work with this setup. Add your router details to the wpa_supplicant.conf file with sudo nano /etc/wpa_supplicant/wpa_supplicant.conf and add the following commands to the bottom of the file. network={ ssid="mySSID" psk="Router Password" key_mgmt=WPA-PSK } chek you have iw installed with dpkg -s iw If it is not found then install it with sudo apt-get install iw This script will check what routers are available when the RPi. The first router found in the wifi settings will be connected to using existing configured WiFi settings. If no know routers are in range then a WiFi hotspot is created: ----- begin /usr/bin/autohotspot #!/bin/bash #RaspberryConnect.com #Wifi config - if no prefered Wifi generate a hotspot #This two lines check for any SSIDs in your RPi's wifi settings wpassid=$(awk '/ssid="/{ print $0 }' /etc/wpa_supplicant/wpa_supplicant.conf | awk -F'ssid=' '{ print $2 }' ORS=' ' | sed 's/\"/''/g') ssids=($wpassid) #or check a restricted list of SSID,s that are setup. #Put a # infront of the two lines above first; #ssids=$(awk..... & ssids=($wpassid) #Enter one or more ssids that are already setup in the wifi settings #Remove # below to use. separate SSIDs by a space, ('mySSID1' 'mySSID2') #ssids=('myssid1') #Main script createAdHocNetwork() { ip link set dev wlan0 down ip a add 10.0.0.5/24 dev wlan0 ip link set dev wlan0 up systemctl start dnsmasq systemctl start hostapd } connected=false for ssid in "${ssids[@]}" doThis script will check what routers are available when the RPi. The first router found in the wifi settings will be connected to using existing configured WiFi settings. If no know routers are in range then a WiFi hotspot is created. if iw dev wlan0 scan ap-force | grep "$ssid" > /dev/null then wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf > /dev/null 2>&1 if dhclient -1 wlan0 then connected=true break else wpa_cli terminate break fi else echo "Not in range, WiFi with SSID:" $ssid fi done if ! $connected; then createAdHocNetwork fi ----- end /usr/bin/autohotspot