Solved

Linux, /etc/hosts question

Posted on 2013-12-19
3
208 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Network Interface Card (NIC) bonding, also known as link aggregation, NIC teaming and trunking, is an important concept to understand and implement in any environment where high availability is of concern. Using this feature, a server administrator …
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now