Iptables

From Tomelec
Revision as of 19:12, 17 September 2011 by Tom (talk | contribs) (Created page with "== Share Internet connection creating a NAT == Sometime it´s handy to share an Internet connection with other network devices. For example to dial in using an UMTS modem and the...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Share Internet connection creating a NAT

Sometime it´s handy to share an Internet connection with other network devices. For example to dial in using an UMTS modem and then getting a second computer (client) on the LAN port online.

  • enable IP forwarding
  • create a simple NAT
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

ppp0 is the network device with an Internet connection. Important notes:

  • the LAN port for the client´s network must have an IP address set
  • clients must have an IP address within the same subnet of course
  • clients must have a default route set
  • clients should have a manual DNS server entry