diff --git a/routlin/install.py b/routlin/install.py index 129449b..7e37bc0 100644 --- a/routlin/install.py +++ b/routlin/install.py @@ -418,13 +418,15 @@ def setup_caddy(domain, email): def _lan_ip(): - """Best-effort local LAN IP for the informational message.""" + """Read the LAN IP from routlin's networkd config files.""" + import glob try: - s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - s.connect(("8.8.8.8", 80)) - return s.getsockname()[0] + for path in sorted(glob.glob("/etc/systemd/network/10-routlin-*.network")): + for m in re.finditer(r'^Address=(\d+\.\d+\.\d+\.\d+)/', Path(path).read_text(), re.MULTILINE): + return m.group(1) except Exception: - return "127.0.0.1" + pass + return "this server" # ===================================================================