From 23856d65e21bb0b960882eecff48cdb932c586af Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 25 Nov 2015 16:35:36 -0800 Subject: [PATCH] IP address detection update --- gravity.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index c2d1ff92..49520549 100755 --- a/gravity.sh +++ b/gravity.sh @@ -8,7 +8,9 @@ if [[ -f $piholeIPfile ]];then rm $piholeIPfile else # Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script - piholeIP=$(ip -4 addr show | awk '{match($0,/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/); ip = substr($0,RSTART,RLENGTH); print ip}' | sed '/^\s*$/d' | grep -v "127.0.0.1" | (head -n1)) + IPv4dev=$(ip route get 8.8.8.8 | awk '{print $5}') + piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}') + piholeIP=${piholeIPCIDR%/*} fi # Ad-list sources--one per line in single quotes