How To Change The Hostname/ServerName Of Your Carbonio Community Edition Server | Carbonio CE

In this article, we will see how you can change the hostname/servername of your Carbonio Community Edition email server.

Changing hostname of Carbonio CE email server is a critical task. Before proceeding to this task, it is strongly recommended to keep backup/snapshot of the server.

We have a Carbonio CE email server. We are going to change it’s hostname. But before doing it let’s take a look at some current information of the server.

zextras@mail:~$ hostname
mail.example.com
zextras@mail:~$
zextras@mail:~$
zextras@mail:~$ cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 mail


192.168.1.192   mail.example.com        mail


# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback localhost
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
root@mail:~#
root@mail:~# tail -n 5 /etc/dnsmasq.conf

server=1.1.1.1
mx-host=example.com,mail.example.com,50
host-record=example.com,192.168.1.192
host-record=mail.example.com,192.168.1.192
root@mail:~#

We can see that our existing server’s hostname is mail.example.com. You can also try below mentioned command to check your server’s hostname.

zextras@mail:~$ zmlocalconfig | grep hostname

We can access our webmail using the existing hostname via our webmail.

carbonio ce webmail login page

Now our goal is to change the existing hostname(mail.example.com) to mail.newserver.com

After changing the hostname, we will check the status of the following parameters:

  • /etc/hostname
  • /etc/hosts
  • zmcontrol status
  • Mail send/receive

Let’s proceed with the steps.

Step-1

Change the hostname of your server.

root@mail:~# cat /etc/hostname
mail.newserver.com

Step-2

Modify the /etc/hosts of your server and add the new hostname as followings:

root@mail:~# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 mail

192.168.1.192   mail.example.com        mail
192.168.1.192   mail.newserver.com      mail

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

Step-3 (Optional)

Modify the existing dnsmasq configuration of your server, if you have any

root@mail:~# tail -n 5 /etc/dnsmasq.conf

server=1.1.1.1
mx-host=newserver.com,mail.newserver.com.com,50
host-record=newserver.com,192.168.1.192
host-record=mail.newserver.com,192.168.1.192
root@mail:~#

After modifying the dnsmasq configuration, don’t forget to restart & check the status of the service

root@mail:~# tail -n 5 /etc/dnsmasq.conf

server=1.1.1.1
mx-host=newserver.com,mail.newserver.com.com,50
host-record=newserver.com,192.168.1.192
host-record=mail.newserver.com,192.168.1.192
root@mail:~#
root@mail:~# systemctl status dnsmasq
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
     Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-12-28 16:56:12 UTC; 3min 31s ago
    Process: 41716 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
    Process: 41722 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=0/SUCCESS)
    Process: 41747 ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf (code=exited, status=0/SUCCESS)
   Main PID: 41746 (dnsmasq)
      Tasks: 1 (limit: 11811)
     Memory: 1.8M
     CGroup: /system.slice/dnsmasq.service
             └─41746 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service --trust-anchor=.,20326,8,2,e06d44b80b8f1d39a95c0b0d7c65d08458>

Dec 28 16:56:11 mail.example.com systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Dec 28 16:56:11 mail.example.com dnsmasq[41716]: dnsmasq: syntax check OK.
Dec 28 16:56:11 mail.example.com dnsmasq[41746]: started, version 2.80 cachesize 150
Dec 28 16:56:11 mail.example.com dnsmasq[41746]: DNS service limited to local subnets
Dec 28 16:56:11 mail.example.com dnsmasq[41746]: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth nettlehash DNSSEC loop-detect inotify dumpfile
Dec 28 16:56:11 mail.example.com dnsmasq[41746]: using nameserver 1.1.1.1#53

Step-4

Change the internal configuration of the server using following command:

root@mail:~# su - zextras
zextras@mail:~$
zextras@mail:~$ /opt/zextras/libexec/zmsetservername -n mail.newserver.com

In the output of the above command, you can see the server will change all oldhostname associated parameters of the newhostname.

[Fragmented portion of the total output]
Getting local config ldap_is_master=true
Getting local config ldap_url=ldap://mail.example.com:389
Getting local config ldap_master_url=ldap://mail.example.com:389
Getting local config ldap_starttls_supported=0
Starting ldap...already running.
Renaming mail.example.com to mail.newserver.com

Setting local config ldap_master_url=ldap://mail.newserver.com:389
Setting local config ldap_url=ldap://mail.newserver.com:389
Getting local config ldap_host=mail.example.com
Setting local config ldap_host=mail.newserver.com
Getting local config av_notify_user=zextras@example.com
Getting local config av_notify_domain=example.com
Getting local config smtp_source=zextras@example.com
Getting local config smtp_destination=zextras@example.com
Starting ldap...done.

Searching for ldap server entry...done.
Getting local config ldap_port=389
Reinitializing the mta config...done.
zextras@mail:~$

Step-5

Remove the entry of the old hostname (mail.example.com) from the /etc/hosts

root@mail:~# cat /etc/hosts
127.0.0.1 localhost
127.0.1.1 mail


192.168.1.192   mail.newserver.com      mail


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

Step-6

Clean the zmloggerhostmap. Before cleaning it check it’s current status

zextras@mail:~$ zmloggerhostmap

Now clean them.

zextras@mail:~$ zmloggerhostmap -d mail mail.example.com
Deleted mapping for mail to mail.example.com
zextras@mail:~$
zextras@mail:~$
zextras@mail:~$ zmloggerhostmap -d mail.example.com mail.example.com
Deleted mapping for mail.example.com to mail.example.com
zextras@mail:~$

Step-8

Edit the file (/opt/zextras/conf/nginx/includes/nginx.conf.web) and replace all string of mail.example.com to mail.newserver.com

sed -i 's/example.com/newserver.com/g' /opt/zextras/conf/nginx/includes/nginx.conf.web

Step-9

Restart all services.

zextras@mail:~$ zmcontrol restart

Now check the webmail and mail send/receive status.

carbonio ce webmail login page

Also, check the configuration using zmlocalconfig.

zextras@mail:~$ zmlocalconfig | grep hostname

So that’s it.

😊

Post your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Understanding Carbonio CE Email Account Status | Carbonio CE
A Brief Of Carbonio CE User Account Settings | Carbonio CE