Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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:213.101.213.177  Bcast:213.101.213.191  Mask:255.255.255.192
          inet6 addr: fe80::21c:23ff:fe87:d3be/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          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:10.0.0.1  Bcast:10.0.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21b:21ff:fe4f:e40b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          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 255.255.255.0;
option broadcast-address 10.0.0.255;
option routers 10.0.0.254;
#option domain-name-servers 10.0.0.1;
option domain-name "server.mydomain.com";

subnet 10.0.0.0 netmask 255.255.255.0 {
    range 10.0.0.2 10.0.0.200;
}

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

# nat Table rules
*nat
:POSTROUTING ACCEPT [0:0]

# Forward traffic from eth1 through eth0
-A POSTROUTING -s 10.0.0.0/24 -o eth0 -j MASQUERADE

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

ufw status: (default is also set to allow)

Status: active

To                         Action      From
--                         ------      ----
Anywhere                   ALLOW       10.0.0.0/24

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

What have I missed? Thanks!

share|improve this question

2 Answers 2

up vote 1 down vote accepted

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

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

share|improve this answer
    
Would you look at that! :D Thanks a lot! –  Znarkus Dec 19 '09 at 14:33

What is the content for /etc/resolv.conf on 10.0.0.2? 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 8.8.8.8 and 8.8.4.4 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.

share|improve this answer
    
search server.mydomain.com \n nameserver 10.0.0.1. 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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