From b2dfe10a5a36f8b29ad0e8464a99c7bfc4863eb7 Mon Sep 17 00:00:00 2001 From: nacho Date: Wed, 26 Jul 2017 06:49:52 +0200 Subject: [PATCH] dnsmasq detect ip --- etc/nextcloudpi-config.d/dnsmasq.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/etc/nextcloudpi-config.d/dnsmasq.sh b/etc/nextcloudpi-config.d/dnsmasq.sh index a3f70a61e..c59cf5d5d 100644 --- a/etc/nextcloudpi-config.d/dnsmasq.sh +++ b/etc/nextcloudpi-config.d/dnsmasq.sh @@ -16,7 +16,6 @@ ACTIVE_=no DOMAIN_=mycloud.ownyourbits.com -IP_=127.0.0.1 DNSSERVER_=8.8.8.8 CACHESIZE_=150 DESCRIPTION="DNS server with cache" @@ -41,6 +40,11 @@ configure() { [[ $ACTIVE_ != "yes" ]] && { service dnsmasq stop; update-rc.d dnsmasq disable; return; } + local IFACE=$( ip r | grep "default via" | awk '{ print $5 }' ) + local IP=$( ip a | grep "global $IFACE" | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 ) + + [[ "$IP" == "" ]] && { echo "could not detect IP"; return 1; } + cat > /etc/dnsmasq.conf <