Solved

Linux, /etc/hosts question

Posted on 2013-12-19
3
214 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
[X]
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
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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

729 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