Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a linux server (Ubuntu 12) with 2 NIC's.

eth0 is connected WAN (inet mask

eth1 is connected LAN (inet mask

I want my windows machine to connect to the internet. Win -> eth1 -> eth0 -> internet

Added to: /etc/network/interfaces

auto eth1
iface eth1 inet static

I added this to: /etc/dhcp/dhcpd.conf

option domain-name "mydomain";
option domain-name-servers,,;
default-lease-time 600;
max-lease-time 7200;
option subnet-mask;
option broadcast-address;
option routers;
subnet netmask {
        range ;
        option routers ;

and in /etc/ufw/before.rules

# nat rules

# Forward all packes through eth0

# WARNING, do not remove COMMIT line. This breaks the loading

I have set my windows machine's default gateway to and its IP to

My windows machine can ping my eth1 but not the internet

I think the problem is the postrouting rule for ufw but I find no documentation on its syntax (yes Im just copy/pasting a tutorial)..

EDIT: Extra info:

output ip addr and output ip route

output iptables -L FORWARD

apologies for screenshots.

share|improve this question
What do you mean by "WAN"? It would make sense to expect the Internet gateway on the WAN side but that doesn't suit this description: "Win -> eth0 -> eth1 -> internet". With routing problems you should always give the output of ip addr, ip route and iptables -L FORWARD -nv (and all chains referenced from FORWARD). – Hauke Laging May 21 '13 at 18:17
up vote 2 down vote accepted

You need to enable IP forwarding somewhere:

 sudo sysctl -w net.ipv4.ip_forward=1

One of the place where it could be enabled is in /etc/sysctl.conf.d :

 echo "net.ipv4.ip_forward = 1" | sudo tee /etc/sysctl.conf.d/routing.conf

Additionnaly, your iptables rules:


Will only enable NAT for hosts in the range, whereas your DHCP server will deliver ips in the range. You need to change it.

share|improve this answer
Already had this enabled in /etc/sysctl.conf AND /etc/ufw/sysctl.conf. I tried your suggestion but it did not help. – Erik Hermans May 21 '13 at 18:37

Your Answer


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.