How to setup a home network with Internet sharing on Linux - Ubuntu/Fedora using Network Manager

Have you ever been in a situation where you are boasting about Linux in front of all your windower friends and then after getting bored of your long lecture someone asks you to shut up and create a network with shared Internet so that they can work on their sucky systems(according to you) atleast then, leaving you staring at the roof wondering, "how the hell is this done"? . If yes, then here is a solution. Next time(if you get any), don't forget to throw it on their faces - how easily and quickly could it be done on Linux.

Most people, even many linuxers, think that managing networks on Linux is like walking on a bed of nails. You need to have good linux networking and command skills. That's because they are not aware of the fact that the network manager makes it tremendously easy for a regular user, with minimal knowledge, to handle various such networks.

Scenario

  • You are connected to Internet through a wired network
  • You want to create a wireless home network with Internet sharing

Solution to setup Internet sharing on Linux

Just follow the steps below:

  • Right click on the network manager and click "Edit connections"

  • Since, we are going to create a wireless network, go to the wireless tab and click Add.

  • Write the name of the wireless network. Please note that this is the connection name(for you), not the name by which your WLAN will appear. Fill the ssid. This will be the WLAN's name(the name which will appear on other systems) and set the mode to AdHoc. Select connect automatically, if you want this network to be up everytime you switch on wireless network. Leave the other settings as it is.

  • Now, move to the wireless security tab and select the one you want. If its just a small home network (temporary) then there is no harm in using no security. But you are always recommended to use WPA type encryption, WEP can be easily broken.

  • Now, move to the "IPv4 setting" tab and set the mode to "Shared to other computers".

Now, hit apply and it should be automatically connected. If not, then left click on the network manager applet and click "connect to a hidden wireless network". Select your network from the list and it should connect now.

That's it. Now, try connecting other computers to this network and they should be able to access internet through this network.

10 Comments

Chris (not verified)
October 21st, 2010 02:21 am
I have followed the steps outlined, and the connection seems to be OK, i.e., the computer (no. 2) without the internet connection shows the SSID of the computer (no. 1) that is connected to the internet. But computer 2 still cannot access the internet.
October 21st, 2010 11:29 am

Are you able to connect properly, i.e. do you get an IP for your wireless interface? Check it by running "ifconfig <your_wirelessinterface>" e.g. ifconfig wlan0. Try running "ping google.com". Do you see any replies?

Chris (not verified)
October 21st, 2010 02:55 pm
2nd reply: I have now managed to connect computer 2 to computer 1 (connected to internet). When I run 'ping google.com' it seems that I get at least one-way communication: --- google.com ping statistics --- 18 packets transmitted, 0 received, 100% packet loss, time 16999ms
October 21st, 2010 05:48 pm

Hi Chris. The IP for 2nd computer shouldn't be 10.42.43.1(this is computer 1's IP). The first 3 parts of the IP(10.42.43) should be common to both (because it signifies the network) and the 4th part defining the uniqueness should be something other than 1 for 2nd computer, anything from 2 to 254.

If you are getting the expected IP on 2nd computer, could you check if you don't have any firewall configured on 1, which is stopping the connection. Try turning the firewall off or  if you don't use any specific firewall config then run "sudo iptables --flush". Bring the network on computer 1 up, connect 2 to 1 and then check if the problem still exists.

Chris (not verified)
October 21st, 2010 06:39 pm
Hi shredder12, many thanks for taking the time to help me with this. OK, I had Firestarter installed from a few days ago when I followed the suggestions on another forum for setting up internet sharing via eth0. I have now uninstalled Firestarter from both computers and ran 'sudo iptables --flush' as you suggested. As before, computer 2 sees the wireless network on computer 1, and can connect to it. I did a test using Network Tools - I can ping successfully from both sides. The IP address of computer 2 is now 10.42.43.10. I think I made a mistake previously by adding a new wireless network connection on 2 as well instead of just connecting to 1. Anyway, this is what I now get when I run 'ping google.com' from computer 2: PING google.com (165.165.38.19) 56(84) bytes of data. From chris-laptop.local (192.168.1.2) icmp_seq=2 Destination Host Unreachable . . . ^C --- google.com ping statistics --- 10 packets transmitted, 0 received, +6 errors, 100% packet loss, time 9009ms, pipe 3
Chris (not verified)
October 21st, 2010 06:45 pm
Hi shredder12, this is confusing. After sending my previous reply, I thought I'd close Firefox on computer 1 and try for internet connection again on computer 2. This time it worked! Just a coincidence?
October 21st, 2010 07:06 pm

Hi Chris. Good to see that it worked. I am pretty sure it was firestarter. Things should work without any trouble from now.

Chris (not verified)
October 21st, 2010 07:24 pm
Hi shredder12. I'm very grateful for your help. Thanks again.
Chris (not verified)
October 21st, 2010 09:12 pm
Hi shredder12. I have finally discovered the root of the problem. I also have a wired connection on eth0 between the two computers for file and printer sharing. When computer 2 is connected to the wired network, it cannot access the internet from computer 1. But as soon as I disconnect the eth0 connection on computer 2, the shared internet connection works.
Chris (not verified)
October 21st, 2010 11:58 am
On computer 1 (connected to internet via USB modem) 'ifconfig wlan0' gives: wlan0 Link encap:Ethernet HWaddr 00:17:c4:78:c8:4f inet addr:10.42.43.1 Bcast:10.42.43.255 Mask:255.255.255.0 inet6 addr: fe80::217:c4ff:fe78:c84f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:654 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:154056 (154.0 KB) Computer 2 gives similar results, but I notice that this line is identical: inet addr:10.42.43.1 Bcast:10.42.43.255 Mask:255.255.255.0 Could this be the problem? On computer 1 I get this when I run a short 'ping google.com': --- google.com ping statistics --- 2 packets transmitted, 2 received, 0% packet loss, time 5682ms rtt min/avg/max/mdev = 316.969/338.473/359.978/21.512 ms This is to be expected. When I 'ping google.com' on computer 2. I get this: ping: unknown host google.com Any suggestions? Thanks

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <img> <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <p> <br>
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Image links with 'rel="lightbox"' in the <a> tag will appear in a Lightbox when clicked on.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.