to make your linux to be router, edit /etc/sysctl.conf and change the following line:
net.ipv4.ip_forward = 1
now its a router. if u change the gw of clients to linux, they will be able to access other networks which linux can access.
then give some iptables command to make NAT. an example:
iptables -t nat -A POSTROUTING -s 172.0.0.0/255.255.0.0 -d ! 192.168.0.0/255.255.255.0 -j SNAT --to 212.145.7.8
this makes nat if the source ip come from 172.0.0.0/255.255.0.0 network and the destinations is not 192.168.0.0/255.255.255.0.. static public ip: 212.145.7.8, change it for your real static ip. if u dont have static ip, u have to use "masquerade" like this:
iptables -t nat -A POSTROUTING -o ppp0 -s 172.0.0.0/255.255.0.0 -d ! 192.168.0.0/255.255.255.0 -j MASQUERADE
the interface which s connected to internet is ppp0. if its a ethernet, change it.
|