
Originally Posted by
exeption
How to I do that?
Recently I wanted to share an Internet connection between my own laptop and a friend's laptop.
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:
Code:
iwconfig wlan0 essid MyNet key off
dhclient wlan0
Next I had to set up my eth0 connection on my own laptop. I gave it a static address:
Code:
ifconfig eth0 10.10.10.1 netmask 255.255.255.0
Then I went to my friend's laptop and I set his eth0 connection:
Code:
ifconfig eth0 10.10.10.2 netmask 255.255.255.0
Then I made sure that we could ping each other. So from my own laptop, I did:
And from my friend's laptop, I did:
That worked fine. Next I wanted to set up Internet connection sharing on my own laptop:
Code:
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o wlan0 -s 10.10.10.0/24 -j MASQUERADE
Then on my friend's computer, I set 10.10.10.1 as the default gateway as follows:
Code:
route add default gateway 10.10.10.1
Again, on my friend's computer, I also set the DNS server:
Code:
echo nameserver 4.2.2.1 > /etc/resolv.conf
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.
Here's a quick guide for using the command line to set your internet connection:
Linux Internet Connection - Virjacode