forked from toolboc/psx-pi-smbshare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-wifi-access-point.sh
60 lines (52 loc) · 1.43 KB
/
setup-wifi-access-point.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
#
# psx-pi-smbshare setup-wifi-access-point script
#
# *What it does*
# This script will install and configure an external wifi dongle for access to XlinkKai & samba
# This allows for configuring devices without ethernet to have access to these services
# The default SSID name for the wifi network is XlinkKai
#
# Be sure to change the wpa_passphrase to a custom password
# Configure hostapd
sudo cat <<'EOF' | sudo tee /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
EOF
sudo cat <<'EOF' | sudo tee /etc/hostapd/hostapd.conf
interface=wlan1
#driver=nl80211
ssid=XlinkKai
hw_mode=g
channel=7
#ieee80211n=1
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=XlinkKai
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
EOF
# Configure dhcpcd
sudo cat <<'EOF' | sudo tee /etc/dhcpcd.conf
interface wlan1
static ip_address=10.254.0.1/16
nohook wpa_supplicant
EOF
# Configure dnsmasq
sudo cat <<'EOF' | sudo tee -a /etc/dnsmasq.d/custom-dnsmasq.conf
interface=wlan1
bind-dynamic
dhcp-range=10.254.0.2,10.254.0.100,12h
EOF
# Forward additional ports
#sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
sudo iptables -A FORWARD -i wlan0 -o wlan1 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -p ALL -i wlan1 -o wlan0 -j ACCEPT
# Restart services
sudo systemctl stop hostapd
sudo systemctl stop dnsmasq
sudo systemctl start hostapd
sudo systemctl start dnsmasq