d51e541e76b825adfa79f893dcd6d184379e29a2
[networtool-web.git] / script / startHostapd.sh
1 #!/bin/bash -xe
2
3 # This tool is to enable Hotspot mode on Raspberry Pi
4 # Refer https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md#internet-sharing
5
6 # disable WiFi connection
7 wpa_cli -i wlan0 disable_network 0 || true
8
9 # Stop dhcp cliennt, will start it with static IP and no wpa_supplicant
10 systemctl stop dhcpcd || true
11 killall dhcpcd || true
12
13 ip addr flush dev wlan0
14
15 # start Hostapd mode
16 systemctl start hostapd
17
18 # start dhcp client with static IP
19 dhcpcd --static ip_address=192.168.4.1/24 --nohook wpa_supplicant wlan0
20
21 # start dnsmasq, dns server with IP reanges
22 dnsmasq --interface=wlan0 --dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h