Internet sharing to a subnet (with NAT): iptables script
There is a script you can use for Internet sharing for an IP or a subnet with NAT:
#!/bin/bash echo -e "\e[6;32mConfiguring iptables..\e[0;0m" # replace ppp0 to your external interface name ext_if = "ppp0" echo 1 > /proc/sys/net/ipv4/ip_forward #uncomment the string for sharing to the whole local net #iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o $ext_if -j MASQUERADE #sharing to 192.168.1.2 ip: iptables -t nat -A POSTROUTING -s 192.168.1.2 -o $ext_if -j MASQUERADE
Save the script to /etc/init.d/ directory. Name it, for example, net_share and make the script executable:
sudo chmod a+x /etc/init.d/net_share
Activate Internet sharing:
sudo /etc/init.d/net_share
To put the script in startup do the following:
sudo update-rc.d net_share defaults
Got a comment?
All Rights Reserved.