-
Notifications
You must be signed in to change notification settings - Fork 0
/
hostapd.txt
133 lines (117 loc) · 3.54 KB
/
hostapd.txt
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md
https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf
https://elinux.org/RPI-Wireless-Hotspot
https://github.com/billz/raspap-webgui
https://howtoraspberrypi.com/create-a-wi-fi-hotspot-in-less-than-10-minutes-with-pi-raspberry/
https://wiki.gentoo.org/wiki/Hostapd#802.11b.2Fg.2Fn_triple_AP
#-----------------------------------------------------
echo -e "192.168.1.1\tmalinka" | sudo tee -a /etc/hosts
sudo apt-get -y install dnsmasq hostapd
sudo systemctl stop dnsmasq ; sudo systemctl stop hostapd
IP="192.168.1.1"
IP_RANGE="192.168.1.200,192.168.1.250"
WSSID="Raspberry"
WPASSWD="12345678"
sudo cp -p /etc/dhcpcd.conf /etc/dhcpcd.conf.orig
#Configuring a static IP
echo -e "interface wlan0\n static ip_address=${IP}/24" >> /etc/dhcpcd.conf
#Configuring the DHCP server (dnsmasq)
echo -e "interface=wlan0\n dhcp-range=${IP_RANGE},255.255.255.0,24h" | sudo tee /etc/dnsmasq.d/dhcp.conf
cat << EOF | sudo tee /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
channel=11
ssid=${WSSID}
wpa_passphrase=${WPASSWD}
macaddr_acl=0
hw_mode=g
auth_algs=1 # 1=wpa, 2=wep, 3=both
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
ieee80211n=1 # 802.11n support
wmm_enabled=1 # QoS support
obss_interval=300
ht_capab=[SHORT-GI-20][DSSS_CCK-40]
EOF
sudo sed -i '/#DAEMON_CONF/ s/#//; /DAEMON_CONF/ s|="|="/etc/hostapd/hostapd.conf| ' /etc/default/hostapd
#delete all settings from /etc/wpa_supplicant/wpa_supplicant.conf
sudo sed -ni '/network/q;p' /etc/wpa_supplicant/wpa_supplicant.conf
sudo systemctl unmask hostapd
sudo systemctl disable hostapd
-------------------------------------------------------------------
#Wi-Fi + router setup
[ -d /etc/local ] || sudo mkdir /etc/local && sudo chown pi.pi /etc/local
sudo chmod 760 /etc/local
echo "Enter your name and press [ENTER]: "
read WSSID
cat << EOF | sudo tee /etc/hostapd/cw.conf
driver=nl80211
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
beacon_int=100
ssid=${WSSID}
channel=11
hw_mode=g
ieee80211n=1
wme_enabled=1
interface=wlan0
wpa=none
ignore_broadcast_ssid=0
EOF
cat << EOF | sudo tee /etc/hostapd/nw.conf
driver=nl80211
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0
auth_algs=1
wpa_key_mgmt=WPA-PSK
beacon_int=100
ssid=Raspberry
channel=11
hw_mode=g
ieee80211n=1
wme_enabled=1
wpa_passphrase=12345678
interface=wlan0
wpa=2
wpa_pairwise=CCMP
ignore_broadcast_ssid=0
EOF
cat << EOF > /etc/local/cwe.sh
#!/bin/bash
#chromecast wifi enable
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo sysctl -w net.ipv4.ip_forward=1
sudo systemctl stop hostapd ; sleep 5 ; sudo cp -p /etc/hostapd/cw.conf /etc/hostapd/hostapd.conf ; sudo systemctl start hostapd
EOF
chmod +x /etc/local/cwe.sh
cat << EOF > /etc/local/cwd.sh
#!/bin/bash
#chromecast wifi disable
sudo iptables -F POSTROUTING -t nat
sudo sysctl -w net.ipv4.ip_forward=0
sudo systemctl stop hostapd ; sleep 5 ; sudo cp -p /etc/hostapd/nw.conf /etc/hostapd/hostapd.conf ; sudo systemctl start hostapd
EOF
chmod +x /etc/local/cwd.sh
cat << EOF > /etc/local/rs.sh
#!/bin/bash
echo "Router start"
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo sysctl -w net.ipv4.ip_forward=1
EOF
chmod +x /etc/local/rs.sh
cat << EOF > /etc/local/we.sh
#!/bin/bash
#persistent wi-fi enable
sudo systemctl start hostapd
sudo systemctl enable hostapd
EOF
chmod +x /etc/local/we.sh
cat << EOF > /etc/local/wd.sh
#!/bin/bash
#persistent wi-fi disable
sudo systemctl stop hostapd
sudo systemctl disable hostapd
EOF
chmod +x /etc/local/wd.sh