Bobcares

Hostname resets on restart using Virtuozzo | An easy fix

by | Nov 15, 2021

Hostname resets on restart using Virtuozzo & gives you trouble?

At Bobcares, we offer solutions for every query, big and small, as a part of our Server Management Service.

Let’s take a look at how our Support Team recently helped out a customer when their hostname resets on restart while using Virtuozzo.

How to resolve hostname resets on restart using Virtuozzo

Does your system hostname reset when you restart via Virtuzzo? This often occurs due to improperly configured hostname on the host server.

According to our Support Engineers, the cPanel license check spots a new hostname and potentially flags the license when this occurs.

How to set hostname with host access

In order to set the hostname via Virtuzzo, we have to execute the following command on the host node:

(host) # vzctl set $ContainerName --hostname "something.example.com" –save

How to set hostname without host access

If we don’t have host access, we can still make the change with the vzctl command from the host node. We just have to set the hostname in the /etc/rc.local file if our container uses CentOS 6.

In case the container used CentOS 7, our Support Engineers recommend creating a systemd unit file.

CentOS 7
For CentOS 7, we have to copy the following script and change the $hostname section with the desired hostname via any editor.

# nano /etc/systemd/system/hostname.service
# A simple service unit file to set the hostname after vz.
# A startup configurations for systemd.
# By Aaron Horsley
# Licensed under GPL V2

[Unit]
Description=Override the hostname set on boot by VZ

[Service]
Type=oneshot
ExecStart=/usr/bin/hostnamectl set-hostname $hostname.domain.tld

[Install]
WantedBy=local-fs-pre.target

Then finally:

# systemctl enable /etc/systemd/system/hostname.service

CentOS 6
For CentOS 6, we have to add the following to the end of the rc.local file and save it at /etc/rc.local:

# nano /etc/rc.local
/usr/bin/hostnamectl set-hostname $hostname.domain.tld

[Looking for help with another query? We are just a click away.]

Conclusion

To conclude, the proficient Support Engineers at Bobcares showed us how to prevent hostname resets on restart using Virtuozzo.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.