0

I was installing a Tomcat webapp that refused to work until I stumbled on someone else's issue with an unrelated product. The solution was to add the machine's name to /etc/hosts, to match the name returned by hostname. Is this required for general Linux networking to function correctly?

My webapp is running in a virtual machine so that I can test the webapp, and I don't normally bother with the /etc/hosts file on VMs. I just shook my fist and cursed Tomcat and webapp's behavior. I read /etc/hosts , /etc/sysconfig/network and hostname?, but that doesn't say if it's required or not.

0

2 Answers 2

0

If DNS won’t resolve a system’s hostname to an IP, things may break, depending on how they’re configured — unless you manually add an entry to /etc/hosts. This seems to be one of those occasions. The reverse can also apply in some situations, too.

It’s generally considered good practice to add such an entry to /etc/hosts — in fact, most Unixish operating systems tend to do this for you as part of their initial configuration (or, if you’re using DHCP, when they obtain a lease).

0

I consider it required but you can get away with it not being specified properly in some cases but in others cases you will find issues where things will not work. I vaguely recall issues with Apache and I can see Tomcat having issues as well.

If the daemon is attempting to reference or resolve the local hostname and it is not specified, it will fail. For example, the hostname is integral to SMTP.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .