Web Hosting Talk







View Full Version : how to change hostname in redhat 9.x ?


lwknet
05-30-2004, 11:58 AM
as title, i've tried /etc/hosts and reboot, but nothing in effect

thanks

Netphobia
05-30-2004, 12:03 PM
> >I have tried using the GUI (from the GNOME main menu, go to "System
> >Settings"->"Network") and changing it there. I can see that it changes
> >/etc/hosts. I tried rebooting (after trying restarting network
> >services), still no joy.
>
> Make sure that it changes the "HOSTNAME" line in /etc/sysconfig/network,
> as well as /etc/hosts
>
> Sean


hope this helps :)

Rahil
05-30-2004, 12:23 PM
Try this script. See attached. It's just one simple shell script, but the forum made me zip it.

lwknet
05-30-2004, 12:39 PM
Originally posted by Netphobia
> >I have tried using the GUI (from the GNOME main menu, go to "System
> >Settings"->"Network") and changing it there. I can see that it changes
> >/etc/hosts. I tried rebooting (after trying restarting network
> >services), still no joy.
>
> Make sure that it changes the "HOSTNAME" line in /etc/sysconfig/network,
> as well as /etc/hosts
>
> Sean


hope this helps :)

i exactly follow what you mentioned and guess what after reboot?

THE SERVER NEVER COMES BACK ONLINE !!!!

its been 30 mins still can't ssh to my server

:bawling:

Netphobia
05-30-2004, 12:48 PM
Well i dont think that would cause your server not to boot up, you may want to ask this question at forums.devshed.com, they are great for that sort of stuff.

gate2vn
05-30-2004, 01:04 PM
that will not cause your server not to start. Maybe there is something wrong with your server, or sometimes it's stuck when rebooting. Just ask your provider make a full reboot. Then, using below steps for changing hostname

ssh to root
pico /etc/sysconfig/network

change from
HOSTNAME=oldname.domain.com
to
HOSTNAME=newname.domain.com

save it

pico /etc/hosts

change oldname to newname at this line
XXX.XXX.XXX.XXX oldname.domain.com oldname

XXX.XXX.XXX.XXX is the IP address. then save it

/etc/init.d/syslog restart

it should work.

lwknet
05-30-2004, 01:07 PM
Originally posted by gate2vn
that will not cause your server not to start. Maybe there is something wrong with your server, or sometimes it's stuck when rebooting. Just ask your provider make a full reboot. Then, using below steps for changing hostname

ssh to root
pico /etc/sysconfig/network

change from
HOSTNAME=oldname.domain.com
to
HOSTNAME=newname.domain.com

save it

pico /etc/hosts

change oldname to newname at this line
XXX.XXX.XXX.XXX oldname.domain.com oldname

XXX.XXX.XXX.XXX is the IP address. then save it

/etc/init.d/syslog restart

it should work.

in that way u mean the machine doesn't need to be restarted for the new hostname to take effect?

i thk i missed this step before reboot:
>>/etc/init.d/syslog restart

is this what cause my server down?

gate2vn
05-30-2004, 01:18 PM
you dont need to reboot. As I said above, I doubt this is the cause your box not to start. You should contact with your provider ask their help.

lwknet
05-30-2004, 01:20 PM
i just did it with my small VPS machine, coz i believe its much easier to restart a single VPS account by the webhost in case anything goes wrong, and guess what after reboot??

IT WENT DOWN JUST LIKE MY DEDICATED SERVER !!!!!!!!!

but lucky this time its just a VPS

:bawling:

anybody comes up with a REALLY WORKING one?

lwknet
05-30-2004, 01:22 PM
Originally posted by gate2vn
you dont need to reboot. As I said above, I doubt this is the cause your box not to start. You should contact with your provider ask their help.

i just followed what you told me not to reboot the whole machine just restarting syslog, but the command "hostname" just shows me the old one...

:bawling:

if its correct, then it must be my machine comes with a broken install

lwknet
05-30-2004, 01:27 PM
its been an hour...

i lost a dedicated server and a VPS...

i believe i'll finally ask my hosts:

Sorry i just made a stupid mistake to change my hostname manually by editing /etc/hosts and /etc/sysconfig/network and the server never comes back online after the reboot, can you reboot my machine and change the hostname for me as follow?
damnmachine.fordummy.com

.
.
.

:(

gate2vn
05-30-2004, 01:48 PM
ok, try the below steps

ssh to root
hostname newname.domain.com
pico /etc/sysconfig/network
pico /etc/hosts
pico /etc/wwwacct.conf
service named restart
/etc/init.d/syslog restart

remember update oldname to newname.
If you have used server before, you may want to update DNS zone as well.
If you are running a cPanel box, after rename, you may have error, try to run this command
/usr/local/cpanel/cpkeyclt

omaha.stylee
05-30-2004, 01:59 PM
all you have to do is run "hostname new.domain.com" as root, and whalah.

Rahil
05-30-2004, 02:03 PM
lol, why don't you just use the script I gave you?

lwknet
05-30-2004, 02:09 PM
i wonder why you have this file in your install:
/etc/wwwacct.conf

it doesn't appear in my 3 servers runing redhat 9, is it created by control panel? sorry i don't use any cp on my machines

this one does work without reboot on my 3rd available machine:
hostname newname.domain.com
even in /etc/hosts and /etc/sysconfig/network there's still the old name. it seems that sendmail also regconizes the change, i checked with dnsreport and it reports me the newname.domain.com as the new hostname, but can u tell what will be printed on the screen if i type "hostname" again after reboot? newname/oldname? i don't dare to try it after so many failure, 2 servers dead just by this...

can u explain why named and syslog needs to be restarted coz i'm confused with it?

Rahil
05-30-2004, 02:13 PM
Originally posted by lwknet
i wonder why you have this file in your install:
/etc/wwwacct.conf

By "your install", do you mean the script I gave you? If so, when you run the script, it will ask you if you're using a control panel, or if it is just a plain install.

lwknet
05-30-2004, 02:18 PM
Originally posted by omaha.stylee
all you have to do is run "hostname new.domain.com" as root, and whalah.

yeah it works, but wait...
hostname -d
hostname -f
hostname -a

all fails !!!

????? i'm still confused, is there a robust way to just change the hostname for a machine huh??

lwknet
05-30-2004, 02:24 PM
Originally posted by Rahil
lol, why don't you just use the script I gave you?

sorry i should... in the first place :bawling:

but i thk your script is way technical for just changing the host name, i see from your script u'll add the folwoing lines into the file network but they are not in my original file:
echo GATEWAYDEV=\"eth0\" >> /etc/sysconfig/network
echo FORWARD_IPV4=\"yes\" >> /etc/sysconfig/network

i'm not sure what's their function

lwknet
05-30-2004, 02:34 PM
wtf my reboot ticket has been ignored over an hour

this is the worst experience so far

even remote reboot port fails

this is my first time ask for a host to reboot my server for my whole life(ive servers over over a year)

:bawling:

omaha.stylee
05-30-2004, 02:37 PM
that's only until you reboot, edit those two files you mentioned and next time your box is rebooted that will be the hostname for good. :)

lwknet
05-30-2004, 02:49 PM
Originally posted by omaha.stylee
that's only until you reboot, edit those two files you mentioned and next time your box is rebooted that will be the hostname for good. :)

i confirm this is definately true, by just testing it with my 3rd available box

lwknet
05-30-2004, 02:51 PM
my 2nd box is back online