0

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

auto eth0
iface eth0 inet static
        address 180.xxx.xx.68
        netmask 255.255.255.248
        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 8.8.8.8

auto eth1
iface eth1 inet static
        address 10.96.92.23
        netmask 255.255.255.0
        network 10.96.92.0
        broadcast 10.96.92.255
        gateway 10.96.92.1
        dns-nameservers 10.96.92.11
        up route add -net 10.86.82.0 netmask 255.255.255.0 gw 10.96.92.1
        down route del -net 10.86.82.0 netmask 255.255.255.0 gw 10.96.92.1

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   0.0.0.0         255.255.255.248 U     0      0        0 eth0
10.86.82.0      10.96.92.1      255.255.255.0   UG    0      0        0 eth1
10.96.92.0      0.0.0.0         255.255.255.0   U     0      0        0 eth1
0.0.0.0         180.xxx.xx.65   0.0.0.0         UG    100    0        0 eth0
0.0.0.0         10.96.92.1      0.0.0.0         UG    100    0        0 eth1

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

1
  • 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?) Dec 1, 2011 at 5:34

3 Answers 3

6

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.

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

Don't forget:

iptables -P FORWARD ACCEPT
-1

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:

net.ipv4.ip_forwarding=1
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 10.96.92.0 netmask 255.255.255.0 
sudo route add -net 10.96.92.0 netmask 255.255.255.0 gw 10.96.92.1 eth1
sudo route del -net 180.x.x.64 netmask 255.255.255.248
sudo route add -net 180.x.x.64 netmask 255.255.255.248 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 10.96.91.1 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
  • 1
    There is an answer response. It's been accepted by the OP, too.
    – MadHatter
    Jun 17, 2018 at 8:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .