Configuring A Custom Hostname

We want to configure a custom hostname so our server can better communicate with the domain we registered earlier.

I recommend setting your hostname to the domain you registered earlier, minus the .com at the end.

For example, I registered the domain:

So I'm going to set my hostname as: quailavocadotoast

Copy the following command into your CLI.

hostnamectl set-hostname example-hostname

Replace example-hostname with the domain you registered earlier. In this example, we're using quailavocadotoast.

Updating Your Hosts File

Now we want to update the hosts file on your server.

Use the following command:

nano /etc/hosts

This will open up Linux's text editor Nano. You won't be able to use your mouse wheel to scroll up and down, you'll have to navigate using the arrow keys and Page Up Page Down keys.

Change the second line of your hosts file by adding in your domain and hostname after localhost.

Use your arrow keys to navigate to the end of localhost, hit the spacebar one time, and type in your domain followed by .com (or whatever domain ender you have) then hit the spacebar one more time and type the hostname you just set.

See the example below.

Disabling IPV6

Before we leave, we want to disable all IPV6 routes to this server and only allow it to use IPV4. This will simplify everything (from personal experience), especially for someone new to server management.

To accomplish this, one step is commenting out the last three lines in this file.

To comment them out, just put a '#' at the beginning of each line, as in the example shown below.

comment out ipv6

Saving Your Changes

To exit and save this file with your new changes, hold CTRL on your keyboard and press X. Press Y and then hit enter to save the file.

Now from the command line enter this command:

nano /etc/sysctl.conf

You'll be in the Nano editor again with another text file.
Copy the following lines and paste them at the bottom of the text file.

#Disable IPV6 Access
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Like so:

Now we'll add a limited user to improve our security before we reboot our server and change how we log in forever.