Exclude interface when send ICMP ping











up vote
0
down vote

favorite












for build small linux application I need to check the internet connectivity of the system. But my box have multiple network interfaces with interfaced for backup internet connection. I need to do some task based on main network connection lose the connectivity.



I used to chose interface using -i with ping command



ping -I eth0 x.x.x.x 


but with this method i have to mention all the available interfaces on my application. Other than doing this is there any way to do something like this



ping -I !bkp0 x.x.x.x 


basically I need to check the connectivity of all the links except backup link










share|improve this question




























    up vote
    0
    down vote

    favorite












    for build small linux application I need to check the internet connectivity of the system. But my box have multiple network interfaces with interfaced for backup internet connection. I need to do some task based on main network connection lose the connectivity.



    I used to chose interface using -i with ping command



    ping -I eth0 x.x.x.x 


    but with this method i have to mention all the available interfaces on my application. Other than doing this is there any way to do something like this



    ping -I !bkp0 x.x.x.x 


    basically I need to check the connectivity of all the links except backup link










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      for build small linux application I need to check the internet connectivity of the system. But my box have multiple network interfaces with interfaced for backup internet connection. I need to do some task based on main network connection lose the connectivity.



      I used to chose interface using -i with ping command



      ping -I eth0 x.x.x.x 


      but with this method i have to mention all the available interfaces on my application. Other than doing this is there any way to do something like this



      ping -I !bkp0 x.x.x.x 


      basically I need to check the connectivity of all the links except backup link










      share|improve this question















      for build small linux application I need to check the internet connectivity of the system. But my box have multiple network interfaces with interfaced for backup internet connection. I need to do some task based on main network connection lose the connectivity.



      I used to chose interface using -i with ping command



      ping -I eth0 x.x.x.x 


      but with this method i have to mention all the available interfaces on my application. Other than doing this is there any way to do something like this



      ping -I !bkp0 x.x.x.x 


      basically I need to check the connectivity of all the links except backup link







      network-interface ping icmp






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago









      Jeff Schaller

      35.8k952119




      35.8k952119










      asked 2 days ago









      gripen fighter

      182110




      182110






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          Do you just need one to work to call it "good"? If you need to check the connectivity for all of the interfaces except one, and you know the name of the interface, you could script it:



          for i in `ip -br link | cut -d" " -f1`
          do
          if [ ${i} != "bkp0" ]
          then
          ping -c 1 -I ${i} so.me.add.ress
          fi
          done





          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',
            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%2f481597%2fexclude-interface-when-send-icmp-ping%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








            up vote
            1
            down vote













            Do you just need one to work to call it "good"? If you need to check the connectivity for all of the interfaces except one, and you know the name of the interface, you could script it:



            for i in `ip -br link | cut -d" " -f1`
            do
            if [ ${i} != "bkp0" ]
            then
            ping -c 1 -I ${i} so.me.add.ress
            fi
            done





            share|improve this answer

























              up vote
              1
              down vote













              Do you just need one to work to call it "good"? If you need to check the connectivity for all of the interfaces except one, and you know the name of the interface, you could script it:



              for i in `ip -br link | cut -d" " -f1`
              do
              if [ ${i} != "bkp0" ]
              then
              ping -c 1 -I ${i} so.me.add.ress
              fi
              done





              share|improve this answer























                up vote
                1
                down vote










                up vote
                1
                down vote









                Do you just need one to work to call it "good"? If you need to check the connectivity for all of the interfaces except one, and you know the name of the interface, you could script it:



                for i in `ip -br link | cut -d" " -f1`
                do
                if [ ${i} != "bkp0" ]
                then
                ping -c 1 -I ${i} so.me.add.ress
                fi
                done





                share|improve this answer












                Do you just need one to work to call it "good"? If you need to check the connectivity for all of the interfaces except one, and you know the name of the interface, you could script it:



                for i in `ip -br link | cut -d" " -f1`
                do
                if [ ${i} != "bkp0" ]
                then
                ping -c 1 -I ${i} so.me.add.ress
                fi
                done






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 2 days ago









                kevlinux

                1642




                1642






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f481597%2fexclude-interface-when-send-icmp-ping%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