hostname.sh changes don't take affect

modem

Verified User
Joined
Apr 7, 2004
Messages
355
Hello all,

I have an issue here where recently I made some hostname changes on my webhosting server including setting up a reverse DNS and needing to fully change the hostname as listed throughout the entire OS.

Seemingly that worked until I noticed I was getting messages inside of DA stating that email may not work until hostname.sh was run, so I ran that. I since haven't received that message again inside of DA, but when checking the OS itself this evening by logging in with SSH, I'm seeing the old originial hostname at the login prompt and in several files referencing the hostname.

For example my login is: root@s15355459
when it should be: root@stargatesg1

I have also checked the following files after running ./hostname.sh and it shows the files with the correct hostname. But after a system reboot and check the files, it shows the old hostname once more. These include:

/etc/hosts
/etc/sysconfig/network
/etc/hosts.tmp
/etc/virtual/domains

Does anyone have any idea why when I manually edit these files or run hostname.sh that they revert back to the old hostname?

Thanks!

Bradley
 
Are you really running on a dedicated server or on a vps?
If you are on a vps, this problem can occur. Your provider needs to take care of the PTR records (reverse DNS).

As far as the hostname of the VPS goes, just put in your /etc/rc.d/rc.local the following:
hostname stargatesg1
or
hostname stargatesg1.com
or whatever extension you need.
 
The server hostname is set during the boot process. Check to see where your OS sets the hostname, and make sure it's changed there.

Jeff
 
Jeff - I have CentOS 5.6 x64 and am not sure where it sets the hostname during the boot process, any suggestions?

Richard - The Reverse DNS Mapping was the first thing I took care of once the server got online before hosting clients. 1&1 hosting allows for reverse DNS to be setup and it's confirmed working.

Here are the steps I done this evening after rebooting and noticing the hostname was setup to the original name:

1.) Ran ./hostname.sh in the DirectAdmin Scripts folder.
2.) Checked the /etc/sysconfig/network and confirmed the file has the changes made.
3.) Checked and confirmed the /etc/hosts file showed the correct entry, which it did.
4.) Added the correct entry into /etc/hosts.tmp
5.) Checked BIND to see if there was anything there in config files that would cause this to not work.
6.) Issuing a hostname command shows that my FQDN is working properly.

Now I issue a shutdown -r now command

Upon reboot I issued the hostname command and received the following:

s15xxxxxx.onlinehome-server.com

So I had to use the hostname.sh command again and this time without rebooting for the hostname to temporarily stay.

Any ideas??
 
I tried that command, but still doesn't take hold upon a system reboot.
 
You didn't answer my most important question.
Are you on a VPS or on your own dedicated server? Because I've still got the impression you are on a VPS because you changed the correct files.
Next to that, the /etc/hosts.tmp file does not need te be changed in Centos.
 
And if your provider does not want to change things, then you can use my tip posted in post #2, I do it the same way on a vps.;)
 
Richard - I apologize, I didn't see the full question while I was traveling. Yes, I have a full root access VPS server that has a full CentOS 5.6 install / imaged.

A followup note, is that even after changing the above files to change the hostname, I noticed in the email headers that the email server that mail is being delivered too is s15xxxxxx.onlinehome-server.com so it's not showing the hostname correctly through the MTA.

I'll check and give your suggestion a try!
 
I just wanted to post an update. Upon each reboot adding my new hostname setting to the rc.local settings does seem to solve this from reverting. However once I comment that out, reboot the server I notice that my /etc/sysconfig/network file is set back to the original with the VPS hostname and my original hostname setting has been removed.

Is this a bug in Cent OS 5.6 or is this something on the VPS host end making changes constantly to revert to their settings?
 
It seems you're running a openvz/virtuozzo VPS.... since that it's normal situation, that you're not allowed to change hostname in a common way.

p.s. show your

Code:
cat /proc/user_beancounters
 
I think I got an adequate solution. I used the command chattr +i /etc/sysconfig/network on the file that indeed seems to keep it from getting overwritten on each reboot. As for my bean_counter, here is the following:

