Saturday, June 18, 2011

Turning your laptop into a wifi router

     It's been a long time since I have posted anything in english. Anyways, let me get to the point real quickly. I have two laptops and one wired connection through which I connect to the internet. So yesterday I turned one of my laptop into a wifi router and got both the laptops connected to internet.

If you search on google regarding 'turning your laptop into access point/router' you will find many ways to do it. Most of it describes it how to do it using command lines. Though, personally I am a big fan of command line, NetworkManager that comes with many linux distros makes it real easy.

What you do is the following. You can choose one laptop to be the mater ( which is going to be turned into a wifi router ) and another slave. At least these are the names I am going to use.

Connect the master to the wired network. I am assuming that you know how to get wired network working on your linux box. Once you have done this, it is really a piece of cake.

In master, click on NetworkManager symbol/applet ( usually sitting in the top-right corner ) and click on "Create New wireless network..". Choose an SSID(name) say "mynetwork". Choose a security mechanism ( say WEP 128bit ) and type in your key. You need to remember this key. That's it, your laptop is turned into a wifi router.

Now on the slave, it should show the wifi connection available by name "mynetwork". If it does not, go to nm ( NetworkManager) and go to "Connect to hidden  wireless network.." and provide the name "mynetwork" and the key that you have entered for the network. You should be good to go now.

What happens behind the scene is as follows. Master acts as a bootstrap server, dns server, gateway for the client. Hence, providing the client with an IP address and masquerading it to provide it connection to the outside world. Enables packet forwarding in the kernel ( "cat /proc/sys/net/ipv4/ip_forward" should show "1"). Checkout "sudo iptables -vL" and "sudo iptables -vL -t nat" in the master for more details. It provides dns service to the client through multicast dns without having to run a full fledged dns server. Routes are added into the routing table ( "sudo route") appropriately.

It does not matter if you do not understand the paragraph above. The good thing is that it has been made piece of cake for normal users and probably requires less amount of efforts than doing the same thing in windows.

Thing to note that you can connect multiple slaves to this masters. However, you may not get as good performance as a dedicated hardware router.

Happy networking!! :-)

1 comment:

Timmy.Norris said...

This is really great, I'll definitely give this a try. Thanks