Hostname keeps reverting to the default one


I operate a Linux server that runs on openSUSE and it uses Plesk to manage websites and user accounts, however, because Plesk requires the system to have a specific hostname which is based on my website domain name, my hostname must be the same as my domain name (according to my setup).

I’m however finding it hard to keep the hostname changes permanent, as every time I change my hostname and restart the network service, the domain reverts to the default one and hence messes up Plesk configuration.

I change my hostname using the hostname command but although I’ve also made the required edits for **/etc/HOSTNAME **and /etc/hosts, the hostname will keep reverting to the default one no matter what.

I remember making the changes permanent by editing the file **/etc/sysconfig/network **and making it read only so that no changes would occur in the file. How can I achieve something similar in openSUSE? I run openSUSE version 12.3. Any suggestion will be hugely appreciated!

Looks like the problem is solved! I went to Yast settings then **Network > Network Settings > Hostname **and unchecked Change Hostname via DHCP. Now when I reboot or restart the network service, the hostname doesn’t revert back to the default one!

You can edit the file


Manually if you like :wink:

But this won’t help at all either if the hostname is changeed by DHCP… :wink:

YaST is of course the preferred way to manage your system. You can of course do everything “manualy”, but then you realy have to know what to call and where to edit, while yAst will show you the options and decisions you have to take right before your eyes.

In the Hostname and DNS setting in YAST where you changed the name, you need to remove the checkmark from “Change Hostname via DHCP”

Right i did not see that /etc/HOSTNAME was in the first post of the OP :frowning:

Right, but do you understand what these configurations actually do?

/etc/hosts This provides local Hostname resolution, by default when an app running on the machine wants to locate the IP address of a machine by name (both the local and any remote machines) then this file is read first before trying other methods (like doing a DNS lookup)

YAST > Network Settings > Hostname tab This is the name your machine would like to be known as on the local network. But notice the language I’ve chosen, it’s not guaranteed that any other machine will honor this name. Just because you machine desires something does not mean that is how other machines will find your machine, more than likely remote machines will use what is configured in DNS as authoritative. Other names might be used, too. But since the machine’s desired name <might> be used, it follows all the usual rules that it must be unique in the network and if used as a NetBIOS name must also conform with those rules. And, this (NetBIOS name use) is why old apps (it seems that Plesk is one) still uses this method.