Linux, /etc/hosts question

I have a machine with the following first two lines       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

Los Angeles1Asked:
Who is Participating?
woolmilkporcConnect With a Mentor Commented:
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! 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.
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.
SurranoSystem EngineerCommented:
@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.: 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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.