Mapping Names to IP Addresses with the /etc/hosts File

You need a way for hostnames to map to IP addresses. Normally, this is done with DNS, but you don’t have DNS set up yet. In the meantime, you can provide mappings for hosts you know about—such as hosts on our local network—with the /etc/hosts file.

/etc/hosts allows you to build a table in which each entry lists an IP address, its most common (or “official”) hostname, and any aliases (additional names that map to the same IP address). Each of these items is separated by spaces or tabs. This table is consulted before any DNS queries are made, so /etc/hosts acts both as a backup to DNS (if it’s not available) and an override (if it’s not serving correct information). The aliases can even be ...

Get FreeBSD6 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.