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 http://puu.sh/2Yfd7.png

output iptables -L FORWARD http://i.stack.imgur.com/Mas98.png

apologies for screenshots.

  • 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

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.

  • 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 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.