Here is my ifconfig file: http://pastebin.com/5ZUGYbnB

auto eth0
iface eth0 inet static
        address 180.xxx.xx.68
        network 180.xxx.xx.64
        broadcast 180.xxx.xx.71
        gateway 180.xxx.xx.65
        # dns-* options are implemented by the resolvconf package, if installed
        dns-nameservers 180.xxx.xx.65

auto eth1
iface eth1 inet static
        up route add -net netmask gw
        down route del -net netmask gw

and this is my routing table http://pastebin.com/VVwCe7ZF

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
180.xxx.xx.64 U     0      0        0 eth0   UG    0      0        0 eth1   U     0      0        0 eth1         180.xxx.xx.65         UG    100    0        0 eth0         UG    100    0        0 eth1

but it doesn't forward any packet to another network. Is there any wrong with my routing table?

  • How did you establish it's not forwarding packets? Do you have ip_forward set to 1? Is it supposed to be doing NAT? (If so, did you configure NAT?) – David Schwartz Dec 1 '11 at 5:34

Well for starters, you've got two default routes. It's possible to have this in certain cases, but it's unlikely to be what you want.

Generally one default route will be used, and for you I'd guess that you want to use the default gateway on that 180.x network.

Remove the gateway line from the eth1 definition.

The other thing to check is that /proc/sys/net/ipv4/ip_forward is enabled:

cat /proc/sys/net/ipv4/ip_forward 

and check that you get 1, not 0.

If you don't, you need to enable it, and the best way is to edit /etc/sysctl.conf and set net.ipv4.ip_forward=1

That will get forwarding working, but if it's still not working at this point (it's hard to say what your requirements are without a better description of what you're trying to achieve), you may need to look into netfilter SNAT or MASQ using iptables.

  • Sorry for asked pretty simple question. Routing problem solved! My mistake was : I wrote 2 destination. 1 for LAN interface address, another was public IP(starting with 180.) address. – KevinOelen Dec 1 '11 at 7:12

Don't forget:


Would be cool if there was an answer response, I am working on a linux router too. It doesn't seem to be as easy as saying:

iptables -P FORWARD -j ACCEPT 

Start with a rebooted state and if that routing table is the rebooted state routing:

sudo route del default eth0
sudo route del default eth1
sudo route add default gw $GATEWAY $IFACE
sudo route del -net netmask 
sudo route add -net netmask gw eth1
sudo route del -net 180.x.x.64 netmask
sudo route add -net 180.x.x.64 netmask gw 180.x.x.65 eth0

So this will be a pretty hard coded route table, $GATEWAY is the IP address of the gateway that knows what to do with destinations not a destination in the table and $IFACE is eth0 or eth1 or another interface like ppp0 where this router is. If or 180.x.x.65 is one of those routers, you can simplify this routing table by putting or leaving default routes.

This only helps this machine find and route it's way. From what I can tell you need the firewall sudo iptables to help with the forwarding. It's not persistent (after reboot) either... there are many ways and I think you already use one.

  • 1
    There is an answer response. It's been accepted by the OP, too. – MadHatter Jun 17 '18 at 8:17

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.