Recently I wanted to share an Internet connection between my own laptop and a friend's laptop.
Originally Posted by exeption
I connected my laptop to my friend's laptop using an Ethernet cable, and the network interface I used for this connection on my own laptop was eth0.
My main wireless card on my own laptop, wlan0, was used to connect to the Internet. Its setup was pretty simple:
Next I had to set up my eth0 connection on my own laptop. I gave it a static address:
iwconfig wlan0 essid MyNet key off
Then I went to my friend's laptop and I set his eth0 connection:
ifconfig eth0 10.10.10.1 netmask 255.255.255.0
Then I made sure that we could ping each other. So from my own laptop, I did:
ifconfig eth0 10.10.10.2 netmask 255.255.255.0
And from my friend's laptop, I did:
That worked fine. Next I wanted to set up Internet connection sharing on my own laptop:
Then on my friend's computer, I set 10.10.10.1 as the default gateway as follows:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o wlan0 -s 10.10.10.0/24 -j MASQUERADE
Again, on my friend's computer, I also set the DNS server:
route add default gateway 10.10.10.1
And that was it. I opened a web browser on my friend's computer, and he was able to surf the net and do whatever he wanted.
echo nameserver 22.214.171.124 > /etc/resolv.conf
Here's a quick guide for using the command line to set your internet connection:
Linux Internet Connection - Virjacode