Yeah, We got Pi!
  page01| page02| page03| page04| page05| page06| page07| page08| page09| page10

Pi Wireless Access Point

I need to make this section clearer and tidier.

  1. udhcpd - Dhcp server to assign client ip addresses on the network.
  2. hostapd - Puts the wireless interface in to AP mode.
  3. routing - Iptables to route traffic between interfaces.
Firstly we configure the dhcp server and assign a static IP address.
sudo apt-get install hostapd udhcpd
sudo vi /etc/udhcpd.conf

start # Served IP range.
interface wlan0 # The inerface uDHCP listens on.
remaining yes
opt dns # The DNS servers client devices will use.
opt subnet
opt router # The Pi's wlan0 IP.
opt lease 259200 # 3 days DHCP lease time in seconds

save and close.

sudo vi /etc/default/udhcpd
add a hash to comment the line as shown below:-
save and close

sudo vi /etc/network/interfaces
delete "iface wlan0 inet dhcp" and replace with :-

iface wlan0 inet static
  address  # your choice of AP IP.

In the same file, add hashes to comment the lines as shown below:-

#allow-hotplug wlan0
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
#iface default inet dhcp
save and close.

Next we configure the access point.
If in a busy wifi area, we can survey the local networks and choose a quieter or lesser used wifi channel between 1 and 11 using :-

sudo iwlist wlan0 scan | less
now we configure the AP software.
sudo vi /etc/hostapd/hostapd.conf
channel=6   # find a quiet or lesser used channel

save and close.

sudo vi /etc/default/hostapd
change #DAEMON_CONF="" to:-
save and close

Next we configure the routing between the interfaces.
This is not the best config and needs to be refined but it does work.

sudo vi /etc/sysctl.conf
add the following to the bottom of the file to enable forwarding in the kernel:-
save and close

run the following routing commands in the shell:-

sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

then save this config using :-

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
sudo vi /etc/network/interfaces
add the following line to the botom of the file to restore on boot.:-

up iptables-restore < /etc/iptables.ipv4.nat

finally run the following two lines to enable the daemons on boot:-

sudo update-rc.d hostapd enable
sudo update-rc.d udhcpd enable
... and very finally:-
sudo shutdown -rF now
to restart your access point.
You should be able to view who is connected using :-
© 2017 Outanet Ltd.