add script of wifif config for raspberry pi
[dotfiles.git] / bin / 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 # start Hostapd mode
14 systemctl start hostapd
15
16 # start dhcp client with static IP
17 dhcpcd --static ip_address=192.168.4.1/24 --nohook wpa_supplicant wlan0
18
19 # start dnsmasq, dns server with IP reanges
20 dnsmasq --interface=wlan0 --dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h