make a file named 'rc.nat' and put the following script in it.
Code:
# Defines the location of iptables executables.
iptables=/sbin/iptables
#Clears if any old iptable rules/ policies are there.
iptables --flush -t nat
# Now we will do Masquerading ie. we are doing NAT.
iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE
iptables --append FORWARD --in-interface eth0 -j ACCEPT
# Enabling packet forwarding.
echo 1 > /proc/sys/net/ipv4/ip_forward
Now save this rc.nat in /etc/rc.d/ and make it executable by
Code:
chmod 755 /etc/rc.d/rc.nat
Now add the following lines in your /etc/rc.d/rc.local so that every time you start your computer it get executed automatically.
Now in your clients make sure you have set the gatway as the ip of your computer which is connected directly to internet and also that you have entered right nameserver (DNS) in the dns list of clients.
Now you should be able to share internet after executing this script.
Source