Hostname woes on cPanel + OpenVZ / Virtuozzo containers.

I have recently run across an issue a few times in the last week where OpenVZ / Virtuozzo 7 containers are having their hostnames reset to the short hostname. The usual culprit is the hostname not being set correctly on the node but in this case, on OVZ7, this is being done via the node by way of the script snippet below when the node boots up:

/etc/vz/dists/scripts/redhat-set_hostname.sh
if [ -f /etc/hostname ]; then
# New style: RHEL7/Fedora15+
# Note hostname(5) says it should NOT be FQDN
val=${val%%.*}
echo "$val" > /etc/hostname
else
# "Classic" style
...

This is apparently a known issue but it has not yet been addressed by the OpenVZ team – OVZ-6738

The diff below submitted by Karl works to resolve this issue on my OpenVZ test server:

--- redhat-set_hostname.sh.origin 2016-07-12 11:10:49.102940809 -0400
+++ redhat-set_hostname.sh 2016-02-26 13:59:26.755337164 -0500
@@ -29,7 +29,8 @@
if [ -f /etc/hostname ]; then
# New style: RHEL7/Fedora15+
# Note hostname(5) says it should NOT be FQDN
- val=${val%%.*}
+
+ # val=${val%%.*} ## force full FQDN
echo "$val" > /etc/hostname
else
# "Classic" style

One thought on “Hostname woes on cPanel + OpenVZ / Virtuozzo containers.

Leave a Reply

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