diff --git a/apps/rego-tunnel/vpn_scripts/start.sh b/apps/rego-tunnel/vpn_scripts/start.sh index 4ed50b3..6a265a2 100755 --- a/apps/rego-tunnel/vpn_scripts/start.sh +++ b/apps/rego-tunnel/vpn_scripts/start.sh @@ -15,16 +15,12 @@ cp /vpn_scripts/id_ed25519-lenovo /root/.ssh/ 2>/dev/null || true chmod 600 /root/.ssh/id_ed25519-lenovo 2>/dev/null || true get_windows_ip() { - # Method 1: DHCP leases (hostname is "Windows") - local ip=$(awk '/Windows/ {print $3}' /var/lib/misc/dnsmasq.leases 2>/dev/null | head -1) - if [[ -n "$ip" ]]; then echo "$ip"; return; fi - - # Method 2: ip neigh (ARP table) - look for 172.32.x.x on docker interface (VM_NET_IP subnet) - ip=$(ip neigh show dev docker 2>/dev/null | grep -oE '172\.32\.[0-9]+\.[0-9]+' | head -1) - if [[ -n "$ip" ]]; then echo "$ip"; return; fi - - # Method 3: qemu.ip file (if available) - cat /run/shm/qemu.ip 2>/dev/null || true + # Use VM_NET_IP env var if set, otherwise detect from DHCP leases + if [[ -n "${VM_NET_IP:-}" ]]; then + echo "$VM_NET_IP" + return + fi + awk '/Windows/ {print $3}' /var/lib/misc/dnsmasq.leases 2>/dev/null | head -1 } get_container_ip() {