Last active
April 3, 2018 17:26
-
-
Save consolewitch/da1d89f8cfcfd58ad365e6ea98461f16 to your computer and use it in GitHub Desktop.
get_eth_device_from_adapter_number.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
### | |
# Written by Alex N. Speaks | |
# Takes the position in which a NIC appears in the vmware console as an argument. | |
# Returns the ethernet device name that corresponds to that position number. | |
# Position numbers start at 0 | |
# You can think of this as the old-style ethX number | |
NIC_INDEX=$1 | |
FOUND=1 | |
for dir in /sys/bus/pci/devices/*/ | |
do | |
if [ -f $dir/label ] && \ | |
[ $(cat ${dir}/label|tr -d '\n') == "Ethernet${NIC_INDEX}" ] && \ | |
[ -d $dir/net/ ] | |
then | |
ls $dir/net/ | |
FOUND=0 | |
fi | |
done | |
exit ${FOUND} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found the information to create this script here:
https://communities.vmware.com/message/2739082#2739082
I didn't want to do any weird renaming or disable the new ethernet device naming scheme because of the warnings found in this article: https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/