Is it possible to ping 8.8.8.8 from two interfaces connected to diffrent WANs












1















I started My project using a raspberry Pi 2 model B and installed Fedora Arm on it. My current Goal is to be able to connect the pi to internet through an ethernet cable connected to a DSL router aswell as a 3G usb dongle in a way where I can set up a fail over mechanic.
To do so I figured I need to make a script that checks if eth0 (ethernet connection) is working by issuing ping 8.8.8.8 -I eth0, if it isn't working I can switch to the 3G connection by taking down the eth0, and activating eth1 (3G dongle).



Everything was fine and it is here that a problem showed up, I wanted to go back to Ethernet once it is back, but I had noway of doing so while my 3G connection was running (issuing ping 8.8.8.8 -I eth0 wasn t working even thought I brought up eth0)
I had to take down eth1 so I could check if the internet connection is back on eth0.
I've realized that when I have both interfaces up only one is active at a time and I can't ping the internet through both using ping 8.8.8.8 -I eth0'
and 'ping 8.8.8.8 -I eth1
at the same time.
my question is :



Is it possible to ping through the two interfaces while both up?



If yes then How?










share|improve this question

























  • Could you add the output of route -n to your question, when eth0 and eth1 are up separately, and when they're both up?

    – John WH Smith
    Jul 19 '16 at 15:20











  • @John WH Smith Thanks for being interested but i already found the solution ,I made sure to share it with the community .voila

    – Ezwig
    Jul 19 '16 at 16:48
















1















I started My project using a raspberry Pi 2 model B and installed Fedora Arm on it. My current Goal is to be able to connect the pi to internet through an ethernet cable connected to a DSL router aswell as a 3G usb dongle in a way where I can set up a fail over mechanic.
To do so I figured I need to make a script that checks if eth0 (ethernet connection) is working by issuing ping 8.8.8.8 -I eth0, if it isn't working I can switch to the 3G connection by taking down the eth0, and activating eth1 (3G dongle).



Everything was fine and it is here that a problem showed up, I wanted to go back to Ethernet once it is back, but I had noway of doing so while my 3G connection was running (issuing ping 8.8.8.8 -I eth0 wasn t working even thought I brought up eth0)
I had to take down eth1 so I could check if the internet connection is back on eth0.
I've realized that when I have both interfaces up only one is active at a time and I can't ping the internet through both using ping 8.8.8.8 -I eth0'
and 'ping 8.8.8.8 -I eth1
at the same time.
my question is :



Is it possible to ping through the two interfaces while both up?



If yes then How?










share|improve this question

























  • Could you add the output of route -n to your question, when eth0 and eth1 are up separately, and when they're both up?

    – John WH Smith
    Jul 19 '16 at 15:20











  • @John WH Smith Thanks for being interested but i already found the solution ,I made sure to share it with the community .voila

    – Ezwig
    Jul 19 '16 at 16:48














1












1








1


0






I started My project using a raspberry Pi 2 model B and installed Fedora Arm on it. My current Goal is to be able to connect the pi to internet through an ethernet cable connected to a DSL router aswell as a 3G usb dongle in a way where I can set up a fail over mechanic.
To do so I figured I need to make a script that checks if eth0 (ethernet connection) is working by issuing ping 8.8.8.8 -I eth0, if it isn't working I can switch to the 3G connection by taking down the eth0, and activating eth1 (3G dongle).



Everything was fine and it is here that a problem showed up, I wanted to go back to Ethernet once it is back, but I had noway of doing so while my 3G connection was running (issuing ping 8.8.8.8 -I eth0 wasn t working even thought I brought up eth0)
I had to take down eth1 so I could check if the internet connection is back on eth0.
I've realized that when I have both interfaces up only one is active at a time and I can't ping the internet through both using ping 8.8.8.8 -I eth0'
and 'ping 8.8.8.8 -I eth1
at the same time.
my question is :



Is it possible to ping through the two interfaces while both up?



If yes then How?










share|improve this question
















I started My project using a raspberry Pi 2 model B and installed Fedora Arm on it. My current Goal is to be able to connect the pi to internet through an ethernet cable connected to a DSL router aswell as a 3G usb dongle in a way where I can set up a fail over mechanic.
To do so I figured I need to make a script that checks if eth0 (ethernet connection) is working by issuing ping 8.8.8.8 -I eth0, if it isn't working I can switch to the 3G connection by taking down the eth0, and activating eth1 (3G dongle).



