Files
Notes/Networking/Hostname.md

1.1 KiB

Setup Hostname

Log into the hostname (ssh)

Run the following command

sudo hostnamectl set-hostname NewHostName

Also need to update the hosts name

sudo vi /etc/hosts

Example of old host file

127.0.0.1       localhost
127.0.1.1       old-hostname.vocus.co.nz old-hostname

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Example of updated host

127.0.0.1       localhost
127.0.1.1       New-hostname.vocus.co.nz New-hostname

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

While hostnamectl typically applies the changes immediately, some services or applications might still be referencing the old hostname. You can restart network services or reboot the system for a complete refresh, although often it's not strictly necessary. To restart network services:

sudo systemctl restart network-online.target

or just reboot

Sudo Reboot