Internet Sharing
Internet Sharing
Before going the long route, have a look at a great application called firestarter which allows you to do internet sharing and is a firewall as well.
On this topic I will not expand much. Have a look at this article. It worked for me.
https://help.ubuntu.com/community/Internet/ConnectionSharing
From the above articleI used point 3:
Internet eth0 Ubuntu gateway eth0:0 Client PC
My situation:
Internet ppp0 Ubuntu gateway eth0 Client PC
One thing worth mentioning is that I only have one network card in my machine which is
connected to a switch. Also connected to the switch is my APN to connect to my ISP using PPPoE.
On my machine I worked with eth0 for local network and ppp0 for internet as indicated above.
Works without any problems.
Helpful tread should you encounter problems:
http://ubuntuforums.org/showthread.php?t=589387
The following procedure that worked for me:
1.sudo gedit /etc/sysctl.conf
2. Uncomment "net.ipv4.conf.default.forwarding=1"
3. Save file and close
4. Create a script with code below, allow execution rights and execute.
#!/bin/sh
sudo sysctl -p
sudo iptables -A FORWARD -i ppp0 -o eth0 -s 192.168.1.101/24 -m state --state NEW -j ACCEPT
sudo iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A POSTROUTING -t nat -j MASQUERADE
5. That's it. Execute above script in a terminal.
6. you can check if the changes was made by doing:
"sudo iptables -L"
Output:
$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
ACCEPT all -- 192.168.1.0/24 anywhere state NEW
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
Chain OUTPUT (policy ACCEPT)
target prot opt source destination