LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-01-2004, 09:59 PM   #1
anachron
LQ Newbie
 
Registered: Jul 2003
Distribution: Mandrake 10.1
Posts: 5

Rep: Reputation: 0
Question 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
 
Old 06-01-2004, 10:16 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
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.
 
Old 06-01-2004, 10:32 PM   #3
anachron
LQ Newbie
 
Registered: Jul 2003
Distribution: Mandrake 10.1
Posts: 5

Original Poster
Rep: Reputation: 0
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
 
Old 06-02-2004, 12:08 AM   #4
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 23, 24, RHL 5.2
Posts: 560

Rep: Reputation: 56
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
 
Old 06-02-2004, 02:43 AM   #5
simon_yang
LQ Newbie
 
Registered: Jun 2004
Location: Shanghai,China
Distribution: RH9.0/uclinux
Posts: 6

Rep: Reputation: 0
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.
 
Old 06-02-2004, 08:24 AM   #6
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 23, 24, RHL 5.2
Posts: 560

Rep: Reputation: 56
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
 
Old 06-02-2004, 08:35 PM   #7
simon_yang
LQ Newbie
 
Registered: Jun 2004
Location: Shanghai,China
Distribution: RH9.0/uclinux
Posts: 6

Rep: Reputation: 0
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?
 
Old 06-02-2004, 08:39 PM   #8
wmakowski
Member
 
Registered: Oct 2003
Location: Ohio
Distribution: Fedora 23, 24, RHL 5.2
Posts: 560

Rep: Reputation: 56
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
 
Old 06-02-2004, 08:48 PM   #9
simon_yang
LQ Newbie
 
Registered: Jun 2004
Location: Shanghai,China
Distribution: RH9.0/uclinux
Posts: 6

Rep: Reputation: 0
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

Last edited by simon_yang; 06-02-2004 at 09:48 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Set hostname btexpress Linux - Networking 2 06-01-2004 01:03 AM
redhat8, changed hostname by editing config file, X no longer recognizes it infamous41md Linux - Newbie 2 03-31-2004 01:20 AM
RH 9, Netz und DNS Config, Fehler "set visible hostname" j.kopitzke Linux - Newbie 0 06-19-2003 12:31 AM
set hostname allelopath Linux - Software 10 04-30-2003 07:05 PM
Want to set up a new domain name and hostname? hamster Linux - Networking 6 04-06-2003 01:04 PM


All times are GMT -5. The time now is 09:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration