Routing doesn’t working in linux

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?

– Answer –

  • 1 December 2011: Answer by grendel for Routing doesn't working in linux -

    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 December 2011: Routing doesn't working in linux -

    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?

One Response to “Routing doesn’t working in linux”

  1. Agregator zakupów grupowych Says:

    Great blog…

    [...]“Hello! I could have sworn I’ve been to this blog before but after browsing through some of the post I realized it’s new to me. Anyways, I’m definitely happy I found it and I’ll be book-marking and checking back frequently!”…

Leave a Reply