Version: 2.5
uid resource held maxheld barrier limit failcnt
60423774: kmemsize 18679643 18712243 41943040 46137344 1669
lockedpages 0 0 1024 1024 0
privvmpages 132518 132617 1048576 1153433 0
shmpages 802 802 65536 65536 0
dummy 0 0 9223372036854775807 9223372036854775807 0
numproc 94 94 256 256 0
physpages 66098 66138 2147483647 2147483647 0
vmguarpages 0 0 262144 2147483647 0
oomguarpages 66098 66138 9223372036854775807 2147483647 0
numtcpsock 24 24 1440 1440 0
numflock 7 7 752 826 0
numpty 1 1 64 64 0
numsiginfo 0 1 1024 1024 0
tcpsndbuf 510872 510872 6881280 10813440 71
tcprcvbuf 393216 393216 6881280 10813440 0
othersockbuf 455728 456520 4504320 8388608 0
dgramrcvbuf 0 0 1048576 1153432 0
numothersock 233 234 1440 1440 0
dcachesize 1368123 1376574 7340032 8074035 0
numfile 4345 4350 16384 16384 0
dummy 0 0 0 0 0
dummy 0 0 0 0 0
dummy 0 0 0 0 0
numiptent 18 18 400 405 0
 
The chattr solution was the solution given by the VPS provider as they didn't really know why it was doing that and how to solve it till the guy on the other end said try chattr.
 
Hostname is saved in config file for VE, and every time you reboot a VPS, it's taken from that config. And you are not allowed to change hostname in that config:

/etc/vz/conf/<VE_ID>.conf

e.g.

Code:
# grep -i hostname /etc/vz/conf/121.conf
HOSTNAME="ve121.hardware-node.com"

So to change it, your hoster should update manually config file, if there is not any Control Panel for managing VPS.

Or run this command in root shell:

Code:
# vzctl set <VE_ID> --save --hostname new.hostname.com

P.S. Why did you choose a VPS provider, if its support team does not know, how to change hostname for your VPS? Is it any kind a VPS-reseller?
 
I double checked and there is no /etc/vz/conf/<ve_id>.conf file nor vzctl command. There is only a /etc/vz/dev/vzlink device file and that's the only thing pertaining to *vz* on the server.

I chose this hosting provider due to our webhosting business contracting in the current economy and costs were cheaper for them to manage the infrastructure while keeping current hosting customers happy. It's not ideal, but it's liveable now.



Hostname is saved in config file for VE, and every time you reboot a VPS, it's taken from that config. And you are not allowed to change hostname in that config:

/etc/vz/conf/<VE_ID>.conf

e.g.

Code:
# grep -i hostname /etc/vz/conf/121.conf
HOSTNAME="ve121.hardware-node.com"

So to change it, your hoster should update manually config file, if there is not any Control Panel for managing VPS.

Or run this command in root shell:

Code:
# vzctl set <VE_ID> --save --hostname new.hostname.com

P.S. Why did you choose a VPS provider, if its support team does not know, how to change hostname for your VPS? Is it any kind a VPS-reseller?
 
You can not run those commands from VPS, those commands and config file are available only from HN (hardware node). You might want to give a link to that post to your hoster.
 
Maybe somebody can help me to, because now my vps ticket system too starts to complaint about the hostname, seems the rc.local fix which which did the trick before, does not work anymore, or at least not good enough.

If I'm correct the VPS is on OpenVZ or Virtuozo. My beancounter looks like this:
Version: 2.5
uid resource held maxheld barrier limit failcnt
202: kmemsize 16769174 25430163 2147483646 2147483646 0
lockedpages 0 0 999999 999999 0
privvmpages 251572 272935 262144 262144 59
shmpages 803 7401 262144 262144 0
dummy 0 0 0 0 0
numproc 94 124 999999 999999 0
physpages 175104 204521 0 2147483647 0
vmguarpages 0 0 262144 2147483647 0
oomguarpages 175105 204522 262144 2147483647 0
numtcpsock 43 66 7999992 7999992 0
numflock 6 22 999999 999999 0
numpty 1 2 500000 500000 0
numsiginfo 0 12 999999 999999 0
tcpsndbuf 1029040 1333944 214748160 396774400 0
tcprcvbuf 1133256 3587128 214748160 396774400 0
othersockbuf 467136 620648 214748160 396774400 0
dgramrcvbuf 0 877592 214748160 396774400 0
numothersock 246 286 7999992 7999992 0
dcachesize 0 0 2147483646 2147483646 0
numfile 2923 3285 23999976 23999976 0
dummy 0 0 0 0 0
dummy 0 0 0 0 0
dummy 0 0 0 0 0
numiptent 179 179 999999 999999 0
[root@server ~]#

I'll gues I have to ask the host the same thing as in post #17?
 
Last edited:
Back
Top