Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
interfaces=(eth0 eth1 eth2) # which interfaces to auto-detect, in descending order of priority
interface="eth0" # the default/current interface
while true; do
newif="$interface"
for i in "${interfaces[@]}"; do
if $(ip link show dev "$i"); then
newif="$i"
fi
done
if [[ ! "$interface" == "$newif" ]]; then
echo "Switching from $interface to $newif"
brctl delif br0 "$interface" || true
brctl addif br0 "$newif"
interface="$newif"
fi
sleep 5
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.