Two default routes in Linux

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

  1. prashant_anavekar

    prashant_anavekar

    Joined:
    Aug 30, 2012
    Messages:
    1
    Likes Received:
    0
    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 127.0.0.1
    /sbin/ifconfig eth1 10.129.221.150 netmask 255.255.255.0 broadcast 10.129.221.255
    /sbin/ifconfig eth0 10.129.221.115 netmask 255.255.255.0 broadcast 10.129.221.255
    /sbin/ip route add default via 10.129.221.1 dev eth1 table 2
    /sbin/ip rule add from 10.129.221.150/32 tab 2 priority 500
    /sbin/ip route add default via 10.129.221.1 dev eth0 table 1
    /sbin/ip rule add from 10.129.221.115/32 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: 10.129.221.115, eth1: 10.129.221.150 and PC: 10.129.221.160) 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 (10.129.221.1) 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.

    Regards,
    Prashant
     
    prashant_anavekar, Aug 30, 2012
    #1
    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.