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.
===============================================

    Summary
  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 192.168.42.2 # Served IP range.
end 192.168.42.20
interface wlan0 # The inerface uDHCP listens on.
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.1 # 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:-
#DHCPD_ENABLED="no"
save and close

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

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

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
interface=wlan0
driver=nl80211
ssid=mynetworkname
hw_mode=g
channel=6   # find a quiet or lesser used channel
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=mynetworkpassphrase
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

save and close.

sudo vi /etc/default/hostapd
change #DAEMON_CONF="" to:-
DAEMON_CONF="/etc/hostapd/hostapd.conf"
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:-
net.ipv4.ip_forward=1
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 :-
dumpleases
...BACK<-->MORE...
 
    
© 2025 Outanet Ltd.