VHostLoom/firewall/detect-wan.sh

14 lines
272 B
Bash

#!/bin/bash
# Detects the most likely WAN interface and prints it
# Look for interface with default route
WAN_IF=$(ip route | awk '/default/ {print $5}' | head -n 1)
if [ -z "$WAN_IF" ]; then
echo "Could not detect WAN interface." >&2
exit 1
fi
echo "$WAN_IF"