Everything was fine and it is here that a problem showed up, I wanted to go back to Ethernet once it is back, but I had noway of doing so while my 3G connection was running (issuing ping 8.8.8.8 -I eth0 wasn t working even thought I brought up eth0)
I had to take down eth1 so I could check if the internet connection is back on eth0.
I've realized that when I have both interfaces up only one is active at a time and I can't ping the internet through both using ping 8.8.8.8 -I eth0'
and 'ping 8.8.8.8 -I eth1
at the same time.
my question is :



Is it possible to ping through the two interfaces while both up?



If yes then How?







networking






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 6 at 22:01









Rui F Ribeiro

39.5k1479132




39.5k1479132










asked Jul 19 '16 at 13:39









EzwigEzwig

325213




325213













  • Could you add the output of route -n to your question, when eth0 and eth1 are up separately, and when they're both up?

    – John WH Smith
    Jul 19 '16 at 15:20











  • @John WH Smith Thanks for being interested but i already found the solution ,I made sure to share it with the community .voila

    – Ezwig
    Jul 19 '16 at 16:48



















  • Could you add the output of route -n to your question, when eth0 and eth1 are up separately, and when they're both up?

    – John WH Smith
    Jul 19 '16 at 15:20











  • @John WH Smith Thanks for being interested but i already found the solution ,I made sure to share it with the community .voila

    – Ezwig
    Jul 19 '16 at 16:48

















Could you add the output of route -n to your question, when eth0 and eth1 are up separately, and when they're both up?

– John WH Smith
Jul 19 '16 at 15:20





Could you add the output of route -n to your question, when eth0 and eth1 are up separately, and when they're both up?

– John WH Smith
Jul 19 '16 at 15:20













@John WH Smith Thanks for being interested but i already found the solution ,I made sure to share it with the community .voila

– Ezwig
Jul 19 '16 at 16:48





@John WH Smith Thanks for being interested but i already found the solution ,I made sure to share it with the community .voila

– Ezwig
Jul 19 '16 at 16:48










1 Answer
1






active

oldest

votes


















1














Apparently the problem is that by default, you can only have one default gateway on a system. The case described would lead to asynchronous routing.



Solution



The iproute2 program, which is included in all current Linux distributions and already installed even, as a rule, can be used for the solution of this problem. Normally, a Linux system only has one routing table, in which only one default gateway can make entries. With iproute2, you have the ability to setup an additional routing table, for one thing, and allow this table to be used by the system based on rules, for another.
Initial Position



We will assume that we have two interfaces: eth0 and eth1. The two networks that should be used are 192.168.0.0/24 and 10.10.0.0/24, whereby the first IP address in each respective network should be the gateway. The initial configuration would appear as follows. /etc/network/interfaces



# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface

auto lo
iface lo inet loopback

# The primary network interface

allow-hotplug eth0
iface eth0 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1

# The secondary network interface
allow-hotplug eth1
iface eth1 inet static
address 10.10.0.10
netmask 255.255.255.0


Adding a Second Routing Table



To add a new routing table, the file, /etc/iproute2/rt_tables must be edited. We will call the routing table “rt2” and set its preference to 1. The named file should then appear as follows.



#
# reserved values
#
255 local
254 main
253 default
0 unspec
#
# local
#
#1 inr.ruhep
1 rt2


Configuring the New Routing Table



From this point, four commands are needed to achieve our goal. First, the new routing table needs to be populated, which is done using the following command.



ip route add 10.10.0.0/24 dev eth1 src 10.10.0.10 table rt2
ip route add default via 10.10.0.1 dev eth1 table rt2


The first command says that the network, 10.10.0.0/24, can be reached through the eth1 interface. The second command sets the default gateway.
Routing Rules



So that the system knows when to use our new routing table, two rules must be configured.



ip rule add from 10.10.0.10/32 table rt2
ip rule add to 10.10.0.10/32 table rt2


