Skip to content

Instantly share code, notes, and snippets.

@roelds
Last active September 6, 2024 13:18
Show Gist options
  • Save roelds/b454681bb3ee17a19f354bca57f7cf02 to your computer and use it in GitHub Desktop.
Save roelds/b454681bb3ee17a19f354bca57f7cf02 to your computer and use it in GitHub Desktop.
Show Local Hosts Entry & Device Name & MAC
# 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