Skip to content

Instantly share code, notes, and snippets.

@roelds
Last active September 6, 2024 13:18

Revisions

  1. roelds revised this gist Sep 6, 2024. No changes.
  2. roelds revised this gist Sep 6, 2024. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions show-self-hosts.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,10 @@
    # 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}'
  3. roelds created this gist Sep 1, 2024.
    3 changes: 3 additions & 0 deletions show-self-hosts.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    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