Ath9k as AP in Arch Linux
I have a Macbook with an Atheros AR5008 wireless network adapter, which is supposed to be able to act as an AP. Some time ago I used Madwifi driver for it. It includes a tool that can create multiple “virtual adapters” and I could use one as an AP to share either my wired or wireless network. However now I use the stock ath9k
driver in the kernel, and I need my Macbook to share its PPP connection wirelessly with my iPhone. It is claimed that ath9k
has the ability to put my adapter into master mode, but I could not just do iwconfig wlan0 mode Master
to get it.
After some research, it looked like to me that ath9k
did that by implementing the hostap
driver, which was utilized by the hostapd
program. Then I found this document, that described all that was needed to be done. I do not need DHCP, so that falls into four steps.
- Set up my wireless adapter, my PPP interface has IP address like 118.207.x.y, so I can safely use 192.168.1.0/24 as my wireless LAN IPs.
# ifconfig wlan0 192.168.1.1 netmask 255.255.255.0
- Config
hostapd
by editing/etc/hostapd/hostapd.conf
. Change interface and SSID. Then starthostapd
daemon by
# /etc/rc.d/hostapd start
- Enable IP forwarding by
# echo 1 > /proc/sys/net/ipv4/ip_forward
then optionally make it permanent by editing /etc/sysctl.conf
and setting net.ipv4.ip_forward
to 1
.
4. Actually forward IP packets with iptables
,
# iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE