diff options
author | Karel Kočí <cynerd@email.cz> | 2017-03-11 20:15:39 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-03-11 20:15:39 +0100 |
commit | ec71cdf84cf4c2d38f42fef698e84ae1f2803e71 (patch) | |
tree | 442df139f97cc5c39137e2c2d7311d3422dafacc | |
parent | de1cb4181f8d92f2c9f2bd6035e80cca6e5d86be (diff) | |
download | myconfigs-ec71cdf84cf4c2d38f42fef698e84ae1f2803e71.tar.gz myconfigs-ec71cdf84cf4c2d38f42fef698e84ae1f2803e71.tar.bz2 myconfigs-ec71cdf84cf4c2d38f42fef698e84ae1f2803e71.zip |
Ping default gateway if no internet connection detected
-rwxr-xr-x | config/i3blocks/scripts/iface | 11 | ||||
-rwxr-xr-x | local/bin/lxc-net | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/config/i3blocks/scripts/iface b/config/i3blocks/scripts/iface index 134d66b..a9a558b 100755 --- a/config/i3blocks/scripts/iface +++ b/config/i3blocks/scripts/iface @@ -65,11 +65,18 @@ PINGV="-c 1 -w 1" if ping $PINGV nic.cz >/dev/null 2>&1; then echo \#00FF00 # color else + # Ping nic.cz by ip if ping $PINGV 217.31.205.50 >/dev/null 2>&1; then # No DNS echo \#FFFF00 # color else - # No internet connection - echo \#FF0000 # color + # Ping default gateway of this interface + if ping $PINGV $(ip route show dev $IF | awk '/^default via/ {print $3}') >/dev/null 2>&1; then + # No internet connection but gateway accessible + echo \#FF0F00 # color + else + # No internet connection + echo \#FF0000 # color + fi fi fi diff --git a/local/bin/lxc-net b/local/bin/lxc-net index ccefd59..0821571 100755 --- a/local/bin/lxc-net +++ b/local/bin/lxc-net @@ -9,7 +9,7 @@ fi if [ "$1" = "clean" ]; then kill $(cat /tmp/lxc-dhcpd.pid) rm -f /tmp/lxc-dhcpd.pid /tmp/lxc-dhcpd.conf - ip link del name vbr0 + ip link del dev vbr0 exit fi |