I'm trying to setup up an Ubuntu server, and first I want it to act as NAT/router/firewall. My question is: How do I make it so the computers connected to the LAN, can access Internet?

eth0      Link encap:Ethernet  HWaddr 00:1c:23:87:d3:be
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::21c:23ff:fe87:d3be/64 Scope:Link
          RX packets:16037 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13626 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2268865 (2.2 MB)  TX bytes:1258854 (1.2 MB)
          Interrupt:26 Base address:0x6000

eth1      Link encap:Ethernet  HWaddr 00:1b:21:4f:e4:0b
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::21b:21ff:fe4f:e40b/64 Scope:Link
          RX packets:929 errors:0 dropped:0 overruns:0 frame:0
          TX packets:309 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:100820 (100.8 KB)  TX bytes:45571 (45.5 KB)

eth0 is internet, with dynamic IP. eth1 is LAN.

I've got dhcp-server working, and computers are getting IP addresses. I'm not sure if I've configured it correctly for computers to resolve domain names though.

This is my dhcpd.conf file. Notice that I commented out the dns part, as i don't run bind (should I?)

default-lease-time 600;
max-lease-time 7200;
option subnet-mask;
option broadcast-address;
option routers;
#option domain-name-servers;
option domain-name "server.mydomain.com";

subnet netmask {

And these are the rules I added to the top of /etc/ufw/before.rules

# nat Table rules

# Forward traffic from eth1 through eth0

# don't delete the 'COMMIT' line or these nat table rules won't be processed

ufw status: (default is also set to allow)

Status: active

To                         Action      From
--                         ------      ----
Anywhere                   ALLOW

When I try to ping Google from computer, I get "destination host unreachable" / "unkown host".

What have I missed? Thanks!


The router that you've specified in /etc/dhcpd.conf is, yet the Ubuntu box you're trying to configure is (apparently) on

So your client machines' packets aren't even being sent to the Ubuntu box for NAT processing and forwarding.

| improve this answer | |

What is the content for /etc/resolv.conf on If no useful nameserver is configured, you will not be able to ping by hostname. Either use DHCPD to set the nameserver for all the clients or configure them manually.

If you do not run bind you can always use a publicly available DNS server such as the recently launched DNS service by Google. Use and nameservers.

Alternatively, if this is a small home/lan setup, you may want to consider using dnsmasq instead for your dhcp/dns server. It works as both a DHCP server and a DNS server for your local network.

| improve this answer | |
  • search server.mydomain.com \n nameserver I ended up installing bind9 (again) and configured dhcpd for it. Got my .2 box to resolve domain names, and Alnitak's answer solved the rest! – Znarkus Dec 19 '09 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.