LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-21-2008, 01:17 PM   #1
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Rep: Reputation: 15
correct /etc/hosts format


For /etc/hosts, which is the correct format?

Code:
127.0.0.1        localhost.localdomain  localhost
10.10.10.10	core.domain.com core
Or

Code:
127.0.0.1       core.domain.com core localhost.localdomain localhost
10.10.10.10	core.domain.com core
On various sources, some say the server's actual fqdn must follow the 127.0.0.1 and then localhost.localdomain and localhost and some say the line with 127.0.0.1 should only contain localhost.localdomain and localhost.
Or does it vary depending on the distro? I'm running Redhat and Ubuntu distros.

Thanks
 
Old 11-21-2008, 01:24 PM   #2
mazhar_theone
LQ Newbie
 
Registered: Mar 2008
Posts: 14

Rep: Reputation: 0
Quote:
Originally Posted by linuxfia View Post
For /etc/hosts, which is the correct format?

Code:
127.0.0.1        localhost.localdomain  localhost
10.10.10.10	core.domain.com core
Or

Code:
127.0.0.1       core.domain.com core localhost.localdomain localhost
10.10.10.10	core.domain.com core
On various sources, some say the server's actual fqdn must follow the 127.0.0.1 and then localhost.localdomain and localhost and some say the line with 127.0.0.1 should only contain localhost.localdomain and localhost.
Or does it vary depending on the distro? I'm running Redhat and Ubuntu distros.

Thanks
The first one is correct format for /etc/hosts
 
Old 11-25-2008, 12:09 PM   #3
linuxfia
Member
 
Registered: Apr 2008
Distribution: ubuntu 7.10, centos 4 & 5
Posts: 84

Original Poster
Rep: Reputation: 15
Thanks, but do you know why the distros such as Redhat would add the hostname automatically after the 127.0.0.1?
127.0.0.1 core.domain.com core localhost.localdomain localhost
 
Old 11-27-2008, 11:34 AM   #4
ugge
Senior Member
 
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028

Rep: Reputation: 45
the 127.0.0.1 address is only a virtual interface, called loop back, and is only accessible for the machine it self.
A domain name is a representation for an IP, so it should be associated with the corresponding IP only.
 
  


Reply



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
Correct way to define hostname in /etc/hosts thespaceman Red Hat 6 10-12-2008 10:27 AM
Kernel won't compile into the correct format iwasapenguin Linux - Kernel 6 08-06-2007 01:58 AM
correct config of Hosts file ankycooper Red Hat 1 06-15-2006 01:07 AM
format of hosts hansi umayangan Linux - General 4 12-28-2004 09:29 PM
Correct entry for local machine in /etc/hosts Kropotkin Linux - Networking 1 11-16-2004 05:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:05 PM.

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
Open Source Consulting | Domain Registration