etchosts


/etc/hosts

The /etc/hosts file matches Internet addresses to host names. While the hosts file is very simple, its contents are only reasonably effective on a single machine. Hosts files are most useful on small private networks behind a Network Address Translation device. For example, the hosts file works quite well if you have one or two servers and some other company manages your public nameservice. If you have more than a couple servers, however, it's generally simplest to set up an actual DNS server.

Each line in /etc/hosts represents one host. The first entry on each line is an IP address, and the second is the fully qualified domain name of the host. Following these two entries you can have an arbitrary number of aliases for that host. I can add comments at the end of each line by starting them with a comment. For example, I have a small home network with four computers. One is the proxy server, one is my wife's desktop, one is my crash machine, and one is my laptop. The hosts file looks somewhat like this.

 192.168.10.1     1 nat.blackhelicopters.org     2 firewall gateway 192.168.10.8   liz.blackhelicopters.org       liz   3 #don't crash! 192.168.10.200 crashbox.blackhelicopters.org  4 test 192.168.10.250 laptop.blackhelicopters.org    michael 

The machine 1 "nat.blackhelicopters.org" also has the names 2 "firewall" and "gateway." I've put in a 3 note to remind myself to not run Nessus against my wife's desktop machine. The machine "crashbox" is also called 4 "test." And if I put in one more full-time computer at home, I'm building a DNS server.

Any machine with this hosts table could find any machine listed in the hosts table by name; I could run "ping liz" or "ssh crashbox" and actually reach the desired machine.




Absolute Openbsd(c) Unix for the Practical Paranoid
Absolute OpenBSD: Unix for the Practical Paranoid
ISBN: 1886411999
EAN: 2147483647
Year: 2005
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net