set ip PC gateway
# ifconfig eth0 192.168.0.6 netmask 255.255.255.0
set default gateway in PC gateway(internet sharing)
# route add default gw 192.168.0.5
- enable IP forwarding
# echo 1 > /proc/sys/net/ipv4/ip_forward
or
# sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
- set firewall
# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j MASQUERADE
or use SNAT
# iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0 -j SNAT 192.168.0.6
- show rule
iptables -t nat -nL
- to make permanent set in /etc/rc.local
nb : 192.168.0.5 --> IP DSL Modem / router
192.168.0.6 --> IP PC gateway(Internet Sharing)