Tag Archives: ICS

Internet Connection Sharing on Ubuntu & Windows with Ad-hoc 2.

A few months ago I made a quick tutorial about Internet Connection Sharing focusing to the case when we are sharing the connection from a machine with Windows installed to the other PC with Linux operating system. In this guide I’ll show you the contrary case, how to share your incoming connection with Linux.

First of all, make sure that you have installed the appropriate drivers for your network interfaces.

Let’s get started with my configuration: I have 2 laptops, one with Ubuntu 10.04 (Laptop 1) and the other with Windows XP (Laptop 2) installed. Both have 2 networking interfaces, Wireless and Ethernet – in the rest of the text just wlan and eth.

We need to share the incoming Internet connection from Ubuntu machine. This laptop is connecting with its network card to the modem with automatic IP address (through DHCP).
I’ll connect my laptops through Wireless. Here is the configuration for the first wireless card (wlan0) on the laptop which is directly connected to the modem:
Create a new Wireless connection, name it and set the mode to Ad-hoc.


Under the tab IPv4 Settings set the following parameters:

IP.: 192.168.88.1
Subnet.: 255.255.255.0
Gateway: Leave empty or set to the IP of your Ethernet card on this machine.

Type the following command in root terminal, do not use sudo:
First, configure the laptop for NAT-ing with the following command:
# iptables -t nat -A POSTROUTING -o ethN -j MASQUERADE # (1)
in my case N is 0, replace N with the number of the card which is directly connected to your modem.
Set IP Forwarding:
# echo 1 > /proc/sys/net/ipv4/ip_forward
Install dnsmasq using apt-get:
# apt-get install dnsmasq
and restart it:
# /etc/init.d/dnsmasq restart
Add the following line to /etc/sysctl.conf:
"net.ipv4.ip_forward = 1"
Reboot and repeat (1).

Before continuing with the next laptop make sure that you have working Internet connection on Laptop 1.

First you need to create an Ad-hoc network on your Windows machine too:


Because we are doing our sharing without any security, switch to Open network under Properties > Associations.


Set the following configuration for the Laptop 2 with Windows installed:

IP: 192.168.88.88
Subnet: 255.255.255.0
DNS: 192.168.88.1 (must be the IP of the wireless card on Laptop 1).


Comments are welcome, happy surfing! 🙂

Internet Connection Sharing on Ubuntu & Windows with Ad-hoc

Hi!

First I was very excited when my brother asked for my help to choose him a laptop. My other task was to share our internet connection between a Desktop PC and two laptops without using switch or router. Of course the story became more interesting due to the different operating systems. I’ll try to show how to set up your home network in such situations.

Important to make sure that you have installed drivers for networking interfaces!

About the connection: cable-net,  the modem is connected to the Desktop-PC with USB.

Configuring the wired interfaces:

Desktop-PC has two networking interfaces, the first (in the following text: eth0) has automatic network  address through the modem (DHCP). We need to allow to the other computers in our network (in this case just one laptop) to connect to the internet through this connection [1].

The another network interface of Desktop-PC is eth1 – it has static address, set to 192.168.0.1 with subnet mask 255.255.255.0 . We need to connect this network card (eth1) to one of our laptops directly. I connected it first to the laptop with Windows XP, of course you can connect it to the laptop with Linux but the Internet Connection Sharing and the IP configuration becomes more complicated in that case. When connecting our Desktop-PC and laptop directly we must to use crossover (crosslink) cable! So, we connected our Desktop-PC’s card (eth1) with our Laptop’s ethernet card (in the following text: eth2). The address configuration for this card need to be also automatic – eth1 will deal for eth2 an address, subnet mask and gateway too.

Configuring the wireless interface on Windows:

At this point you have working internet connection on both Desktop-PC and laptop (with the interface eth2). We’ll share this connection with the second laptop through an ad-hoc network. First of all you need to configure the eth2 card to allow the other computers in the network to connect to the internet through this connection ( see [1]).

Create an Ad-hoc wireless network with your integrated wireless card (wlan0 in the following)  on the laptop with Windows XP (no encryption used in this example to simplify the setup).

After creating an Ad-hoc network,  set static address for wlan0, IP: 192.168.88.1, subnet: 255.255.255.0. You have configured your Windows machines, move to the laptop with Linux.

Configuring the wireless interface on Linux:

In this example I’m using Ubuntu 9.10 Karmic Koala, but you will find the same expressions on other Linux distributions and in different Network Configuration Interfaces. Create a new wireless connection and set the connection type to Ad-hoc.

The most important part is the IP configuration. On your Linux laptop for the wireless interface (wlan1) set static addresses for IP: 192.168.88.88 (actually the end of this address can be anything – in the allowed range – the only important thing is that it must be different from the last part of your static address of the interface wlan0), subnet 255.255.255.0, for Gateway and DNS set the IP address of the interface wlan0.

Apply the changes and connect to this Ad-hoc network on your Windows and Linux laptops.

If you have any question, please comment.