Pull request: DHCP: imp markup, opt docs

Merge in DNS/adguard-home-wiki from imp-opt to master

Squashed commit of the following:

commit 9ddad2fb3a1dd72dc0306eb3ef00fed41e813b98
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Oct 8 19:07:27 2021 +0300

    DHCP: imp wording

commit 1baf136849127585fb7d87ef21ff72224aadd570
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Fri Oct 8 18:51:08 2021 +0300

    DHCP: imp markup, opt docs
Ainar Garipov 2021-10-08 19:08:41 +03:00
parent 713163fe91
commit 1a8843345e
3 changed files with 82 additions and 62 deletions

@ -82,7 +82,7 @@ Examples:
* `[/example.local/]1.1.1.1`: DNS upstream for specific domains, see below. * `[/example.local/]1.1.1.1`: DNS upstream for specific domains, see below.
### <a hfer="#upstreams-for-domains" id="upstreams-for-domains" name="upstreams-for-domains">Specifying Upstreams For Domains</a> ### <a href="#upstreams-for-domains" id="upstreams-for-domains" name="upstreams-for-domains">Specifying Upstreams For Domains</a>
You can specify upstreams that will be used for specific domains using the You can specify upstreams that will be used for specific domains using the
dnsmasq-like syntax (see the documentation for the option `--server` dnsmasq-like syntax (see the documentation for the option `--server`

140
DHCP.md

@ -1,4 +1,4 @@
# AdGuard Home - DHCP Server # AdGuard Home - DHCP Server
* [Prerequisites](#prereq) * [Prerequisites](#prereq)
* [Default Options](#default) * [Default Options](#default)
@ -7,96 +7,112 @@
* [DHCPv6 Options](#config-6) * [DHCPv6 Options](#config-6)
* [Automatic Hosts](#autohosts) * [Automatic Hosts](#autohosts)
*AdGuard Home* can be used as a DHCP server. This page describes how to do that. AdGuard Home can be used as a DHCP server. This page describes how to do that.
## <a id="prereq" href="#prereq">Prerequisites</a> ## <a id="prereq" href="#prereq">Prerequisites</a>
1. Make sure that you run an OS on which *AdGuard Home* supports DHCP. We 1. Make sure that you run an OS on which AdGuard Home supports DHCP. We
currently don't support DHCP on *Windows*. currently don't support DHCP on Windows.
1. Make sure that your machine has a static IP address. 1. Make sure that your machine has a static IP address.
## <a id="default" href="#default">Default Options</a> ## <a id="default" href="#default">Default Options</a>
By default, *AdGuard Home* will set itself as the DNS server for the DHCP By default, AdGuard Home will set itself as the DNS server for the DHCP clients.
clients. The default lease time is 24 hours. The default lease time is 24 hours.
## <a id="config" href="#config">Configuration</a> ## <a id="config" href="#config">Configuration</a>
See the DHCP section in the [configuration] article for the overview of the DHCP See the DHCP section in the [configuration] article for the overview of the DHCP
configuration options. There are several configuration parameters for DHCP that configuration options. There are several configuration parameters for DHCP that
can't be set via the *AdGuard Home* administrator dashboard. Those are can't be set via the AdGuard Home administrator dashboard. Those are described
described below. below.
### <a id="config-4" href="#config-4">The `dhcp.dhcpv4.options` Array Field</a>
The `options` field accepts two types of values: `hex` and `ip`. Both start
with the `CODE`, which MUST be an integer in the [1, 255] range.
See [RFC 2132, sec. 3](https://tools.ietf.org/html/rfc2132#section-3). ### <a id="config-4" href="#config-4">The `dhcp.dhcpv4.options` Array Field</a>
The `hex` format is: The `options` field accepts four types of values: `hex`, `ip`, `ips`, and
`text`. They all start with the `CODE`, which MUST be an integer in the [1,
255] range. See also [RFC 2132, sec. 3][rfc-2132].
``` In accordance with [RFC 2131, sec. 4.3.1][rfc-2131], these options override the
CODE hex HEX_VALUE default options set by Adguard Home. Which means that if you want to set DNS
``` server addresses using option `6`, you should also add Adguard Home's own
addresses there. Otherwise, AdGuard Home's filtering won't work for the DHCP
clients who receive these DNS server addresses.
For example, to set option `6`, the DNS server, to two IP addresses, `1.2.3.4` * The `hex` format is:
and `1.2.3.5`, use:
```yaml ```
# … CODE hex HEX_VALUE
'dhcp': ```
# …
'dhcpv4': For example, to set option `6`, the DNS server, to two IP addresses,
`1.2.3.4` and `1.2.3.5`, use:
```yaml
# … # …
'options': 'dhcp':
- '6 hex 0102030401020305' # …
``` 'dhcpv4':
# …
'options':
- '6 hex 0102030401020305'
```
The `ip` format is: * The `ip` format is:
``` ```
CODE ip IPV4_VALUE CODE ip IPV4_VALUE
``` ```
For example, to set option `6`, the DNS server, to one IP address, `1.2.3.4`, For example, to set option `6`, the DNS server, to one IP address,
use: `1.2.3.4`, use:
```yaml ```yaml
# …
'dhcp':
# …
'dhcpv4':
# … # …
'options': 'dhcp':
- '6 ip 1.2.3.4' # …
``` 'dhcpv4':
# …
'options':
- '6 ip 1.2.3.4'
```
The `ips` format (since **v0.106.0**) is the same, but with comma-separated * The `ips` format (since **v0.106.0**) is the same, but with comma-separated
IP-addresses: IP-addresses:
```yaml ```yaml
# …
'dhcp':
# …
'dhcpv4':
# … # …
'options': 'dhcp':
- '6 ips 1.2.3.4,5.6.7.8' # …
``` 'dhcpv4':
# …
'options':
- '6 ips 1.2.3.4,5.6.7.8'
```
The `text` format (since **v0.106.0**) allows you to put arbitrary UTF-8 text as * The `text` format (since **v0.106.0**) allows you to put arbitrary UTF-8
the option data. For example: text as the option data. For example:
```yaml ```yaml
# …
'dhcp':
# …
'dhcpv4':
# … # …
'options': 'dhcp':
- '252 text http://example.com' # …
``` 'dhcpv4':
# …
'options':
- '252 text http://example.com'
```
### <a id="config-6" href="#config-6">DHCPv6 Options</a> ### <a id="config-6" href="#config-6">DHCPv6 Options</a>
@ -107,6 +123,10 @@ The option `dhcp.dhcpv6.ra_allow_slaac`, if `true`, sends RA packets allowing
the clients to choose between SLAAC and DHCPv6. the clients to choose between SLAAC and DHCPv6.
[configuration]: https://github.com/AdguardTeam/AdGuardHome/wiki/Configuration [configuration]: https://github.com/AdguardTeam/AdGuardHome/wiki/Configuration
[rfc-2131]: https://tools.ietf.org/html/rfc2131#page-29
[rfc-2132]: https://tools.ietf.org/html/rfc2132#section-3
## <a id="autohosts" href="#autohosts">Automatic Hosts</a> ## <a id="autohosts" href="#autohosts">Automatic Hosts</a>

@ -75,7 +75,7 @@ work. -->
and alike) for a host is basically the same as blocking that host. and alike) for a host is basically the same as blocking that host.
```none ```none
# Returns the IP address 1.2.3.4 for exmaple.org. # Returns the IP address 1.2.3.4 for example.org.
1.2.3.4 example.org 1.2.3.4 example.org
# Blocks example.com by responding with 0.0.0.0. # Blocks example.com by responding with 0.0.0.0.
0.0.0.0 example.com 0.0.0.0 example.com