Skip to content

Commit

Permalink
force dig to use vpn tunnel ip
Browse files Browse the repository at this point in the history
  • Loading branch information
binhex committed Aug 3, 2017
1 parent 38cf86e commit d895547
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions run/root/getvpnextip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ source /home/nobody/getvpnip.sh

while true; do

external_ip="$(dig TXT +short o-o.myaddr.l.google.com @${pri_external_ip_ns} | tr -d '"')"
external_ip="$(dig -b ${vpn_ip} TXT +short o-o.myaddr.l.google.com @${pri_external_ip_ns} | tr -d '"')"
exit_code="${?}"

# if error then try secondary name server
if [[ "${exit_code}" != 0 ]]; then

echo "[warn] Failed to get external IP from Google NS, trying OpenDNS..."

external_ip="$(dig +short myip.opendns.com @${sec_external_ip_ns})"
external_ip="$(dig -b ${vpn_ip} +short myip.opendns.com @${sec_external_ip_ns})"
exit_code="${?}"

if [[ "${exit_code}" != 0 ]]; then
Expand Down

0 comments on commit d895547

Please sign in to comment.