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.

link|improve this question
feedback

2 Answers

up vote 1 down vote accepted

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

link|improve this answer
I thought when iptables disabled there are no barriers to traffic.thanks i'll try it – 29ru Oct 19 '11 at 10:31
feedback

Enabling IP forwarding (AKA routing) is not enough; you must also NAT the internal network to the external IP.

Disabling netfilter is not going to get you there; you need Rusty's one-line rule of masquerade:

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.