| 1 |
# Name |
| 2 |
|
| 3 |
_dbhosts_ - serve data from /etc/hosts |
| 4 |
|
| 5 |
# Description |
| 6 |
|
| 7 |
The _dbhost_ handler is useful for serving data from a `/etc/hosts` file. It watches the file and reloads it |
| 8 |
when written to. The _dbhost_ handler can only reply to A, AAAA and PTR queries, all others are deferred to |
| 9 |
the next handler(s). |
| 10 |
|
| 11 |
The _dbhost_ handler can be used with readily available hosts files that block access to advertising servers. |
| 12 |
|
| 13 |
# Hosts File |
| 14 |
|
| 15 |
Commonly the entries are of the form `IP_address canonical_hostname [aliases...]` as explained by |
| 16 |
the hosts(5) man page. |
| 17 |
|
| 18 |
Examples: |
| 19 |
|
| 20 |
``` |
| 21 |
# The following lines are desirable for IPv4 capable hosts |
| 22 |
127.0.0.1 localhost |
| 23 |
192.168.1.10 example.com example |
| 24 |
|
| 25 |
# The following lines are desirable for IPv6 capable hosts |
| 26 |
::1 localhost ip6-localhost ip6-loopback |
| 27 |
fdfc:a744:27b5:3b0e::1 example.com example |
| 28 |
``` |
| 29 |
|
| 30 |
## Reverse Lookups |
| 31 |
|
| 32 |
PTR records for reverse lookups are generated automatically. |
| 33 |
|
| 34 |
# Syntax |
| 35 |
|
| 36 |
```txt |
| 37 |
dbhost [FILE] { |
| 38 |
ttl TTL |
| 39 |
} |
| 40 |
``` |
| 41 |
|
| 42 |
- **FILE** the hosts file to read and parse. If the path is relative the path from the _root_ |
| 43 |
handler will be prepended to it. Defaults to`/etc/hosts` if omitted. |
| 44 |
- `ttl` change the **TTL** of the records generated (forward and reverse). The default is 3600 seconds (1 hour). |
| 45 |
|
| 46 |
# Examples |
| 47 |
|
| 48 |
Load `/etc/hosts` file. |
| 49 |
|
| 50 |
```conffile |
| 51 |
. { |
| 52 |
dbhost |
| 53 |
} |
| 54 |
``` |
| 55 |
|
| 56 |
Load `example.hosts` file in the current directory (if _root_ is not set), and only use it for `example.org` |
| 57 |
names: |
| 58 |
|
| 59 |
``` |
| 60 |
example.org { |
| 61 |
dbhost example.hosts |
| 62 |
} |
| 63 |
``` |
| 64 |
|
| 65 |
# See Also |
| 66 |
|
| 67 |
The form of the entries in the `/etc/hosts` file are based on IETF [RFC |
| 68 |
952](https://tools.ietf.org/html/rfc952) which was updated by IETF [RFC |
| 69 |
1123](https://tools.ietf.org/html/rfc1123). |