I puchased a domain, say fireworks.com, and I would like to call my server ubuntu-18-04.
How am I expected to edit /etc/hosts? Is it possible to add multiple aliases as follows?   localhost   ubuntu-18-04.fireworks.com fireworks.com ubuntu-18-04 ubuntu-18-04.fireworks.com fireworks.com ubuntu-18-04

Usually in documentation the /etc/hosts format has only three records:

1. An IP address
2. A fqdn
3. The hostname

Is it possible (and necessary?) to add a fourth record, as in my previous example, including fireworks.com? I would like to receive mail as [email protected] other than as [email protected]

1 Answer 1


From man hosts:

This manual page describes the format of the /etc/hosts file. This file is a simple text file that associates IP addresses with hostnames, one line per IP address. For each host a single line should be present with the following information:

          IP_address canonical_hostname [aliases...]

Yes, you can add multiple lines of IPs and aliases. But for your mail reception, I'd suggest you use DNS for domain name mapping. Use dnsmasq to make it easier, it resolves from /etc/hosts too

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .