Reset a dynamically assigned host name

Recently I noticed that when using DHCP my RedHat system was picking up a dynamically generated host name, which was then being used when I registered the system with the subscription manager.

Fortunately it is easy to clear the dynamic host name and restore some sanity.

The output below shows the transient host name (‘client001’ in this example but usually something more random).

[root@client001 ~]# hostnamectl status
   Static hostname: localhost.localdomain
Transient hostname: client001.example.com
         Icon name: computer-vm
           Chassis: vm
        Machine ID: f6a436447669f274afa9dc5bfd6d5f81
           Boot ID: c83cd33b9d9f5ca642d2895e5fb88c7b
    Virtualization: vmware
  Operating System: Red Hat Enterprise Linux
       CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
            Kernel: Linux 3.10.0-514.el7.x86_64
      Architecture: x86-64

To clear it just redefine it as follows (setting it to be the same as the static host name also works).

[root@client001 ~]# hostnamectl set-hostname "" --transient

Sorted…

[root@client001 ~]# hostnamectl status
   Static hostname: localhost.localdomain
         Icon name: computer-vm
           Chassis: vm
        Machine ID: f6a436447669f274afa9dc5bfd6d5f81
           Boot ID: c83cd33b9d9f5ca642d2895e5fb88c7b
    Virtualization: vmware
  Operating System: Red Hat Enterprise Linux
       CPE OS Name: cpe:/o:redhat:enterprise_linux:7.3:GA:server
            Kernel: Linux 3.10.0-514.el7.x86_64
      Architecture: x86-64
[root@client001 ~]# 

The prompt won’t change until you logout and back in again (and yes – I know you can reset it from the command line but there is more than one way to do that and they won’t all work on every system).

[root@localhost ~]#

Advertisements
This entry was posted in RedHat. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.