New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Setting your hostname????
So just how do you set your hostname permanently? I have a CentoOS 5 box running on OpenVZ. From the command prompt I can temporarily set the hostname with the command:
hostname newdomainname.net
From what I read online, you edit your /etc/sysconfig/network file and put the hostname in there as well:
NETWORKING="yes"
GATEWAYDEV="venet0"
NETWORKING_IPV6="yes"
IPV6_DEFAULTDEV="venet0"
HOSTNAME="newdomainname.net"
But as soon as I reboot, both the 'hostname' command and the 'network' file go right back to the original domain.
What is magically changing them back?
Comments
change your hostname in /etc/hosts
try this:
vi /etc/rc.d/rc.local
add there :
hostname newdomainname.net
done !
Openvz resets your containers network configuration on reboot. Do this
vzctl set --hostname your.hostname.com --save
edit: I can't read.
That got me on the right track. The SolusVM control panel always overwrites the container settings. Once I changed it there, the innards of the vm changed.
Thanks.
nano /etc/sysconfig/network
add or edit
HOSTNAME=myserver.domain.com
now edit it in /etc/hosts
and make your you type, hostname domain.yourhostname.com
The 'hostname' command will let you change the hostname on the server that the commandline remembers, but it will not actively update all programs that are running under the old hostname.
Then a
/etc/init.d/network restart
Should do it
Also another note is make sure the solusvm hostname on the panel is up to date.
For OpenVZ you can try following:
chattr +i /etc/hosts
Now all other actions excepts read will be denied for this file even for root user.
The same goes for the dns resolvers configuration file '/etc/resolv.conf' if you don't like that default settings back again after a reboot.
Note that only root user can set or unset this 'immutable' attribute, to unset it run this:
chattr -i file_name
I could not locate the vzctl command on my VPS, is that perhaps a system command not available to the VPS that is running on OpenVZ?
P.S just curious about the command, my hostname is setting properly
If your host allow to change the hostname, you can do it from your client area (whcms) or solusvm cp. Or just ask your host via ticket to make a change.
Yes that command is only available to the host running your VPS
vzctl is run by your host. It is found on the node.
Yup. And I'm puzzled why this was offered as a solution. He did specify he had a VPS, not a node.
I offered the correct way to set the hostname on an OpenVZ machine. He never said he didn't have access to the hostnode, and if he didn't he can tell the provider to execute the command for him.
Most people who have containers have no access to the host nodes. And there are better ways to set hostname on a container than bothering the provider for such a simple issue.
I believe the easiest method would be editing the file /etc/hostname, and then setting the immutable flag on it, as someone has already suggested.
Even easier is just changing it in Solus, which is what the OP didn't know to do but eventually figured out.
Sort of true, I knew that you could change it there, I just didn't know that was the only place you could change it and that if you didn't, Solus would keep overwriting it. @Corey got me on the right track. Thanks again!
My experience with SolusVM has taught me that the setting in the control panel doesn't do anything on the container lol.
Same with me..
It's supposed to, but there is a SolusVM+OpenVZ bug where the hostname gets stuck (it shows the new one in Solus, but the container keeps the old one). If that happens you have to either manually set and read-only it or ticket the provider and ask them to change it (vzctl still works).
It seems to be fixed in newer versions and/or with the new bootstrap theme, but it consistently happens for me with providers using the old one.
Glad its not just me then ha.