I'm using a laptop as a wifi access point. Since this laptop has the proper hardware, I was able to use hostapd. I wanted to use DHCP and iptables/NAT forwarding instead of a bridge to have more control over the connection. I made a script to execute all commands.
My devices are able to connect to the access point and have full access to the internet for the first few minutes. After this amount of time, no devices are able to connect to the access point anymore. The only way to re-establish a connection is if I reboot the laptop and relaunch the script.
Here is my script:
#!/bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
# Clear iptables Rules
iptables -F
iptables -t nat -F
# iptables Rules
iptables -A FORWARD -d 192.168.1.0/24 -o wlan0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -s 192.168.1.0/24 -i wlan0 -j ACCEPT
iptables -t nat -A POSTROUTING -o p4p1 -j MASQUERADE
# Set wlan0 IP
ip addr add 192.168.1.1/24 broadcast 192.168.1.255 dev wlan0
ip link set wlan0 up
# Set DHCP
dnsmasq -C /dev/null >/dev/null 2>&1 --listen-address=192.168.1.1 --dhcp-range=192.168.1.2,192.168.1.200,12h
# hostapd
hostapd /etc/hostapd/hostapd.conf
Where hostapd.conf has the following content:
ctrl_interface=/var/run/hostapd
ctrl_interface_group=wheel
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=3
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
wpa_passphrase=testomesto
driver=nl80211
interface=wlan0
hw_mode=g
channel=1
ssid=osumi-0
Additional information:
- Network hardware: Broadcom Corporation BCM4311 802.11a/b/g (rev 01)
- Network subsystem: Dell Wireless 1490 Dual Band WLAN Mini-Card
- Network driver: b43-pci-bridge
- OS: Fedora 17 (up to date)
Below is an image of an iPod showing correct IP and router information
