« Audio transcription with vim and mocp | Main | 25c3: The future is already here - it is just unevenly distributed »

Create AP from any laptop with wifi and ethernet card

So, you have a laptop with wifi and enternet card and you want to make "real" AP from it. There are many ways to do this, but I like this one:

  1. Install packages required:
    apt-get install dnsmasq
    
  2. configure /etc/dnsmasq.conf to be DHCP server for your wifi network:
    listen-address=192.168.42.1
    dhcp-range=192.168.42.42,192.168.42.242,12h
    
  3. turn atheros card into master (AP) mode and configure new network 192.168.42.0/24 and setup masquarade:
    sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
    sudo wlanconfig ath0 destroy
    sudo wlanconfig ath0 create wlandev wifi0 wlanmode ap
    sudo iwconfig ath0 essid free4all
    sudo ifconfig ath0 192.168.42.1
    sudo iwconfig 
    sudo /etc/init.d/dnsmasq restart
    sudo iptables --flush  
    sudo iptables --table nat --flush
    sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    sudo iptables -A FORWARD -i eth0 -o ath0 -m state --state RELATED,ESTABLISHED -j ACCEPT
    sudo iptables -A FORWARD -i ath0 -o eth0 -j ACCEPT
    

And that's it. You have new 192.168.42.0/24 network on your wifi interface ath0 which is passed to eth0 (which you should configure beforehand using dhclient eth0 or someting similar). Bring wifi to every home in next year ;-)

Instructions here are specific for configuration with atheros wifi card (that's why I'm using wlanconfig to switch card in EeePC into AP mode). For other wifi cards which support AP mode via standard iwconfig the syntax is: iwconfig eth1 mode master. If you get error using this command, you might try with ad-hoc mode instead of "real" AP...

TrackBack

TrackBack URL for this entry:
http://blog.rot13.org/mt/mt-tb.cgi/607

Comments (3)

Benoit Author Profile Page:

Very good instruction. Could you tell me how you revert to 'normal mode', i.e. when I am at work, I would like my laptop to become an access point (as you instructed) but back home, I would like to use the wireless as a client to surf the net.

Ben Author Profile Page:

I have this set up and it is being picked up by my Dell machine running Vista but there is no internet on that end. I think the problem is that I have not properly configured eth0. Your last instruction about configuring eth0 with dhclient eht0 is not quite clear to me. Can you explain in detail how I should do this?
Thanks
Ben

I'm assuming that your eth0 is already configured, and that's why I'm suggesting dhclient eth0 to pickup all setting from DHCP server.

In short, if you have internet access using wired network on eth0, you can ignore dhclient eth0.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About

This page contains a single entry from the blog posted on December 30, 2008 10:59 PM.

The previous post in this blog was Audio transcription with vim and mocp.

The next post in this blog is 25c3: The future is already here - it is just unevenly distributed.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.