0

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

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.