Skip to content

Instantly share code, notes, and snippets.

@greyltc
Created August 8, 2016 11:18
Show Gist options
  • Save greyltc/e8dbaeb4c1f7ec806a7b754601ec7a4d to your computer and use it in GitHub Desktop.
Save greyltc/e8dbaeb4c1f7ec806a7b754601ec7a4d to your computer and use it in GitHub Desktop.
bash script to change interface to 100baseTx given its mac address
#!/usr/bin/env bash
set -eu -o pipefail
# this is the mac address of the interface we're interested in
MAC_OI="20:47:47:f8:f4:71"
for i in /sys/class/net/* ; do
I_MAC=$(cat $i/address)
INTERFACE=$(basename $i/)
if [ "$MAC_OI" = "$I_MAC" ]; then
ETH_INTERFACE=$INTERFACE
fi
done
mii-tool -F 100baseTx-FD ${ETH_INTERFACE}
ethtool -s ${ETH_INTERFACE} speed 100 duplex full
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment