#!/usr/bin/env bash # Fix NPMplus (VMID 10233) network: restore the correct LAN gateway and preserve the # documented dual-address layout when present (.166 for admin, .167 for UDM Pro/public ingress). # Run on Proxmox host r630-01 or: ssh root@192.168.11.11 'bash -s' < scripts/npmplus/fix-npmplus-ip-and-gateway.sh set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" [ -f "${PROJECT_ROOT}/config/ip-addresses.conf" ] && source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true VMID="${NPMPLUS_VMID:-10233}" NPM_IP_ETH0="${IP_NPMPLUS_ETH0:-192.168.11.166}" NPM_IP="${IP_NPMPLUS:-192.168.11.167}" GATEWAY="${NETWORK_GATEWAY:-192.168.11.1}" if ! command -v pct &>/dev/null; then echo "Run this script on the Proxmox host (e.g. ssh root@192.168.11.11)" exit 1 fi CURRENT_CFG="$(pct config "$VMID" 2>/dev/null || true)" HAS_NET1=0 if grep -q '^net1:' <<<"$CURRENT_CFG"; then HAS_NET1=1 fi echo "NPMplus VMID $VMID: restore gateway=$GATEWAY and start" if [[ "$HAS_NET1" == "1" ]]; then echo "Preserving dual-interface layout: eth0=${NPM_IP_ETH0}, eth1=${NPM_IP}" pct set "$VMID" -net0 "name=eth0,bridge=vmbr0,ip=${NPM_IP_ETH0}/24" pct set "$VMID" -net1 "name=eth1,bridge=vmbr0,ip=${NPM_IP}/24,gw=${GATEWAY}" else echo "Single-interface layout detected: eth0=${NPM_IP}" pct set "$VMID" -net0 "name=eth0,bridge=vmbr0,ip=${NPM_IP}/24,gw=${GATEWAY}" fi pct stop "$VMID" 2>/dev/null || true sleep 2 pct start "$VMID" echo "Started. Wait ~30s then run verify-npmplus-running-and-network.sh"