Linux – How to share the internet connection to the LAN with Debian

debiangatewaylinuxnetworkingrouting

I'm trying to make my Debian server the router for my LAN.

I got two interfaces: eth0 connects to internet through PPPoE, eth1 to LAN.
I switched on forwarding in sysctl net.ipv4.ip_forward=1 and disabled iptables(policy accept). I can ping the gateway, but can't ping anything on the internet.

Best Answer

You need to use NAT to share the internet connection to your LAN.

Example:

iptables --table nat --append POSTROUTING --out-interface eth0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT

See this guide at HowtoForge for more info: http://www.howtoforge.com/nat_iptables