Friday, August 26, 2011

share your connection from ubuntu with your ipod

I have a temporary office without wifi and my ipod which I use for skype comunication suffer from that so I decided to share the wired connection from my Ubuntu box.

In general in order to share an Internet connection, the computer that will do the sharing must have two network cards or ports. This assumes that you are using at least one Ethernet port and that it is identified as "eth0". eth0 will be the port that other computers will connect to you on.

When you are logged in:

  • Go to "System" on your top bar
  • Navigate to "Preferences" and select "Network Connections"
  • When that window opens, select "Auto eth0" and press "Edit" (This assumes that you are connected to the internet on some other port, for ex. wlan0 using wireless)

A new window will open. Navigate to the tab titled "IPv4 Settings" and change the Method to "Shared to other computers". After restarting the computer you should now be able to plug in any computer into your other Ethernet port or share through your wireless card.

Note: To clarify the above example here is an example configuration that will work -

  1. You are already connected to the internet using your wireless on port wlan0
  2. The ethernet port eth0 is connected to the PC that needs to share your internet connection (or you could wire eth0 to a router for multiple machines)

Note: in the case of connecting a router, especially one with wireless, where you want the users to share your connection:

  1. Check before you start (in Synaptic or with dpkg-query -l dnsmasq*) that dnsmasq-base is installed and that dnsmasq isnot installed. Install or uninstall as appropriate (see next section).

  2. After connecting the router, to enable masquerading, type: sudo iptables -t nat -A POSTROUTING -j MASQUERADE

Wireless Ad-Hoc connection sharing scenario

Step by step guide:

  • dnsmasq-base has to be installed: sudo apt-get install dnsmasq-base
  • remove dnsmasq as it's conflicting with NetworkManager: sudo apt-get remove dnsmasq

  • restart NetworkManager: sudo /etc/init.d/network-manager restart

  • Add a new wireless network with NetworkManager (left-click on NetworkManager icon, then select "Create New Wireless Network")

  • Call the new network "UbuntuAdhoc" (note: if you choose another name you will have to turn on connection sharing later by editing the network you just created!)

  • Set encryption to "WEP40..." (note: you may have to experiment here according to what type of encryption with ad-hoc the phone/other laptop/pc supports, wpa is not supported)

NetworkManager now should connect to itself (which means it creates the ad-hoc wireless network and routes any internet traffic to your wired network interface). Now connect with the client(s) and you should have a working internet connection.


ciao alex barchiesi

No comments:

Post a Comment