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 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
    address 192.168.0.249
    netmask 255.255.255.0
    gateway 192.168.0.1
    broadcast 192.168.0.255

auto eth0
iface eth0 inet static
    address 192.168.100.1
    netmask 255.255.255.0

This is the router information:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 eth2
0.0.0.0         192.168.0.1     0.0.0.0         UG    100    0        0 eth2

And this is dhcp configuration:

subnet 192.168.100.0 netmask 255.255.255.0 {
    range 192.168.100.101 192.168.100.254;
    option domain-name-servers 201.70.86.133;
    option routers 192.168.100.1;
    authoritative;
}

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

en0: flags=8963<UP,BROADCAST,SMART,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
 ether 00:26:bb:5d:82:b0 
 inet6 fe80::226:bbff:fe5d:82b0%en0 prefixlen 64 scopeid 0x4 
 inet 192.168.100.101 netmask 0xffffff00 broadcast 192.168.100.255
 media: autoselect (100baseTX <full-duplex>)
 status: active

And this is the routing table:

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            192.168.100.1      UGSc          139       32     en0
10.37.129/24       link#8             UC              2        0   vnic1
10.37.129.2        0:1c:42:0:0:9      UHLWI           0      839     lo0
10.37.129.255      ff:ff:ff:ff:ff:ff  UHLWbI          0        4   vnic1
10.211.55/24       link#7             UC              2        0   vnic0
10.211.55.2        0:1c:42:0:0:8      UHLWI           0      840     lo0
10.211.55.255      ff:ff:ff:ff:ff:ff  UHLWbI          0        4   vnic0
127                127.0.0.1          UCS             0        0     lo0
127.0.0.1          127.0.0.1          UH              3   507924     lo0
169.254            link#4             UCS             0        0     en0
172.16.42/24       link#10            UC              2        0  vmnet8
172.16.42.1        0:50:56:c0:0:8     UHLWI           0      839     lo0
172.16.42.255      link#10            UHLWbI          1       24  vmnet8
192.168.100        link#4             UC              2        0     en0
192.168.100.1      0:e0:7c:7e:f:99    UHLWI         139        0     en0    777
192.168.100.101    127.0.0.1          UHS             0        0     lo0
192.168.100.255    ff:ff:ff:ff:ff:ff  UHLWbI          0        4     en0
192.168.116        link#9             UC              2        0  vmnet1
192.168.116.1      0:50:56:c0:0:1     UHLWI           0      839     lo0
192.168.116.255    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 192.168.100.1, it works. When I ping 192.168.0.249, it also works. However, when I try to ping 192.168.0.1 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?

Thanks,

share|improve this question

4 Answers 4

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 192.168.0.1 from 192.168.100.101.

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

share|improve this answer

Can you ping 192.168.0.1 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).

share|improve this answer
    
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 192.168.0.1 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

share|improve this answer

Found the reason.

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

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

Thanks!

share|improve this answer

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.