Host and network name database

Note: The /etc/hosts file may be consulted before any name servers. Avoid hard-coding any values that may change. It is best to rely on nameservers.

/etc/hosts

As stated in the OpenBSD manual, the hosts file associates names and IP addresses. The file format is quite simple. Each line holds this format:

Internet address IPV4/IPV6Host nameAliases
100.10.20.31PEPPINOPEPPINO.oddprotocol.org

Every line field is separated using one or more spaces or one or more tabs character. a '#' character indicates a comment. The comment starts from this character to the end of the line. Every character in this space is ignored. To edit /etc/hosts just use:

$ doas vi /etc/hosts
127.0.0.1               localhost          AKASA.local AKASA.localhost AKASA.localdomain AKASA # IPV4 loopback interface with four aliases following
::1                     localhost          AKASA.local AKASA.localhost AKASA.localdomain AKASA # IPV6 loopback interface with four aliases following

100.106.12.31           AKASA.mydomain.com AKASA                                               # an IPV4 network address associated with a name plus an alias
fe80:16dd:a9ff:fee9:d17 AKASA.fastweb.it   AKASA                                               # an IPV6 network address associated with a name plus an alias

192.168.1.1             ZXHNF601                                                               # an IPv4 address/host association

#10.0.0.1               CISCO887VA                                                             # a comment

# LAN hosts
10.0.0.1                PROLIANTETH1                                                           # other associations
10.0.0.2                PROLIANTETH2
10.0.0.24               INDIGO2
10.0.0.25               ATHLON64

See also:

OpenBSD FAQ - Networking