Install Hostapd On Rpi
List all enabled services.
systemctl list-unit-files | grep enabled
List all running services.
systemctl | grep running
Get sshd to start on boot as it is disabled by default
sudo systemctl enable ssh.socket
Get dhcpd to stop on boot as it need more time to boot
sudo systemctl disable dhcpcd.service
Install hostapd
1 | git clone https://github.com/lostincynicism/hostapd-rtl8188 |
Add following lines to /boot/my-hostapd.sh file
1 |
|
For ip configuration, it is more applicable to update /etc/network/interfaces
file, but for Jessie Debian, it needs to disable dhcpd first refering to http://raspberrypi.stackexchange.com/questions/37920/how-do-i-set-up-networking-wifi-static-ip-address and https://www.raspberrypi.org/documentation/hardware/raspberrypi/bootmodes/net_tutorial.md
1 | sudo systemctl disable dhcpcd |
1 | auto lo |
Settings in /boot/hostadp.8188eu.conf
1 | interface=wlan0 |
Settings in /lib/systemd/system/hostapd.service as below
1 | [Unit] |
1 | sudo chmod 644 /lib/systemd/system/hostapd.service |
Check the hostapd.service
sudo systemctl status hostapd.service
Start/Stop/Restart the hostapd.service
1 | sudo systemctl start hostapd.service |
Run tmux in Ubuntu
options in /etc/wpa_supplicant/wpa_supplicant.conf
1 | ctrl_interface=/var/run/wpa_supplicant |
Notes
- In one pane, run
sudo wpa_supplicant -Dnl80211,wext -iwlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf
The option of ‘wext’ is the 8188eu driver for wpa_supplicant - In other pane, run
sudo wpa_cli
orsudo iwlist wlan0 scan
- iw command for “nl80211”, iwconfig/iwlist(wireless_tools) for “wext” (rtl871xdrv)
- wpa_supplicant - works with both wext and nl80211.
1
2
3iwconfig wlan0 => iw dev wlan0 link (Getting info on wlan0)
iwconfig wlan0 essid foo => iw wlan0 connect foo (Connecting to an open network)
iwconfig wlan0 essid off => iw wlan0 ibss leave (Leave an IBSS (ad-hoc network))
Install udhcpd
sudo apt-get install udhcpd
Settings in /etc/udhcpd.conf
1
2
3
4
5
6
7
8
9start 192.168.42.2 # This is the range of IPs that the hostspot will give to client devices.
end 192.168.42.20
interface wlan0 # The device uDHCP listens on.
max_leases 10
remaining yes
opt dns 8.8.8.8 4.2.2.2 # The DNS servers client devices will use.
opt subnet 255.255.255.0
opt router 192.168.42.100 # The Pi's IP address on wlan0 which we will set up shortly.
opt lease 864000 # 10 day DHCP lease time in secondsEnable dhcpd
#DHCPD_ENABLED="no"
in /etc/default/udhcpdStart service
1
2sudo systemctl restart hostapd.service
sudo service udhcpd restartCheck result
service udhcpd status
Or
cat /var/log/syslog | grep udhcpd
Get the udhcpd to start on boot
sudo update-rc.d udhcpd enable
Reference
http://www.raspberrypi-spy.co.uk/2015/10/how-to-autorun-a-python-script-on-boot-using-systemd/
https://wiki.archlinux.org/index.php/WPA_supplicant
https://wiki.archlinux.org/index.php/Wireless_network_configuration
http://elinux.org/RPI-Wireless-Hotspot