mirror of
https://github.com/coredns/coredns.git
synced 2026-07-12 10:40:10 -04:00
plugin/hosts: add wildcard support (#8185)
* plugin/hosts: add wildcard support for owner names Signed-off-by: youknowforsearch <amirhebrahimzader@gmail.com> * plugin/hosts: document wildcard owner name support Signed-off-by: youknowforsearch <amirhebrahimzader@gmail.com> * plugin/hosts: remove unused lookupStaticHost Signed-off-by: Amirhossein Ebrahimzade <amirhossein.e@smartech.ir> --------- Signed-off-by: youknowforsearch <amirhebrahimzader@gmail.com> Signed-off-by: Amirhossein Ebrahimzade <amirhossein.e@smartech.ir> Co-authored-by: Amirhossein Ebrahimzade <amirhossein.e@smartech.ir>
This commit is contained in:
committed by
GitHub
parent
e45ad5f87a
commit
6805f6f8a0
@@ -37,6 +37,28 @@ Examples:
|
||||
fdfc:a744:27b5:3b0e::1 example.com example
|
||||
~~~
|
||||
|
||||
### Wildcard records
|
||||
|
||||
Owner names may use a `*` as the leftmost label to match one additional label below
|
||||
that name. This follows the same wildcard semantics as the *file* plugin.
|
||||
|
||||
Examples:
|
||||
|
||||
~~~
|
||||
192.168.1.10 *.example.com
|
||||
192.168.1.11 a.example.com
|
||||
192.168.1.12 b.example.com
|
||||
~~~
|
||||
|
||||
With the entries above:
|
||||
|
||||
* `a.example.com` and `b.example.com` resolve to their explicit addresses.
|
||||
* `apps.example.com` resolves to `192.168.1.10`.
|
||||
* `example.com` does not match the wildcard (the zone apex is excluded).
|
||||
* `deep.apps.example.com` does not match `*.example.com` (only one label is matched).
|
||||
|
||||
Wildcard entries do not generate PTR records.
|
||||
|
||||
### PTR records
|
||||
|
||||
PTR records for reverse lookups are generated automatically by CoreDNS (based on the hosts file
|
||||
@@ -120,6 +142,20 @@ example.hosts example.org {
|
||||
}
|
||||
~~~
|
||||
|
||||
Resolve all single-label subdomains of `example.com` to one address, with explicit
|
||||
exceptions, and fall through for everything else under `example.com`.
|
||||
|
||||
~~~
|
||||
. {
|
||||
hosts example.hosts example.com {
|
||||
192.168.1.10 *.example.com
|
||||
192.168.1.11 www.example.com
|
||||
fallthrough example.com
|
||||
}
|
||||
forward . 8.8.8.8
|
||||
}
|
||||
~~~
|
||||
|
||||
## See also
|
||||
|
||||
The form of the entries in the `/etc/hosts` file are based on IETF [RFC 952](https://tools.ietf.org/html/rfc952) which was updated by IETF [RFC 1123](https://tools.ietf.org/html/rfc1123).
|
||||
|
||||
Reference in New Issue
Block a user