From 04b0f206473e56b4ed68563d4c671078420f2e74 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 23 Nov 2023 09:54:20 -0300 Subject: [PATCH] fix: discover default interface sometimes docker would change the container interface --- Dockerfile | 1 + whatsmydefaulteth.sh | 3 +++ whatsmyip6.sh | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100755 whatsmydefaulteth.sh diff --git a/Dockerfile b/Dockerfile index 193d0ab..9672abc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,6 +24,7 @@ RUN install -dm 2750 -o root -g root /var/lib/monit COPY --from=build /etc/monitrc /etc/monitrc COPY ./nsupdate.sh /usr/local/bin/nsupdate COPY ./whatsmyip6.sh /usr/local/bin/whatsmyip6 +COPY ./whatsmydefaulteth.sh /usr/local/bin/whatsmydefaulteth COPY ./syslogize.sh /usr/local/bin/syslogize COPY ./zeroconf.sh /usr/local/bin/zeroconf COPY ./zeroconf.conf /etc/zeroconf.conf diff --git a/whatsmydefaulteth.sh b/whatsmydefaulteth.sh new file mode 100755 index 0000000..c5f8225 --- /dev/null +++ b/whatsmydefaulteth.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +ip -6 r | grep default | tr -s " " | cut -d " " -f 5 diff --git a/whatsmyip6.sh b/whatsmyip6.sh index 641fb7d..858a559 100755 --- a/whatsmyip6.sh +++ b/whatsmyip6.sh @@ -1,3 +1,3 @@ #!/bin/sh -ip address show ${1:-eth0} | grep inet6 | grep global | tr -s " " | cut -d " " -f 3 | cut -d / -f 1 +ip address show ${1:-$(whatsmydefaulteth)} | grep inet6 | grep global | tr -s " " | cut -d " " -f 3 | cut -d / -f 1