From 4458cceb1b29b4b85fbe4f38f3381a6621048d00 Mon Sep 17 00:00:00 2001 From: Lenard Hess Date: Sun, 26 Feb 2023 11:31:03 +0100 Subject: [PATCH] Add environment variable to override FRITZ!Box hostname For setups with a different DNS server than the FRITZ!Box, the fritz.box DNS entry may be missing. --- sample-get-ip-from-fritzbox | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sample-get-ip-from-fritzbox b/sample-get-ip-from-fritzbox index 079df07..05c8277 100755 --- a/sample-get-ip-from-fritzbox +++ b/sample-get-ip-from-fritzbox @@ -9,12 +9,13 @@ # # All credits for this one liner go to the author of this blog: # http://scytale.name/blog/2010/01/fritzbox-wan-ip -# As the author explains its not required to tamper with the provided IP for the FritzBox -# as it always binds to that address for UPnP. # Disclaimer: It might be necessary to make the script executable +# Set default hostname to connect to the FritzBox +: ${FRITZ_BOX_HOSTNAME:=fritz.box} + curl -s -H 'Content-Type: text/xml; charset="utf-8"' \ -H 'SOAPAction: urn:schemas-upnp-org:service:WANIPConnection:1#GetExternalIPAddress' \ -d ' ' \ - 'http://fritz.box:49000/igdupnp/control/WANIPConn1' | \ + "http://$FRITZ_BOX_HOSTNAME:49000/igdupnp/control/WANIPConn1" | \ grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'