Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Linux, /etc/hosts question

Posted on 2013-12-19
3
211 Views
Last Modified: 2013-12-20
I have a machine with the following first two lines

127.0.0.1       localhost.localdomain   localhost.localdomain   localhost4      localhost4.localdomain4 localhost       xxclnt12x
::1     localhost.localdomain   localhost.localdomain   localhost6      localhost6.localdomain6 localhost       xxclnt12x

Open in new window


If I take out the xxclnt12 at the end of each line, will there be a problem aftter the next

service network restart 

Open in new window


?
0
Comment
Question by:Los Angeles1
3 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 39730742
Au contraire! If this is the machine's external hostname it should never appear there - if attached to the net a machine must have its own, unique IP associated to its hostname!

127.0.0.1 is meant for localhost/loopback access and for nothing else - it is the same on every host and not at all meant to be exposed to the public.
0
 
LVL 14

Expert Comment

by:ThomasMcA2
ID: 39730987
No, don't do that. xxclnt12x is the name of your computer. Those entries help some software that runs on your computer to "find" itself.
0
 
LVL 8

Expert Comment

by:Surrano
ID: 39731213
@ThomasMcA2: nope, an app/service should never find itself based on loopback address. It should use /etc/hostname and/or /etc/hostname.<interface>. (edit: location varies based on *nix flavour)

Some services use a specific name, e.g. some *nix systems use "loghost" to identify the target of syslog. But even then, "loghost" should be alias to the primary ethernet address and not the localhost.

The long and the short of it: woolmilkporc is right, with one addition: if this is the machine's name then it should appear with its primary IP in a separate line, e.g.:
192.168.22.44 xxclnt12x

Open in new window


unless of course the machine uses dynamic dhcp in which case you cannot (and should not) specify the hostname like that. Instead, you specify your hostname and primary interface in some config file and configure your DHCP client to request address for that particular interface. E.g. centOS uses /etc/sysconfig/network to specify hostname and /etc/sysconfig/network-scripts/ifcfg-eth0 to specify dhcp request for eth0 interface.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Install Predefined Certificate on Ubunto 4 48
mcrypt_create_iv() is deprecated 4 279
expectj telnet failing 5 45
Trying to install php56 on CentOS 7 get GPG error 5 28
Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question