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.
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:
DNS: 192.168.88.1 (must be the IP of the wireless card on Laptop 1).