Last active
September 6, 2024 13:18
-
-
Save roelds/b454681bb3ee17a19f354bca57f7cf02 to your computer and use it in GitHub Desktop.
Show Local Hosts Entry & Device Name & MAC
This file contains 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
# uses network-manager | |
myip=$(nmcli device show | grep -m 1 "IP4.ADDRESS" | awk '{print substr($2, 1, length($2)-3)}') | |
myentry=$(echo -n $myip && echo -e "\t thishost.thisdomain.local" && echo -e "\t thishost") | |
echo $myentry | |
# get nic device name (enps) | |
nmcli device show | grep -m 1 "GENERAL.DEVICE" | awk '{print $2}' | |
# get nic mac addr | |
nmcli device show | grep -m 1 "GENERAL.HWADDR" | awk '{print $2}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment