Sunday, December 19, 2010

Enable Packet forwarding on for Internet Connection Sharing on Linux

Enable NATting for internet connection:


ppp0-internet connected port


add on startup or to /etc/init.d/rc.local


sudo iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE


Enable Packet accep for incoming requests:


Edit following file and change/uncomment following line to enable packet forwarding for incoming request packets.


/etc/sysctl.conf: net.ipv4.ip_forward = 1


to get control over the packet forwarding, we can forward all NATed packets to a local proxy server

to disable direct packet forwarding, change
/etc/sysctl.conf: net.ipv4.ip_forward = 0

then add an additional route;
i don't know whether the sequence of following will affect, just check you guys ans let me know....
:-)

iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128

iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

1 comment:

  1. to get control over the packet forwarding, we can forward all NATed packets to a local proxy server

    to disable direct packet forwarding, change
    /etc/sysctl.conf: net.ipv4.ip_forward = 0

    then add an additional route;
    i don't know whether the sequence of following will affect, just check you guys ans let me know....
    :-)

    iptables -t nat -A PREROUTING -i eth1 -p tcp --dport 80 -j REDIRECT --to-port 3128

    iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

    ReplyDelete