LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Which config file do I set the hostname in (RH9)? (https://www.linuxquestions.org/questions/linux-newbie-8/which-config-file-do-i-set-the-hostname-in-rh9-188652/)

anachron 06-01-2004 08:59 PM

Which config file do I set the hostname in (RH9)?
 
I have RH9. I used the Network Configuration dialog to change the hostname from localhost to <newlocalhost>. It works, but now my computer boots *really* slowly--it gets to "starting sendmail" and takes about ten minutes, and then gets to "starting sm-client" and takes another ten minutes, and then there's another long pause just before it draws the login screen, and when I open any sort of window it too takes forever to load.
I'm assuming there's a config file or two that I need to change? /etc/hosts perhaps? And what do I put in it?
Thanks,
anachron

trickykid 06-01-2004 09:16 PM

To set the hostname permanently, edit these files:

/etc/sysconfig/network by adding HOSTNAME=Your-host-name
Sometimes its best to add the full hostname plus domain there, example: HOSTNAME=myhost.mydomain.com

/etc/sysconfig/network-scripts/ifcfg-eth0 and change your default hostname there.

At a prompt do this as root: hostname your-host-name

And then restart your network with this command as root once again: /sbin/service network restart

In your /etc/hosts file you will want to make sure you have your loopback address along with your actual hostname like this example:

127.0.0.1 loopback
X.X.X.X your-hostname.yourdomain.com your-hostname

Where X.X.X.X is the actual IP of your machine, etc.

If it still starts up slowly, could be other problems but I'd try that first.

anachron 06-01-2004 09:32 PM

If my computer isn't on any network, what should I put in /etc/hosts as my IP address? Do I skip the loopback line?

Thanks,
anachron

wmakowski 06-01-2004 11:08 PM

Below are a couple of man pages that should help you out. Leave the loopback line in the hosts file alone. It is used by some applications during normal operation. Therefore, you always have to configure it, regardless of whether your machine is attached to a network or not.

man hostname
man hosts

Bill

simon_yang 06-02-2004 01:43 AM

Quote:

Originally posted by trickykid
To set the hostname permanently, edit these files:

/etc/sysconfig/network by adding HOSTNAME=Your-host-name
Sometimes its best to add the full hostname plus domain there, example: HOSTNAME=myhost.mydomain.com

/etc/sysconfig/network-scripts/ifcfg-eth0 and change your default hostname there.

At a prompt do this as root: hostname your-host-name

And then restart your network with this command as root once again: /sbin/service network restart

In your /etc/hosts file you will want to make sure you have your loopback address along with your actual hostname like this example:

127.0.0.1 loopback
X.X.X.X your-hostname.yourdomain.com your-hostname

Where X.X.X.X is the actual IP of your machine, etc.

If it still starts up slowly, could be other problems but I'd try that first.

After following your suggestion,in local machine(PC 1),everything seems ok,while in other machine(PC 2) i still can't visit the machine(PC 1) through hostname,it displays"unknown hostname",only after rebooting PC 1,can I visit PC 1 from PC 2 through pc1's hostname.

wmakowski 06-02-2004 07:24 AM

I gather that PC1 and PC2 are part of your own local network. What I've done is make entries for each PC in each /etc/hosts on all machines in the network. Haven't had any problems since then. I added them to the hosts file on my WINNT box as well. Each machine has no problem connecting to another using the alias or ip address. Here is a sample very much like what is on the hosts man page.

127.0.0.1 localhost.localdomain localhost
192.168.1.3 fred.flintstones.org fred
192.168.1.7 wilma.flintstones.org wilma
192.168.1.8 barney.flintstones.org barney

Bill

simon_yang 06-02-2004 07:35 PM

Quote:

Originally posted by wmakowski
I gather that PC1 and PC2 are part of your own local network. What I've done is make entries for each PC in each /etc/hosts on all machines in the network. Haven't had any problems since then. I added them to the hosts file on my WINNT box as well. Each machine has no problem connecting to another using the alias or ip address. Here is a sample very much like what is on the hosts man page.

127.0.0.1 localhost.localdomain localhost
192.168.1.3 fred.flintstones.org fred
192.168.1.7 wilma.flintstones.org wilma
192.168.1.8 barney.flintstones.org barney

Bill

Thanks for replying,you mean that I should add the machine's alias on every machine's /etc/hosts in the same sub-network?

wmakowski 06-02-2004 07:39 PM

Yes, this is a quick way of letting each computer in your local network know what and where the others are at. An alternative would be to set up a DNS, but that is another story.

Bill

simon_yang 06-02-2004 07:48 PM

Normaly, DNS would be in charge of resolving name. When I change hostname/ip,how could I notify DNS and make it aware of the changes?Should I install a DNS client here?
my /etc/resolv.conf is:
nameserver 192.168.56.6
nameserver 192.168.56.7


All times are GMT -5. The time now is 11:10 AM.