Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm really confused on how to properly setup my webserver's /ets/hosts file. This server does not do DNS but should be able to deliver mail messages from the server, notifications, etc. This machine also has 2 NIC's one that is used for the public IP and another for local connections, they are 192.168.2.99 (public) and 192.168.1.99 (local).
I'm really getting confused on the proper use of the domainname, hostname, machinename and aliases, etc...
I was hoping someone could school me a bit on the differences and the uses.
Host file is to use a name instead of an IP address.
As you can see the first line says localhost. Whenever you put localhost into a place where an IP might be used the system will look first to the host file (unless you use a proxy.pac file) and it will substitute the IP address you have for that name. In this case 127.0.0.1
Does this help? (Although they do make the mistake of allowing the spellchecker to correct 'resolv.conf' to 'resolve.conf', which always makes you look as if you don't know what you are writing about.)
Hosts really are two things. One is simply a way to keep people from typing ip addresses. The other use is for security. You could also maybe speed up lookup's for your common 20 or 30 web sites that you visit each day.
You should only put a few in hosts file of your own. Hosts file is what you want to use to avoid using an IP address. It is a convenience rather than a needed item. In fact you tend to forget what you put in a hosts file and then have troubles.
Hosts are for local lan setups usually but can be used to protect your system. See hosts file blocking web pages. I strongly suggest you put in a good hosts file from one of those sites.
Loopback is rather tricky. Some os's don't need a nic card installed. It will loopback through the IP stack as well as ping on some setups.
The loopback address is for your local machine, not for other computers on the network. You could list other hosts that your server uses, however as you have a dns server on the network, this isn't necessary. /etc/hosts might contain your router's IP address and give it a name for convenience, but you wouldn't include your server's IP address for the NIC device that connects to the router.
At home, I fix the IP/MAC address mappings in my router so that all the hosts always are given the same IP address by the router's DHCP server. That way I can maintain an /etc/hosts file on each host and not worry about one of the IP addresses changing. Servers are usually configured to have static IP addresses. Include your servers in the /etc/hosts file that that computer uses. If your host doesn't use dns to resolve a server's IP address, it won't need to use your dns to resolve the name.
Some people go further and maintain hostname / MAC address mappings in /etc/ethers and have this info loaded by arp when they boot up. ( your system my do this if /etc/ethers exists when you boot ) This can help protect against Cane and Abel type attacks.
Aliases in your /etc/hosts file are for your convenience. It will probably contain just the hostname and not the domain part.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.