I our lab we have a small network of 4 Debian machines, connected through a router in a LAN. One of these machines (the server) have internet connection provided by the bigger network of the building. I want to give internet to the inner machines on LAN using NAT. I followed this guide but I cannot get a working connection from clients.

The IP of the server at eth0 is (connected to the internet); and the eth1 is (connected to the LAN). I setup bind9 (with standard conf, but adding the correct DNS addresses to /etc/bind/named.conf.options) to forward the DNS but I not sure if this is absolutely necessary.

$ iptables-save 
# Generated by iptables-save v1.4.21 on Mon Aug 22 16:06:21 2016
:PREROUTING ACCEPT [46792:8129746]
:INPUT ACCEPT [46302:8099043]
:OUTPUT ACCEPT [2752:190850]
-A POSTROUTING -o eth0 -j SNAT --to-source
# Completed on Mon Aug 22 16:06:21 2016
# Generated by iptables-save v1.4.21 on Mon Aug 22 16:06:21 2016
:INPUT ACCEPT [61997:8558568]
:OUTPUT ACCEPT [9258:2611777]
-A FORWARD -i eth1 -j ACCEPT
# Completed on Mon Aug 22 16:06:21 2016

I can connect the machines using ssh or ping between them, but I still cannot connect or ping the internet from the client machine (eth0 IP This is the gateway on this:

$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 eth0   U     0      0        0 eth0

/proc/sys/net/ipv4/ip_forward is 1

Any help are welcome

  • 4
    Have you really configured both client and server with the IP address – kasperd Aug 22 '16 at 19:36
  • You don't need bind set up on the server, the client machines can use the same DNS as the outer network once the NAT is working correctly. – Tero Kilkanen Aug 22 '16 at 20:22
  • The IP of the client is (typing error) – FVillanelo Aug 23 '16 at 13:15

you don't need to use bind, you could set a DNS server outside your network (like Google DNS / but your first problem is at the IP layer.

If you SNAT with you should set up your default route to target this way (something like on your gateway.

Do you have any responce when you ping from your gateway ?

  1. Verify that your Gateway have internet (ping
  2. You should ping your gateway from your client
  3. Try to use -j MASQUERADE instead of -j SNAT
  • I remove bind and now work. I try before without bind and don't work, but maybe in that moment the iptables wasn't configured correctly. I have SNAT in place of MASQUERADE because the static IP. Thanks anyway! – FVillanelo Aug 23 '16 at 14:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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