diff --git a/README.md b/README.md index b97e37f..05dcbbb 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,8 @@ One crucial thing to know before starting is the docker-pi-hole container needs ``` IMAGE='diginc/pi-hole' -NIC='eth0' -IP=$(ip addr show $NIC | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) +IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0 +IP="${IP:-$IP_LOOKUP}" # use $IP, if set, otherwise IP_LOOKUP docker run -p 53:53/tcp -p 53:53/udp -p 80:80 --cap-add=NET_ADMIN -e ServerIP="$IP" --name pihole -d $IMAGE # Recommended auto ad list updates & log rotation: diff --git a/docker_dev.sh b/docker_dev.sh index 7116bc8..2d3b4a5 100755 --- a/docker_dev.sh +++ b/docker_dev.sh @@ -3,7 +3,8 @@ docker build -f alpine.docker -t diginc/pi-hole:alpine . docker tag diginc/pi-hole:alpine diginc/pi-hole:latest docker build -f debian.docker -t diginc/pi-hole:debian . -IP=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) +IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0 +IP="${IP:-$IP_LOOKUP}" # use $IP, if set, otherwise IP_LOOKUP # Alternative ports to not conflict with my real instance # shellcheck disable=SC2068 @@ -15,4 +16,3 @@ docker run -it --rm --cap-add=NET_ADMIN \ -e VIRTUAL_HOST='pihole.diginc.lan:5080' \ $@ \ diginc/pi-hole:"${image:-alpine}" - diff --git a/docker_run.sh b/docker_run.sh index 2a6799c..54ae685 100755 --- a/docker_run.sh +++ b/docker_run.sh @@ -1,7 +1,7 @@ #!/bin/bash IMAGE=${1:-'diginc/pi-hole:alpine'} -NIC=${2:-'eth0'} -IP=$(ip addr show "$NIC" | grep "inet\b" | awk '{print $2}' | cut -d/ -f1) +IP_LOOKUP="$(ip route get 8.8.8.8 | awk '{ print $NF; exit }')" # May not work for VPN / tun0 +IP="${IP:-$IP_LOOKUP}" # use $IP, if set, otherwise IP_LOOKUP # Default ports + daemonized docker container docker run -p 53:53/tcp -p 53:53/udp -p 80:80 \