From 862ef5a72e540b98dc3ba2c041c6a1881abccbc8 Mon Sep 17 00:00:00 2001 From: RobertNils <37214629+RobertNils@users.noreply.github.com> Date: Tue, 2 Jun 2026 14:33:52 +0200 Subject: [PATCH] install-proxy: auto-detect default-route interface for IP lookup IP detection only probed a hardcoded interface list (eth0 ens3 ens4), so on hosts whose primary NIC has a different name (e.g. ens6 on Ubuntu 24.04 and IONOS VPS) NET_IP came back empty. fresh-start.sh was then called with an empty --ip-address and aborted with "Invalid option for --ip-address". Prefer the host's actual default-route interface (via `ip route`) and prepend it to the existing list, keeping the old names as a fallback so behaviour is unchanged on hosts that already worked. Also silence the "Device does not exist" noise from `ip address show` for absent NICs. Co-Authored-By: Claude Opus 4.8 (1M context) --- install/nginx-proxy/install-proxy.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/install/nginx-proxy/install-proxy.sh b/install/nginx-proxy/install-proxy.sh index 6be3537..b58a9fe 100755 --- a/install/nginx-proxy/install-proxy.sh +++ b/install/nginx-proxy/install-proxy.sh @@ -15,8 +15,15 @@ cd $NGINX_PROXY_AUTOMATION_PATH # Get current IP Address NET_INTERFACES=( eth0 ens3 ens4) + +# Prefer the host's actual default-route interface so detection works +# regardless of naming (e.g. ens6 on Ubuntu 24.04 / IONOS), then fall back +# to the well-known list above for backward compatibility. +DEFAULT_IFACE=$(ip -4 route show default 2>/dev/null | awk '{print $5; exit}') +[[ -n "$DEFAULT_IFACE" ]] && NET_INTERFACES=( "$DEFAULT_IFACE" "${NET_INTERFACES[@]}" ) + for i in "${NET_INTERFACES[@]}"; do - NET_IP=$(ip address show $i | grep "inet\b" | head -n 1 | awk '{print $2}' | cut -d/ -f1) + NET_IP=$(ip address show $i 2>/dev/null | grep "inet\b" | head -n 1 | awk '{print $2}' | cut -d/ -f1) if [[ $NET_IP =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then break fi