Score:0

Cannot ping reachable host when using eth0 as interface

ru flag

I wrote a watchdog script that checks whether the VPN server on my machine (which is reachable over the internet) is working properly. There have been random issues after long runs that required a reboot.

In a loop, the target host is pinged. After 20 unsuccessful pings, the machine reboots.

Unfortunately, the host used for the ping resolves to an IP that is bound to interface tap0. RTTs of below a millisecond indicate that no packet has been sent over the internet, so the route I monitor is bridged on the local machine. The machine is connected to the internet via eth0 and can be pinged from any computer. But when using ping -I eth0 <host>, all I get are timeouts.

traceroute shows the correct route when using -i eth0 but leaving out the interface results in an instant output with one line, pointing directly to my machine (as the host name resolves to the IP address of tap0).

Below is my script (okay, this might not really help, but for those of you who are interested, have a look at it):

#!/bin/bash

unsuccessful=0

while [ $unsuccessful -lt 20 ]; do
  echo -n "  ->"
  ping -c 1 -W 2 <addr of vpn server> > /dev/null
  if [ $? -ne 0 ]; then
    ((unsuccessful++))
    echo "Unsuccessful: $unsuccessful"
  else
    unsuccessful=0
    echo -n "<-  "
  fi
  sleep 10
done

echo "Bye"
reboot
Ercksen avatar
ru flag
By the way, using `-I eth0` works for other hosts on the internet
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.