#!/usr/bin/env bash # Pin Dankserver's fleet NIC (eno1, 192.168.0.235) as the primary default route. # # The 2026-09-20 board swap (TUF GAMING B650-E -> ProArt B850-Creator WiFi NEO) # brought up a second port, eno2, which took DHCP and — with NetworkManager's # default per-connection metric of 100 — came up with metric 101 while eno1's # static gateway got 102. Outbound traffic therefore started leaving by eno2 # even though every fleet peer, Caddy upstream and monitoring target addresses # this host as .235. Keep eno2 (it is a real second link) but make it secondary: # route metrics decide the default route, so eno1 wins while eno2 stays a # failover. # # Run on Dankserver. Idempotent; NetworkManager owns these connections (the # netplan files under /etc/netplan are its generated shim, so edit via nmcli). # # bash scripts/dankserver-route-primary.sh [--check] set -euo pipefail PRIMARY='Wired connection 1' # eno1, static 192.168.0.235, fleet address SECONDARY='Wired connection 2' # eno2, DHCP 192.168.0.247 PRIMARY_IF='eno1' SECONDARY_IF='eno2' PRIMARY_METRIC=100 SECONDARY_METRIC=200 show() { printf 'routes:\n'; ip route show default printf 'wanted: %s metric %s, %s metric %s\n' \ "$PRIMARY" "$PRIMARY_METRIC" "$SECONDARY" "$SECONDARY_METRIC" } if [[ "${1:-}" == '--check' ]]; then for conn in "$PRIMARY" "$SECONDARY"; do printf '%s: ipv4=%s ipv6=%s\n' "$conn" \ "$(nmcli -g ipv4.route-metric connection show "$conn")" \ "$(nmcli -g ipv6.route-metric connection show "$conn")" done show exit 0 fi nmcli connection modify "$PRIMARY" \ ipv4.route-metric "$PRIMARY_METRIC" ipv6.route-metric "$PRIMARY_METRIC" nmcli connection modify "$SECONDARY" \ ipv4.route-metric "$SECONDARY_METRIC" ipv6.route-metric "$SECONDARY_METRIC" # `nmcli device reapply ` pushes the edited profile without tearing the # link down. `nmcli connection up` would re-run DHCP and briefly drop the route # this session rides on, and `connection reapply` is not a verb (NM 1.54). nmcli device reapply "$PRIMARY_IF" nmcli device reapply "$SECONDARY_IF" show if [[ "$(ip route show default | head -1)" != *"dev $PRIMARY_IF"* ]]; then printf 'ERROR: eno1 is still not the preferred default route\n' >&2 exit 1 fi printf 'eno1 is the preferred default route; eno2 remains up as failover.\n'