setting the hostname on ubuntu 18.04 / iRedMail

Hi there

I am a bit confused on how to est the hostname on an 18.04 server.

I intend to use the server as a mail server running iRedMail.

The instruction to set up iRedMail instructs to set :

On Debian/Ubuntu Linux, hostname is set in two

* |/etc/hostname|: short hostname, not FQDN.


and to to set etc hosts:

* |/etc/hosts|: static table lookup for hostnames.*Warning*: Please
list the FQDN hostname as first item.

|# Part of file: /etc/hosts mx localhost
localhost.localdomain |

so what I did:

in /etc/cloud/cloud.cfg

I changed:

# This will cause the set+update hostname module to not operate (if true)
preserve_hostname: true

in /etc/hostname:


in /etc/hosts: localhost

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

However when I execute:

hostname -f

I get:


How should I setup the hostname, that I can use the server as a
mailserver for

thannks, robert


Re: setting the hostname on ubuntu 18.04 / iRedMail

By Tom H at 01/21/2019 - 19:24

On Wed, Jan 9, 2019 at 12:41 PM robert rottermann < ... at redcor dot ch> wrote:
If you're using a dynamic address

# cat /etc/hosts localhost

If you're using a static address and don't want to use the above

# cat /etc/hosts localhost

But you can use

# cat /etc/hosts localhost

you're using systemd-resolved and install lbnss-resolve
or if
you're not using systemd-resolved and install lbnss-myhostname

Re: setting the hostname on ubuntu 18.04 / iRedMail

By compdoc at 01/09/2019 - 15:28

On 1/9/19 4:39 AM, robert rottermann wrote:
mx is an unusal name for a mail server in my opinion, but I suppose it
doesn't matter. I tend to use, or

However, an 'mx' record needs to be set correctly with the business that
hosts your domain name, such as Network Solutions or Godaddy, etc. It
needs to point to the address of your mail server.

This is how I set my hosts file: localhost mail

Use the real local ip address. I think "" is placed there by
network-manager, but not sure. I dont use it.

And your hostname is correct. Its just the single name of the server.