LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   hostname question (urgent) (https://www.linuxquestions.org/questions/linux-networking-3/hostname-question-urgent-77586/)

dincer80 07-31-2003 03:40 AM

hostname question (urgent)
 
Currently etc/hosts is:

127.0.0.1 localhost.localdomain localhost

I want to change name of the machine from localhost to "ABC"

Which part should I modify?

localhost.localdomain -> ABC.localdomain [Name]
or
localhost -> ABC [Alias]

or both?


And, any other files needed to be modified?

dincer80 07-31-2003 03:43 AM

By the way,

etc/sysconfig/network contains:

HOSTNAME = localhost.localdomain



Should I modify this one?

And, lastly, after changing name of the localhost;can "sendmain" cause any problems when starting?

jharris 07-31-2003 03:44 AM

Neither will change the hostname. /etc/hosts is only used to map hostnames to ip addresses (the precursor to DNS). You need to leave the entry for localhost as it is.

What distro are you running? Different distros set the hostname in different places. Once you've changed the hostname you'll want to add an entry for your new hostname in /etc/hosts on a new line.

cheers

Jamie...

dincer80 07-31-2003 03:47 AM

I have RedHat Advanced Server 2.1 installed.

I hope you know what file I should modify to change the name of the machine from localhost to something else..

Peace..

jharris 07-31-2003 03:52 AM

Quote:

Originally posted by dincer80
etc/sysconfig/network contains:

HOSTNAME = localhost.localdomain

OK - that was the missing bit of info. Looks like you're using Redhat or something that uses a similar layout. Yeah, change this entry then reboot, or change this entry then use the hostname command from the command line - whever you prefer.

Once this is done edit /etc/hosts to reflect the change of name, add a line for the new hostname, leave the old entry for localhost alone or things may go screwy.
Quote:

Originally posted by dincer80
And, lastly, after changing name of the localhost;can "sendmain" cause any problems when starting?
Uhm... sorry I don't follow.

cheers

Jamie...

dincer80 07-31-2003 03:57 AM

Did I understand right? What I gotta do is:

1. Editing etc/sysconfig/network and changing the line "HOSTNAME = localhost.localdomain" to "HOSTNAME = ABC"

2. Rebooting

3. Editing etc/hosts and adding the line
"127.0.0.1 localhost.localdomain ABC"
under the line
"127.0.0.1 localhost.localdomain localhost"


Are these 3 steps correct?

dincer80 07-31-2003 03:59 AM

As soosn as you confirm, I'll apply the steps :-)

dincer80 07-31-2003 04:09 AM

Won't you confirm?
Is there anything wrong?

jharris 07-31-2003 04:24 AM

Easy now, its only been a few minutes since the last update! If someone takes a while to respond it might be becuase they're in a different timezone, or gone to lunch or something! (Or actually doing some work in my case...)

Step 1 is correct, then edit /etc/hosts and add "ABC" to the end of the localhost line (assuming you don't have another IP address), then reboot.

HTH

Jamie...

dincer80 07-31-2003 04:34 AM

I am sorry about that.. And thank you by the way.

Actually, I have one more line under the
"127.0.0.1 localhost.localdomain localhost"
which is
"21......... qua..... q..."

Does the existence of this line change anything?

Now what should I do?
"127.0.0.1 localhost.localdomain ABC"
"21......... qua..... q..."

Does it work, when the file contains these 2 lines?

jharris 07-31-2003 05:02 AM

All /etc/hosts allows you to do it type things like "ping ABC" instead of having to use the ip address "ping 127.0.0.1". If your want ABC to be associated with a different IP address then you need to put that in /etc/hosts. You can have as many different entries in /etc/hosts as you want, so the 'other' line will simply be an entry for another box.

So long as your hostname appears to have changed and you can ping your hostname from the command line then that's it done. Keep in mind that entries in /etc/hosts only effect your machine.

cheers

Jamie...

ppuru 07-31-2003 07:01 AM

you will require to change the /etc/sysconfig/network entry

HOSTNAME=mylinux.domain.com

leave the 127.0.0.1 entries in /etc/hosts as they are...
add your ipaddress and add assign names to it, for example,

172.16.200.1 abc.mydomain.com abc


All times are GMT -5. The time now is 09:04 PM.