summary refs log tree commit diff
diff options
context:
space:
mode:
authorNakidai <nakidai@disroot.org>2025-07-31 20:47:27 +0300
committerNakidai <nakidai@disroot.org>2025-07-31 20:58:29 +0300
commit1271e6efcb473dba79ba7249569d8e6fb296e96f (patch)
tree86464433003b3869a9814df74571aff070ef8571
parent16dabf158b31b515d1e5cdb8f94832f86dcbc61b (diff)
downloadfatvpn-1271e6efcb473dba79ba7249569d8e6fb296e96f.tar.gz
fatvpn-1271e6efcb473dba79ba7249569d8e6fb296e96f.zip
Use tail with dig
If dig(1) finds some inaccessible nameserver then it for some reason
will shit out that into stdout

To ignore that tail(1) can be used instead of head(1)
-rwxr-xr-xfvpn_launch.sh2
-rwxr-xr-xfvpn_stop.sh2
2 files changed, 2 insertions, 2 deletions
diff --git a/fvpn_launch.sh b/fvpn_launch.sh
index 3b158de..d5b84be 100755
--- a/fvpn_launch.sh
+++ b/fvpn_launch.sh
@@ -30,7 +30,7 @@ ip link set $TAP up
 # 2) masquarade
 # 3) firewall forward rules configured/disabled
 if [ "$1" = "all" ]; then
-	srv_ip=$(dig +short $SERVER | head -1)
+	srv_ip=$(dig +short $SERVER | tail -1)
 	gw=$(ip route get $srv_ip | head -1 | awk '{print $3}')
 	ip route add $srv_ip/32 via $gw
 	ip route add   0.0.0.0/1 via $INTERNAL_SRV_IP
diff --git a/fvpn_stop.sh b/fvpn_stop.sh
index 5149fba..e1dca4d 100755
--- a/fvpn_stop.sh
+++ b/fvpn_stop.sh
@@ -5,7 +5,7 @@ SERVER=vpn.example.org
 
 ip route del   0.0.0.0/1
 ip route del 128.0.0.0/1
-ip route del "$(dig +short $SERVER | head -1)/32"
+ip route del "$(dig +short $SERVER | tail -1)/32"
 
 killall fatvpn
 ip link set $TAP down