These rules say that both traffic from the IP address, 10.10.0.10, as well as traffic directed to or through this IP address, should use the rt2 routing table.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f296854%2fis-it-possible-to-ping-8-8-8-8-from-two-interfaces-connected-to-diffrent-wans%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Apparently the problem is that by default, you can only have one default gateway on a system. The case described would lead to asynchronous routing.



    Solution



    The iproute2 program, which is included in all current Linux distributions and already installed even, as a rule, can be used for the solution of this problem. Normally, a Linux system only has one routing table, in which only one default gateway can make entries. With iproute2, you have the ability to setup an additional routing table, for one thing, and allow this table to be used by the system based on rules, for another.
    Initial Position



    We will assume that we have two interfaces: eth0 and eth1. The two networks that should be used are 192.168.0.0/24 and 10.10.0.0/24, whereby the first IP address in each respective network should be the gateway. The initial configuration would appear as follows. /etc/network/interfaces



    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    # The loopback network interface

    auto lo
    iface lo inet loopback

    # The primary network interface

    allow-hotplug eth0
    iface eth0 inet static
    address 192.168.0.10
    netmask 255.255.255.0
    gateway 192.168.0.1

    # The secondary network interface
    allow-hotplug eth1
    iface eth1 inet static
    address 10.10.0.10
    netmask 255.255.255.0


    Adding a Second Routing Table



    To add a new routing table, the file, /etc/iproute2/rt_tables must be edited. We will call the routing table “rt2” and set its preference to 1. The named file should then appear as follows.



    #
    # reserved values
    #
    255 local
    254 main
    253 default
    0 unspec
    #
    # local
    #
    #1 inr.ruhep
    1 rt2


    Configuring the New Routing Table



    From this point, four commands are needed to achieve our goal. First, the new routing table needs to be populated, which is done using the following command.



    ip route add 10.10.0.0/24 dev eth1 src 10.10.0.10 table rt2
    ip route add default via 10.10.0.1 dev eth1 table rt2


    The first command says that the network, 10.10.0.0/24, can be reached through the eth1 interface. The second command sets the default gateway.
    Routing Rules



    So that the system knows when to use our new routing table, two rules must be configured.



    ip rule add from 10.10.0.10/32 table rt2
    ip rule add to 10.10.0.10/32 table rt2


    These rules say that both traffic from the IP address, 10.10.0.10, as well as traffic directed to or through this IP address, should use the rt2 routing table.






    share|improve this answer




























      1














      Apparently the problem is that by default, you can only have one default gateway on a system. The case described would lead to asynchronous routing.



      Solution



      The iproute2 program, which is included in all current Linux distributions and already installed even, as a rule, can be used for the solution of this problem. Normally, a Linux system only has one routing table, in which only one default gateway can make entries. With iproute2, you have the ability to setup an additional routing table, for one thing, and allow this table to be used by the system based on rules, for another.
      Initial Position



      We will assume that we have two interfaces: eth0 and eth1. The two networks that should be used are 192.168.0.0/24 and 10.10.0.0/24, whereby the first IP address in each respective network should be the gateway. The initial configuration would appear as follows. /etc/network/interfaces



      # This file describes the network interfaces available on your system
      # and how to activate them. For more information, see interfaces(5).
      # The loopback network interface

      auto lo
      iface lo inet loopback

      # The primary network interface

      allow-hotplug eth0
      iface eth0 inet static
      address 192.168.0.10
      netmask 255.255.255.0
      gateway 192.168.0.1

      # The secondary network interface
      allow-hotplug eth1
      iface eth1 inet static
      address 10.10.0.10
      netmask 255.255.255.0


      Adding a Second Routing Table



      To add a new routing table, the file, /etc/iproute2/rt_tables must be edited. We will call the routing table “rt2” and set its preference to 1. The named file should then appear as follows.



      #
      # reserved values
      #
      255 local
      254 main
      253 default
      0 unspec
      #
      # local
      #
      #1 inr.ruhep
      1 rt2


      Configuring the New Routing Table



      From this point, four commands are needed to achieve our goal. First, the new routing table needs to be populated, which is done using the following command.



      ip route add 10.10.0.0/24 dev eth1 src 10.10.0.10 table rt2
      ip route add default via 10.10.0.1 dev eth1 table rt2


      The first command says that the network, 10.10.0.0/24, can be reached through the eth1 interface. The second command sets the default gateway.
      Routing Rules



      So that the system knows when to use our new routing table, two rules must be configured.



      ip rule add from 10.10.0.10/32 table rt2
      ip rule add to 10.10.0.10/32 table rt2


      These rules say that both traffic from the IP address, 10.10.0.10, as well as traffic directed to or through this IP address, should use the rt2 routing table.






      share|improve this answer


























        1












        1








        1







        Apparently the problem is that by default, you can only have one default gateway on a system. The case described would lead to asynchronous routing.



        Solution



        The iproute2 program, which is included in all current Linux distributions and already installed even, as a rule, can be used for the solution of this problem. Normally, a Linux system only has one routing table, in which only one default gateway can make entries. With iproute2, you have the ability to setup an additional routing table, for one thing, and allow this table to be used by the system based on rules, for another.
        Initial Position



        We will assume that we have two interfaces: eth0 and eth1. The two networks that should be used are 192.168.0.0/24 and 10.10.0.0/24, whereby the first IP address in each respective network should be the gateway. The initial configuration would appear as follows. /etc/network/interfaces



        # This file describes the network interfaces available on your system
        # and how to activate them. For more information, see interfaces(5).
        # The loopback network interface

        auto lo
        iface lo inet loopback

        # The primary network interface

        allow-hotplug eth0
        iface eth0 inet static
        address 192.168.0.10
        netmask 255.255.255.0
        gateway 192.168.0.1

        # The secondary network interface
        allow-hotplug eth1
        iface eth1 inet static
        address 10.10.0.10
        netmask 255.255.255.0


        Adding a Second Routing Table



        To add a new routing table, the file, /etc/iproute2/rt_tables must be edited. We will call the routing table “rt2” and set its preference to 1. The named file should then appear as follows.



        #
        # reserved values
        #
        255 local
        254 main
        253 default
        0 unspec
        #
        # local
        #
        #1 inr.ruhep
        1 rt2


        Configuring the New Routing Table



        From this point, four commands are needed to achieve our goal. First, the new routing table needs to be populated, which is done using the following command.



        ip route add 10.10.0.0/24 dev eth1 src 10.10.0.10 table rt2
        ip route add default via 10.10.0.1 dev eth1 table rt2


        The first command says that the network, 10.10.0.0/24, can be reached through the eth1 interface. The second command sets the default gateway.
        Routing Rules



        So that the system knows when to use our new routing table, two rules must be configured.



        ip rule add from 10.10.0.10/32 table rt2
        ip rule add to 10.10.0.10/32 table rt2


        These rules say that both traffic from the IP address, 10.10.0.10, as well as traffic directed to or through this IP address, should use the rt2 routing table.






        share|improve this answer













        Apparently the problem is that by default, you can only have one default gateway on a system. The case described would lead to asynchronous routing.



        Solution



        The iproute2 program, which is included in all current Linux distributions and already installed even, as a rule, can be used for the solution of this problem. Normally, a Linux system only has one routing table, in which only one default gateway can make entries. With iproute2, you have the ability to setup an additional routing table, for one thing, and allow this table to be used by the system based on rules, for another.
        Initial Position



        We will assume that we have two interfaces: eth0 and eth1. The two networks that should be used are 192.168.0.0/24 and 10.10.0.0/24, whereby the first IP address in each respective network should be the gateway. The initial configuration would appear as follows. /etc/network/interfaces



        # This file describes the network interfaces available on your system
        # and how to activate them. For more information, see interfaces(5).
        # The loopback network interface

        auto lo
        iface lo inet loopback

        # The primary network interface

        allow-hotplug eth0
        iface eth0 inet static
        address 192.168.0.10
        netmask 255.255.255.0
        gateway 192.168.0.1

        # The secondary network interface
        allow-hotplug eth1
        iface eth1 inet static
        address 10.10.0.10
        netmask 255.255.255.0


        Adding a Second Routing Table



        To add a new routing table, the file, /etc/iproute2/rt_tables must be edited. We will call the routing table “rt2” and set its preference to 1. The named file should then appear as follows.



        #
        # reserved values
        #
        255 local
        254 main
        253 default
        0 unspec
        #
        # local
        #
        #1 inr.ruhep
        1 rt2


        Configuring the New Routing Table



        From this point, four commands are needed to achieve our goal. First, the new routing table needs to be populated, which is done using the following command.



        ip route add 10.10.0.0/24 dev eth1 src 10.10.0.10 table rt2
        ip route add default via 10.10.0.1 dev eth1 table rt2


        The first command says that the network, 10.10.0.0/24, can be reached through the eth1 interface. The second command sets the default gateway.
        Routing Rules



        So that the system knows when to use our new routing table, two rules must be configured.



        ip rule add from 10.10.0.10/32 table rt2
        ip rule add to 10.10.0.10/32 table rt2


        These rules say that both traffic from the IP address, 10.10.0.10, as well as traffic directed to or through this IP address, should use the rt2 routing table.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 19 '16 at 16:45









        EzwigEzwig

        325213




        325213






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f296854%2fis-it-possible-to-ping-8-8-8-8-from-two-interfaces-connected-to-diffrent-wans%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Morgemoulin

            Scott Moir

            Souastre