LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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
 
LinkBack Search this Thread
Old 04-22-2005, 10:51 AM   #1
itgl72
LQ Newbie
 
Registered: May 2003
Posts: 19

Rep: Reputation: 0
Proper Layout of /etc/hosts


I know this is a basic topic, and I have set these up many a time in simple environements and gotten the machine to work but I wanted to ask the forum about this question since I have read several help files online that have not really NAILED DOWN my question on /etc/hosts in a way in which I may want to use it.

I'm looking for the best practice in setting up the /etc/hosts for a linux box called "linuxserv" with an internal domain of abc.com and external domain of xyz.com.



Heres how I set up a basic system, IS IT WRONG TO GIVE IT TWO NAMES THAT POINT TO 127.0.0.1?

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
127.0.0.1 linuxserv.abc.com linuxserv


What about adding the internal IP address of the system like so, DOES THE FORMAT BELOW LOOK ACCEPTABLE?

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
127.0.0.1 linuxserv.abc.com linuxserv
192.168.1.2 linuxserv.abc.com linuxserv


Now lets say linuxserv also had a second network interface that links to the external network. What about adding the external IP address of the system like so, DOES THE FORMAT BELOW LOOK ACCEPTABLE?

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
127.0.0.1 linuxserv.abc.com linuxserv
192.168.1.2 linuxserv.abc.com linuxserv
234.X.X.X linuxserv.xyz.com linuxserv


What would make any of these unacceptable, or wrong in a best practice environement?
 
Old 04-22-2005, 11:33 AM   #2
lugoteehalt
Senior Member
 
Registered: Sep 2003
Location: UK
Distribution: Debian
Posts: 1,193
Blog Entries: 2

Rep: Reputation: 49
Quote:
#lugo The next line is all that was in the file. I am commenting it out.
#127.0.0.1 debian localhost
#
#lugo Put in next block to try to get networking.
127.0.0.1 localhost
192.168.1.1 debian.domain.org debian
192.168.1.2 apricot.domain.org apricot
Don't know if that any help, it's my file. It's for computer 1, debian, on a two computer network. The other computer is apricot.domain.org. You may put what you want for domain.org.link. It's a Debian system.
 
Old 04-25-2005, 08:22 AM   #3
itgl72
LQ Newbie
 
Registered: May 2003
Posts: 19

Original Poster
Rep: Reputation: 0
That did not really clear up my question. I'm looking for someone to reply with information regarding my setup posted above. I understand the basics but wanted to get a better grasp of the hosts file and its formats.
 
Old 04-25-2005, 09:05 AM   #4
jschiwal
Moderator
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,263

Rep: Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562Reputation: 562
127.0.0.1 linuxserv.abc.com linuxserv
192.168.1.2 linuxserv.abc.com linuxserv
234.X.X.X linuxserv.xyz.com linuxserv

I believe that these lines would cause a problem. One thing that is sometimes done is to block access to a certain website by making its IP address 127.0.0.1 in the hosts file.

127.0.0.1 localhost localhost.localdomain
127.0.0.1 www.crackerland.com

That is assuming that /etc/hosts is searched first. That is true if a line in your host.conf is:
order hosts,bind
 
Old 04-25-2005, 09:25 AM   #5
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 3,665

Rep: Reputation: 204Reputation: 204Reputation: 204
Here's the first few lines of my primary /etc/hosts file:
Code:
$ cat /mnt/fc3/etc/hosts | more
90.0.0.4        tss-4   TSS-4
90.0.0.3        tss-3   TSS-3
90.0.0.2        tss-2   TSS-2
90.0.0.1        tss-1   TSS-1
127.0.0.1       localhost.localdomain   localhost
127.0.0.1       view.atdmt.com
127.0.0.1       clk.atdmt.com
127.0.0.1       nytmembercenter.112.2o7.net
127.0.0.1       promotions.real.com
127.0.0.1       media.fastclick.net
Note the first five lines: They are each assigning two names to the specified address. (The 90.0.0.* lines are for our internal [i.e., "home"] network. Our firewall used 90.0.0.* for internal networks, and M$ seems to prefer uppercase names for NETBIOS, which one of the family's systems is using.)
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
External Hosts Resolve but Local Hosts Do Not kjm9 Linux - Networking 7 11-19-2005 03:51 PM
hosts.allow & hosts.deny question... jonc Linux - Security 9 03-05-2005 09:41 PM
Adding shell commands to hosts.deny and hosts.allow ridertech Linux - Security 3 12-29-2003 03:52 PM
hosts.deny and hosts.allow defaults? gui10 Linux - Security 5 12-20-2001 01:57 AM
hosts.allow / hosts.deny fistz Linux - Newbie 1 04-19-2001 07:00 PM


All times are GMT -5. The time now is 03:06 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration