Changing Server Hostname - KeegMitch/Operations-Engineering-group-c GitHub Wiki

How to change your server hostname on Ubuntu 18.04 LTS

  1. Go to the hostname file here, sudo nano /etc/hostname if using nano editor, if using vim sudo vim /etc/hostname, screenshot below is for the management server

image

  1. Use the command sudo reboot which will close putty, reopen the server and login, The screenshot below is the new hostname for the database server, "db-c" shown in the prompt, which serves the purpose of using this server for databases

image

Update: The hostnames for all the other servers all match the prompt/purpose they serve

Management server:

image

App server:

image

Backup server:

image

Changing the hosts file

  1. Go on to the hosts file: sudo vim /etc/hosts

  2. Add the hostname into the public IP address so that it's recognised by other servers, make sure you do this on all servers:

In Management server:

image

In DB server:

image

  1. Make sure it's consistent with the hostname in /etc/hostname, this will be important when mapping them to configure puppet

In Management server:

image

In DB server:

image

  1. Testing that the servers can communicate with each other

ping: Note that only the private addresses work and not public, but the hostnames work

image

image

image

Issue: we can't ping the db-c hostname but it works on nslookup and the private ip address

image

nslookup

image

image