Wednesday, June 18, 2008

And Linux is now a wireless AP router

I followed the instructions in the YoLinux article on making the Linux gateway ... and it works perfectly. The WORKIT AP now functions as a gateway router, instead of the bridge as it was earlier. (The LinuxJournal article mentioned in my previous post is a little old at this point.)

I just had to follow the instructions to set up the gateway. This is what I used for the WORKIT AP (eth0 is my wired WAN connection and ath0 is the wireless LAN):
   # Delete and flush. Default table is "filter". Others like "nat" must be explicitly stated.
# Flush all the rules in filter and nat tables
iptables --flush
iptables --table nat --flush
# Delete all chains that are not in default filter and nat table
iptables --delete-chain
iptables --table nat --delete-chain

# Set up IP FORWARDing and Masquerading
iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface ath0 -j ACCEPT

# Enables packet forwarding by kernel
echo 1 > /proc/sys/net/ipv4/ip_forward

Also, while instructions exist for both iptables and ipchains, you will find yourself using the iptables rules since ipchains was RIP after Linux 2.4 came out.

No comments: