How to configure systemd-resolved and systemd-networkd to use local DNS server for resolving local domains and remote DNS server for remote domains?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I'm connected to local area network with access to the Internet through gateway. There is DNS server in local network which is capable of resolving hostnames of computers from local network.
I would like to configure systemd-resolved and systemd-networkd so that lookup requests for local hostnames would be directed (routed) exclusively to local DNS server and lookup requests for all other hostnames would be directed exclusively to another, remote DNS server.
linux systemd dns systemd-networkd systemd-resolved
add a comment |Â
up vote
2
down vote
favorite
I'm connected to local area network with access to the Internet through gateway. There is DNS server in local network which is capable of resolving hostnames of computers from local network.
I would like to configure systemd-resolved and systemd-networkd so that lookup requests for local hostnames would be directed (routed) exclusively to local DNS server and lookup requests for all other hostnames would be directed exclusively to another, remote DNS server.
linux systemd dns systemd-networkd systemd-resolved
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm connected to local area network with access to the Internet through gateway. There is DNS server in local network which is capable of resolving hostnames of computers from local network.
I would like to configure systemd-resolved and systemd-networkd so that lookup requests for local hostnames would be directed (routed) exclusively to local DNS server and lookup requests for all other hostnames would be directed exclusively to another, remote DNS server.
linux systemd dns systemd-networkd systemd-resolved
I'm connected to local area network with access to the Internet through gateway. There is DNS server in local network which is capable of resolving hostnames of computers from local network.
I would like to configure systemd-resolved and systemd-networkd so that lookup requests for local hostnames would be directed (routed) exclusively to local DNS server and lookup requests for all other hostnames would be directed exclusively to another, remote DNS server.
linux systemd dns systemd-networkd systemd-resolved
asked May 8 at 17:01
Piotr Dobrogost
68411127
68411127
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
2
down vote
In the configuration file for local network interface we have to either specify we want to obtain local DNS server address from DHCP server using DHCP=
option:
[Network]
DHCP=yes
or specify its address explicitly using DNS=
option:
[Network]
DNS=10.0.0.1
In addition we need to specify (in the same section) local domains using Domains=
option
Domains=domainA.example domainB.example ~example
We specify local domains domainA.example domainB.example
to get the following behavior (from systemd-resolved.service, systemd-resolved man page):
Lookups for a hostname ending in one of the per-interface domains are
exclusively routed to the matching interfaces.
This way hostX.domainA.example
will be resolved exclusively by our local DNS server.
We specify with ~example
that all domains ending in example
are to be treated as route-only domains to get the following behavior (from description of this commit) :
DNS servers which have route-only domains should only be used for the
specified domains.
This way hostY.on.the.internet
will be resolved exclusively by our global, remote DNS server.
Note
Ideally, when using DHCP protocol, local domain names should be obtained from DHCP server instead of being specified explicitly in configuration file of network interface above. See UseDomains=
option. However there are still outstanding issues with this feature â see systemd-networkd DHCP search domains option issue.
We need to specify remote DNS server as our global, system-wide DNS server. We can do this in /etc/systemd/resolved.conf
file:
[Resolve]
DNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
Don't forget to reload configuration and to restart services:
$ sudo systemctl daemon-reload
$ sudo systemctl restart systemd-networkd
$ sudo systemctl restart systemd-resolved
Caution!
Above guarantees apply only when names are being resolved by systemd-resolved â see man page for nss-resolve, libnss_resolve.so.2 and man page for systemd-resolved.service, systemd-resolved.
See also:
Description of routing lookup requests in systemd related man pages is unclear
How to troubleshoot DNS with systemd-resolved?
References:
- Man page for systemd-resolved.service, systemd-resolved
- Man page for resolved.conf, resolved.conf.d
- Man page for systemd-network
4
Have you considered not using.local
in this example? Certainly with avahi, this was supposed to be reserved for MDNS and misusing it was a big no-no. It would be clearer to me to useexample.com
or .example.
â sourcejedi
May 8 at 17:17
@sourcejedi For reference.local
is defined as special domain in RFC 6762 â Multicast DNS in section Multicast DNS Names. Thanks, fixed.
â Piotr Dobrogost
May 9 at 7:48
Unrelated note: you can self-accept answers too.
â intelfx
May 9 at 13:41
@intelfx Not so fast â You can accept your own answer tomorrow :)
â Piotr Dobrogost
May 9 at 13:47
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
In the configuration file for local network interface we have to either specify we want to obtain local DNS server address from DHCP server using DHCP=
option:
[Network]
DHCP=yes
or specify its address explicitly using DNS=
option:
[Network]
DNS=10.0.0.1
In addition we need to specify (in the same section) local domains using Domains=
option
Domains=domainA.example domainB.example ~example
We specify local domains domainA.example domainB.example
to get the following behavior (from systemd-resolved.service, systemd-resolved man page):
Lookups for a hostname ending in one of the per-interface domains are
exclusively routed to the matching interfaces.
This way hostX.domainA.example
will be resolved exclusively by our local DNS server.
We specify with ~example
that all domains ending in example
are to be treated as route-only domains to get the following behavior (from description of this commit) :
DNS servers which have route-only domains should only be used for the
specified domains.
This way hostY.on.the.internet
will be resolved exclusively by our global, remote DNS server.
Note
Ideally, when using DHCP protocol, local domain names should be obtained from DHCP server instead of being specified explicitly in configuration file of network interface above. See UseDomains=
option. However there are still outstanding issues with this feature â see systemd-networkd DHCP search domains option issue.
We need to specify remote DNS server as our global, system-wide DNS server. We can do this in /etc/systemd/resolved.conf
file:
[Resolve]
DNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
Don't forget to reload configuration and to restart services:
$ sudo systemctl daemon-reload
$ sudo systemctl restart systemd-networkd
$ sudo systemctl restart systemd-resolved
Caution!
Above guarantees apply only when names are being resolved by systemd-resolved â see man page for nss-resolve, libnss_resolve.so.2 and man page for systemd-resolved.service, systemd-resolved.
See also:
Description of routing lookup requests in systemd related man pages is unclear
How to troubleshoot DNS with systemd-resolved?
References:
- Man page for systemd-resolved.service, systemd-resolved
- Man page for resolved.conf, resolved.conf.d
- Man page for systemd-network
4
Have you considered not using.local
in this example? Certainly with avahi, this was supposed to be reserved for MDNS and misusing it was a big no-no. It would be clearer to me to useexample.com
or .example.
â sourcejedi
May 8 at 17:17
@sourcejedi For reference.local
is defined as special domain in RFC 6762 â Multicast DNS in section Multicast DNS Names. Thanks, fixed.
â Piotr Dobrogost
May 9 at 7:48
Unrelated note: you can self-accept answers too.
â intelfx
May 9 at 13:41
@intelfx Not so fast â You can accept your own answer tomorrow :)
â Piotr Dobrogost
May 9 at 13:47
add a comment |Â
up vote
2
down vote
In the configuration file for local network interface we have to either specify we want to obtain local DNS server address from DHCP server using DHCP=
option:
[Network]
DHCP=yes
or specify its address explicitly using DNS=
option:
[Network]
DNS=10.0.0.1
In addition we need to specify (in the same section) local domains using Domains=
option
Domains=domainA.example domainB.example ~example
We specify local domains domainA.example domainB.example
to get the following behavior (from systemd-resolved.service, systemd-resolved man page):
Lookups for a hostname ending in one of the per-interface domains are
exclusively routed to the matching interfaces.
This way hostX.domainA.example
will be resolved exclusively by our local DNS server.
We specify with ~example
that all domains ending in example
are to be treated as route-only domains to get the following behavior (from description of this commit) :
DNS servers which have route-only domains should only be used for the
specified domains.
This way hostY.on.the.internet
will be resolved exclusively by our global, remote DNS server.
Note
Ideally, when using DHCP protocol, local domain names should be obtained from DHCP server instead of being specified explicitly in configuration file of network interface above. See UseDomains=
option. However there are still outstanding issues with this feature â see systemd-networkd DHCP search domains option issue.
We need to specify remote DNS server as our global, system-wide DNS server. We can do this in /etc/systemd/resolved.conf
file:
[Resolve]
DNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
Don't forget to reload configuration and to restart services:
$ sudo systemctl daemon-reload
$ sudo systemctl restart systemd-networkd
$ sudo systemctl restart systemd-resolved
Caution!
Above guarantees apply only when names are being resolved by systemd-resolved â see man page for nss-resolve, libnss_resolve.so.2 and man page for systemd-resolved.service, systemd-resolved.
See also:
Description of routing lookup requests in systemd related man pages is unclear
How to troubleshoot DNS with systemd-resolved?
References:
- Man page for systemd-resolved.service, systemd-resolved
- Man page for resolved.conf, resolved.conf.d
- Man page for systemd-network
4
Have you considered not using.local
in this example? Certainly with avahi, this was supposed to be reserved for MDNS and misusing it was a big no-no. It would be clearer to me to useexample.com
or .example.
â sourcejedi
May 8 at 17:17
@sourcejedi For reference.local
is defined as special domain in RFC 6762 â Multicast DNS in section Multicast DNS Names. Thanks, fixed.
â Piotr Dobrogost
May 9 at 7:48
Unrelated note: you can self-accept answers too.
â intelfx
May 9 at 13:41
@intelfx Not so fast â You can accept your own answer tomorrow :)
â Piotr Dobrogost
May 9 at 13:47
add a comment |Â
up vote
2
down vote
up vote
2
down vote
In the configuration file for local network interface we have to either specify we want to obtain local DNS server address from DHCP server using DHCP=
option:
[Network]
DHCP=yes
or specify its address explicitly using DNS=
option:
[Network]
DNS=10.0.0.1
In addition we need to specify (in the same section) local domains using Domains=
option
Domains=domainA.example domainB.example ~example
We specify local domains domainA.example domainB.example
to get the following behavior (from systemd-resolved.service, systemd-resolved man page):
Lookups for a hostname ending in one of the per-interface domains are
exclusively routed to the matching interfaces.
This way hostX.domainA.example
will be resolved exclusively by our local DNS server.
We specify with ~example
that all domains ending in example
are to be treated as route-only domains to get the following behavior (from description of this commit) :
DNS servers which have route-only domains should only be used for the
specified domains.
This way hostY.on.the.internet
will be resolved exclusively by our global, remote DNS server.
Note
Ideally, when using DHCP protocol, local domain names should be obtained from DHCP server instead of being specified explicitly in configuration file of network interface above. See UseDomains=
option. However there are still outstanding issues with this feature â see systemd-networkd DHCP search domains option issue.
We need to specify remote DNS server as our global, system-wide DNS server. We can do this in /etc/systemd/resolved.conf
file:
[Resolve]
DNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
Don't forget to reload configuration and to restart services:
$ sudo systemctl daemon-reload
$ sudo systemctl restart systemd-networkd
$ sudo systemctl restart systemd-resolved
Caution!
Above guarantees apply only when names are being resolved by systemd-resolved â see man page for nss-resolve, libnss_resolve.so.2 and man page for systemd-resolved.service, systemd-resolved.
See also:
Description of routing lookup requests in systemd related man pages is unclear
How to troubleshoot DNS with systemd-resolved?
References:
- Man page for systemd-resolved.service, systemd-resolved
- Man page for resolved.conf, resolved.conf.d
- Man page for systemd-network
In the configuration file for local network interface we have to either specify we want to obtain local DNS server address from DHCP server using DHCP=
option:
[Network]
DHCP=yes
or specify its address explicitly using DNS=
option:
[Network]
DNS=10.0.0.1
In addition we need to specify (in the same section) local domains using Domains=
option
Domains=domainA.example domainB.example ~example
We specify local domains domainA.example domainB.example
to get the following behavior (from systemd-resolved.service, systemd-resolved man page):
Lookups for a hostname ending in one of the per-interface domains are
exclusively routed to the matching interfaces.
This way hostX.domainA.example
will be resolved exclusively by our local DNS server.
We specify with ~example
that all domains ending in example
are to be treated as route-only domains to get the following behavior (from description of this commit) :
DNS servers which have route-only domains should only be used for the
specified domains.
This way hostY.on.the.internet
will be resolved exclusively by our global, remote DNS server.
Note
Ideally, when using DHCP protocol, local domain names should be obtained from DHCP server instead of being specified explicitly in configuration file of network interface above. See UseDomains=
option. However there are still outstanding issues with this feature â see systemd-networkd DHCP search domains option issue.
We need to specify remote DNS server as our global, system-wide DNS server. We can do this in /etc/systemd/resolved.conf
file:
[Resolve]
DNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
Don't forget to reload configuration and to restart services:
$ sudo systemctl daemon-reload
$ sudo systemctl restart systemd-networkd
$ sudo systemctl restart systemd-resolved
Caution!
Above guarantees apply only when names are being resolved by systemd-resolved â see man page for nss-resolve, libnss_resolve.so.2 and man page for systemd-resolved.service, systemd-resolved.
See also:
Description of routing lookup requests in systemd related man pages is unclear
How to troubleshoot DNS with systemd-resolved?
References:
- Man page for systemd-resolved.service, systemd-resolved
- Man page for resolved.conf, resolved.conf.d
- Man page for systemd-network
edited May 9 at 7:50
answered May 8 at 17:01
Piotr Dobrogost
68411127
68411127
4
Have you considered not using.local
in this example? Certainly with avahi, this was supposed to be reserved for MDNS and misusing it was a big no-no. It would be clearer to me to useexample.com
or .example.
â sourcejedi
May 8 at 17:17
@sourcejedi For reference.local
is defined as special domain in RFC 6762 â Multicast DNS in section Multicast DNS Names. Thanks, fixed.
â Piotr Dobrogost
May 9 at 7:48
Unrelated note: you can self-accept answers too.
â intelfx
May 9 at 13:41
@intelfx Not so fast â You can accept your own answer tomorrow :)
â Piotr Dobrogost
May 9 at 13:47
add a comment |Â
4
Have you considered not using.local
in this example? Certainly with avahi, this was supposed to be reserved for MDNS and misusing it was a big no-no. It would be clearer to me to useexample.com
or .example.
â sourcejedi
May 8 at 17:17
@sourcejedi For reference.local
is defined as special domain in RFC 6762 â Multicast DNS in section Multicast DNS Names. Thanks, fixed.
â Piotr Dobrogost
May 9 at 7:48
Unrelated note: you can self-accept answers too.
â intelfx
May 9 at 13:41
@intelfx Not so fast â You can accept your own answer tomorrow :)
â Piotr Dobrogost
May 9 at 13:47
4
4
Have you considered not using
.local
in this example? Certainly with avahi, this was supposed to be reserved for MDNS and misusing it was a big no-no. It would be clearer to me to use example.com
or .example.â sourcejedi
May 8 at 17:17
Have you considered not using
.local
in this example? Certainly with avahi, this was supposed to be reserved for MDNS and misusing it was a big no-no. It would be clearer to me to use example.com
or .example.â sourcejedi
May 8 at 17:17
@sourcejedi For reference
.local
is defined as special domain in RFC 6762 â Multicast DNS in section Multicast DNS Names. Thanks, fixed.â Piotr Dobrogost
May 9 at 7:48
@sourcejedi For reference
.local
is defined as special domain in RFC 6762 â Multicast DNS in section Multicast DNS Names. Thanks, fixed.â Piotr Dobrogost
May 9 at 7:48
Unrelated note: you can self-accept answers too.
â intelfx
May 9 at 13:41
Unrelated note: you can self-accept answers too.
â intelfx
May 9 at 13:41
@intelfx Not so fast â You can accept your own answer tomorrow :)
â Piotr Dobrogost
May 9 at 13:47
@intelfx Not so fast â You can accept your own answer tomorrow :)
â Piotr Dobrogost
May 9 at 13:47
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f442598%2fhow-to-configure-systemd-resolved-and-systemd-networkd-to-use-local-dns-server-f%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password