#!/bin/bash # Test interface detection logic (no root required) echo "Testing Interface Detection Logic" echo "=================================" echo "" # Get all physical interfaces PHYSICAL_IFACES=() for iface in /sys/class/net/*; do iface_name=$(basename "$iface") # Skip loopback, virtual interfaces, bridges, bonds, and VLANs if [[ "$iface_name" == "lo" ]] || \ [[ -L "$iface/device" ]] && [[ ! -d "$iface/device" ]] || \ [[ -d "$iface/bridge" ]] || \ [[ -d "$iface/bonding" ]] || \ [[ "$iface_name" =~ \. ]]; then continue fi # Check if it's a physical interface if [ -d "$iface/device" ] || [ -L "$iface/device" ]; then PHYSICAL_IFACES+=("$iface_name") fi done # Sort interfaces for consistent selection IFS=$'\n' PHYSICAL_IFACES=($(sort <<<"${PHYSICAL_IFACES[*]}")) unset IFS echo "Detected Physical Interfaces:" for i in "${!PHYSICAL_IFACES[@]}"; do idx=$((i+1)) iface="${PHYSICAL_IFACES[$i]}" if [ $idx -eq 1 ]; then echo " NIC $idx (LAN): $iface → vmbr0" elif [ $idx -eq 2 ]; then echo " NIC $idx (WAN): $iface → vmbr1" else echo " NIC $idx (unused): $iface" fi done echo "" if [ ${#PHYSICAL_IFACES[@]} -ge 2 ]; then NIC1="${PHYSICAL_IFACES[0]}" NIC2="${PHYSICAL_IFACES[1]}" echo "Configuration Preview:" echo "======================" echo "" cat <