Two default routes in Linux

Discussion in 'General Networking Discussion' started by prashant_anavekar, Aug 30, 2012.

  1. prashant_anavekar


    Aug 30, 2012
    Likes Received:
    Hello Friends,

    My device has 2 n/w cards. The requirement is to use 2 n/w cards to communicate on 2 totally different networks (they should use 2 different GWs for communication outside the subnet), so I used following commands to configure the network:
    /sbin/ifconfig lo
    /sbin/ifconfig eth1 netmask broadcast
    /sbin/ifconfig eth0 netmask broadcast
    /sbin/ip route add default via dev eth1 table 2
    /sbin/ip rule add from tab 2 priority 500
    /sbin/ip route add default via dev eth0 table 1
    /sbin/ip rule add from tab 1 priority 600
    /sbin/ip route flush cache

    with this I meet my above mentioned requirement successfully, but I face following issue:
    If I connect either eth0 OR eth1 of my device directly to my PC (here my device eth0, eth1 and my PC all are in same network. e.g. eth0:, eth1: and PC: using ethernet cross/straight cable then I can not ping my device from my PC.
    I tried to check what exactly is happening by looking at wireshark dump on my PC and tcpdump on my device and my observations are as below:
    1. ping req goes successfully from my PC
    2. ping req is received by my device successfully, but while responding it tries to go via the GW ( and it does not find the GW, so ping fails.

    Now, what should I do to tell my device to not use the GW while communicating on the same network?
    Please help, it is very urgent.

    prashant_anavekar, Aug 30, 2012
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.