I'm trying to configure a ubuntu server to be a router. This is my interface configuration (eth2 connects to my WAN, eth0 to my LAN):

auto eth2
iface eth2 inet static

auto eth0
iface eth0 inet static

This is the router information:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface   U     0      0        0 eth0   U     0      0        0 eth2         UG    100    0        0 eth2

And this is dhcp configuration:

subnet netmask {
    option domain-name-servers;
    option routers;

I'm then connecting a mac os x by cable on eth0. This is en0 interface configuration:

 ether 00:26:bb:5d:82:b0 
 inet6 fe80::226:bbff:fe5d:82b0%en0 prefixlen 64 scopeid 0x4 
 inet netmask 0xffffff00 broadcast
 media: autoselect (100baseTX <full-duplex>)
 status: active

And this is the routing table:

Destination        Gateway            Flags        Refs      Use   Netif Expire
default        UGSc          139       32     en0
10.37.129/24       link#8             UC              2        0   vnic1        0:1c:42:0:0:9      UHLWI           0      839     lo0      ff:ff:ff:ff:ff:ff  UHLWbI          0        4   vnic1
10.211.55/24       link#7             UC              2        0   vnic0        0:1c:42:0:0:8      UHLWI           0      840     lo0      ff:ff:ff:ff:ff:ff  UHLWbI          0        4   vnic0
127                UCS             0        0     lo0          UH              3   507924     lo0
169.254            link#4             UCS             0        0     en0
172.16.42/24       link#10            UC              2        0  vmnet8        0:50:56:c0:0:8     UHLWI           0      839     lo0      link#10            UHLWbI          1       24  vmnet8
192.168.100        link#4             UC              2        0     en0      0:e0:7c:7e:f:99    UHLWI         139        0     en0    777          UHS             0        0     lo0    ff:ff:ff:ff:ff:ff  UHLWbI          0        4     en0
192.168.116        link#9             UC              2        0  vmnet1      0:50:56:c0:0:1     UHLWI           0      839     lo0    ff:ff:ff:ff:ff:ff  UHLWbI          0        4  vmnet1

My net.ipv4.ip_forward is setted and iptables has no rule defined.

When I ping, it works. When I ping, it also works. However, when I try to ping it does not. In this last case, when I use tcpdump I can see ICMP activity in eth0 but none in eth2.

Does anyone has any way to solve this? Is there a way to debug it?



In /etc/sysctl.conf have a look for the line mentioning net.ipv4.ip_forward. If it's still commented out, uncomment it and then run sysctl -p to get the packets forwarding. This should allow you to ping from

However, then you're going to have to look at using iptables to NAT the connection coming from to the outside world.


Can you ping from your Ubuntu system?

Is forwarding enabled on your Ubuntu system? You need net.ipv4.ip_forward enabled if you want to forward packets; this would typically be placed in /etc/sysctl.conf:

net.ipv4.ip_forward = 1

And then run sysctl -p.

You can set this (non-persistently) on the command line:

sysctl -w net.ipv4.ip_forward=1

Do you have a local firewall that prevents forwarding? Check the default policy on your FORWARDING (or any specific rules in the FORWARDING chain).

  • Hi, thanks for the help. My net.ipv4.ip_forward is 1. It doesn't work. Also, my firewall does not have any rules and the ubuntu router is able to ping perfectly. When I use tcpdump I can see ICMP activity in eth0 and none in eth2. – Rafael Jan 5 '11 at 17:23

Perhaps you're not forwarding packets across interfaces? Try

echo 1 > /proc/net/ipv4/ip_forward
echo 1 > /proc/net/ipv6/ip_forward

If it works, set it permanently with sysctl.conf


Found the reason.

My WAN router did not recognize the network, therefore the icmp request got there, but could not get back.

Altering the routing information in the WAN router fixed the problem.


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.