diff --git a/routlin/install.py b/routlin/install.py index 7e37bc0..fddee33 100644 --- a/routlin/install.py +++ b/routlin/install.py @@ -418,15 +418,28 @@ def setup_caddy(domain, email): def _lan_ip(): - """Read the LAN IP from routlin's networkd config files.""" + """Read the LAN IP from routlin's networkd config files. + + Prefers the physical (untagged) interface — its Name has no dot. + Falls back to the first address found across all routlin network files. + """ import glob + fallback = None try: 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) + content = Path(path).read_text() + name_m = re.search(r'^Name=(.+)$', content, re.MULTILINE) + addr_m = re.search(r'^Address=(\d+\.\d+\.\d+\.\d+)/', content, re.MULTILINE) + if not name_m or not addr_m: + continue + ip = addr_m.group(1) + if '.' not in name_m.group(1).strip(): # physical interface, no dot + return ip + if fallback is None: + fallback = ip except Exception: pass - return "this server" + return fallback or "this server" # ===================================================================