-
-
Save Lauszus/47e673e60e7f15d41f5c8b680abefe9e 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 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 Interface: " WLAN # wlan0, wlan1 etc | |
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 | |
# ====================== | |
# | |
# STATIC IP / BRIDGE | |
# | |
save_original /etc/dhcpcd.conf | |
exc patch /etc/dhcpcd.conf <<EOT | |
@@ -55,3 +55,5 @@ | |
#interface eth0 | |
#fallback static_eth0 | |
+interface $WLAN | |
+ static ip_address=192.168.1.1/24 | |
EOT | |
# Not necessary, but in case someone needs it: | |
# BRIDGE | |
# | |
#save_original /etc/network/interfaces | |
# exc patch /etc/network/interfaces <<EOT | |
#@@ -5,3 +5,8 @@ | |
# | |
# # Include files from /etc/network/interfaces.d: | |
# source-directory /etc/network/interfaces.d | |
#+ | |
#+# Bridge setup | |
#+auto br0 | |
#+iface br0 inet manual | |
#+bridge_ports eth0 wlan1 | |
#EOT | |
# | |
# ACCES POINT | |
# | |
save_original /etc/hostapd/hostapd.conf | |
exc patch /etc/hostapd/hostapd.conf <<EOT | |
@@ -0,0 +1,16 @@ | |
+interface=$WLAN | |
+driver=nl80211 | |
+ssid=$APName | |
+hw_mode=g | |
+channel=6 | |
+macaddr_acl=0 | |
+auth_algs=1 | |
+ignore_broadcast_ssid=0 | |
+wpa=2 | |
+wpa_passphrase=$WIFIPASS | |
+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 | |
+wmm_enabled=1 | |
+ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40] | |
EOT | |
save_original /etc/default/hostapd | |
exc patch /etc/default/hostapd <<EOT | |
@@ -7,7 +7,7 @@ | |
# file and hostapd will be started during system boot. An example configuration | |
# file can be found at /usr/share/doc/hostapd/examples/hostapd.conf.gz | |
# | |
-#DAEMON_CONF="" | |
+DAEMON_CONF="/etc/hostapd/hostapd.conf" | |
# Additional daemon options to be appended to hostapd command:- | |
# -d show more debug messages (-dd for even more) | |
EOT | |
# | |
# DHCP-SERVER | |
# | |
save_original /etc/dnsmasq.conf | |
exc patch /etc/dnsmasq.conf <<EOT | |
@@ -668,3 +668,6 @@ | |
# 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=$WLAN # Use the require wireless interface - usually wlan0 | |
+ dhcp-range=192.168.1.2,192.168.1.20,255.255.255.0,24h | |
EOT | |
# | |
# 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 | |
# Not necessary, but in case someone needs it: | |
# BRIDGE | |
# | |
# sudo brctl addbr br0 | |
# sudo brctl addif br0 eth0 | |
sudo systemctl enable hostapd | |
sudo systemctl enable dnsmasq | |
sudo systemctl start hostapd | |
sudo systemctl start dnsmasq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment