2025-06-04 09:25:52 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
2025-10-14 23:45:08 -04:00
|
|
|
# Copyright (c) Advanced Micro Devices, Inc.
|
|
|
|
|
# SPDX-License-Identifier: MIT
|
2025-06-04 09:25:52 -04:00
|
|
|
|
|
|
|
|
# This script gets the name of the default NIC and writes it to standard output.
|
2025-10-14 23:45:08 -04:00
|
|
|
# NOTE: if command "ip r" finds multiple default NICs, this script will output
|
|
|
|
|
# all of them.
|
|
|
|
|
nics=$(ip r | awk '/^default /{print $5}' | sort -u)
|
2025-06-04 09:25:52 -04:00
|
|
|
|
2025-10-14 23:45:08 -04:00
|
|
|
# nics="ens50f1 ens50f2 ens50f3 ens50f4" # For testing purposes only
|
|
|
|
|
# nics= # For testing purposes only
|
|
|
|
|
|
|
|
|
|
if [ -z "$nics" ]; then
|
|
|
|
|
echo "Error: no default route found" >&2
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "$nics"
|