Last active
April 7, 2018 16:16
-
-
Save totti2/e59c1bbf5c2e5ea3c52dc36cf12c8276 to your computer and use it in GitHub Desktop.
Adding accesspoint-mode to SSRPARI's stretch-branch (found here: https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ``` | |
| #!/bin/bash | |
| if [ "$WIFIPASS" == "" ] | |
| then | |
| read -p "Wifi Network name: " APName | |
| read -p "Wifi Password: " WIFIPASS | |
| fi | |
| if [ -z "$exc" ] | |
| then | |
| source functions.sh | |
| source dependencies.sh | |
| fi | |
| sudo systemctl stop dnsmasq | |
| sudo systemctl stop hostapd | |
| # setup the config files | |
| save_original /etc/network/interfaces | |
| #exc cp etc/network/interfaces /etc/network/interfaces # depreciated in stretch | |
| # set static IP for wifi device | |
| save_original /etc/dhcpcd.conf | |
| #exc patch /etc/dhcpcd.conf <<EOT # worked without this patch | |
| #@@ -39,3 +39,4 @@ | |
| # # A hook script is provided to lookup the hostname if not set by the DHCP | |
| # # server, but it should not be run by default | |
| # nohook lookup-hostname | |
| #+denyinterfaces wlan0 | |
| exc patch /etc/dhcpcd.conf <<EOT | |
| @@ -55,3 +55,5 @@ | |
| #interface eth0 | |
| #fallback static_eth0 | |
| +interface wlan1 # wlan0 for internal wifi-device | |
| + static ip_address=192.168.1.1/24 | |
| EOT | |
| sudo service dhcpcd restart | |
| #save_original /etc/init.d/hostapd | |
| #exc patch /etc/init.d/hostapd <<EOT | |
| #@@ -16,7 +16,7 @@ | |
| # PATH=/sbin:/bin:/usr/sbin:/usr/bin | |
| # DAEMON_SBIN=/usr/sbin/hostapd | |
| # DAEMON_DEFS=/etc/default/hostapd | |
| #-DAEMON_CONF= | |
| #+DAEMON_CONF=/etc/hostapd/hostapd.conf | |
| # NAME=hostapd | |
| # DESC="advanced IEEE 802.11 management" | |
| # PIDFILE=/run/hostapd.pid | |
| #EOT | |
| # Setup AP | |
| save_original /etc/hostapd/hostapd.conf | |
| exc patch /etc/hostapd/hostapd.conf <<EOT | |
| @@ -0,0 +1,18 @@ | |
| +interface=wlan1 | |
| +driver=nl80211 | |
| +#ssid=$APName | |
| +ssid=BusFunk | |
| +hw_mode=g | |
| +channel=6 | |
| +macaddr_acl=0 | |
| +auth_algs=1 | |
| +ignore_broadcast_ssid=0 | |
| +wpa=2 | |
| +#wpa_passphrase=$WIFIPASS | |
| +wpa_passphrase=BassFank | |
| +wpa_key_mgmt=WPA-PSK | |
| +#wpa_pairwise=TKIP # You better do not use this weak encryption (only used by old client devices | |
| +rsn_pairwise=CCMP | |
| +ieee80211n=1 # 802.11n support | |
| +wmm_enabled=1 # QoS support | |
| +ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] | |
| EOT | |
| save_original /etc/default/hostapd.conf | |
| exc patch /etc/default/hostapd.conf <<EOT | |
| @@ -16,7 +16,7 @@ | |
| PATH=/sbin:/bin:/usr/sbin:/usr/bin | |
| DAEMON_SBIN=/usr/sbin/hostapd | |
| DAEMON_DEFS=/etc/default/hostapd | |
| -DAEMON_CONF= | |
| +DAEMON_CONF=/etc/hostapd/hostapd.conf | |
| NAME=hostapd | |
| DESC="advanced IEEE 802.11 management" | |
| PIDFILE=/run/hostapd.pid | |
| EOT | |
| # Setup dhcp server | |
| save_original /etc/dnsmasq.conf | |
| exc patch /etc/dnsmasq.conf <<EOT | |
| @@ -668,3 +668,7 @@ | |
| # Delays sending DHCPOFFER and proxydhcp replies for at least the specified number of seconds. | |
| dhcp-mac=set:client_is_a_pi,B8:27:EB:*:*:* | |
| dhcp-reply-delay=tag:client_is_a_pi,2 | |
| + | |
| +interface=wlan1 # Use the require wireless interface - usually wlan0 | |
| + dhcp-range=192.168.1.2,192.168.1.20,255.255.255.0,24h | |
| + | |
| EOT | |
| sudo systemctl start hostapd | |
| sudo systemctl start dnsmasq | |
| # Add routing and masquerade | |
| save_original /etc/sysctl.conf | |
| exc patch /etc/sysctl.conf <<EOT | |
| @@ -25,7 +25,7 @@ | |
| #net.ipv4.tcp_syncookies=1 | |
| # Uncomment the next line to enable packet forwarding for IPv4 | |
| -#net.ipv4.ip_forward=1 | |
| +net.ipv4.ip_forward=1 | |
| # Uncomment the next line to enable packet forwarding for IPv6 | |
| # Enabling this option disables Stateless Address Autoconfiguration | |
| EOT | |
| sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | |
| sudo sh -c "iptables-save > /etc/iptables.ipv4.nat" | |
| save_original /etc/rc.local | |
| exc patch /etc/rc.local <<EOT | |
| @@ -17,4 +17,5 @@ | |
| printf "My IP address is %s\n" "$_IP" | |
| fi | |
| +iptables-restore < /etc/iptables.ipv4.nat | |
| exit 0 | |
| EOT | |
| ``` |
My smartphone doen't get an IP when the Pi isn't connected to a LAN-internet-source
bridge-functions not needed
don't forget to add dnsmasq to the dependencies.sh
finished
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
code works - bridge-utils, hostapd and dnsmasq must be installed
AP does not work - hostapd crashes