34
34
35
35
## How to Enable
36
36
37
- Make sure that you have ` systemd-resolved ` enabled and running:
37
+ Make sure that you have ` systemd-resolved ` enabled and running. First, make sure
38
+ that ` systemd-resolved.service ` is enabled and started:
38
39
39
40
``` bash
40
41
systemctl enable systemd-resolved.service
41
42
systemctl start systemd-resolved.service
42
43
```
43
44
44
- Then update your ` /etc/nsswitch.conf ` file to look up DNS via the ` resolve `
45
- service (you may need to install the NSS library which connects libnss to
45
+ Next, you can either configure the system libraries to talk to it using NSS, or
46
+ you can override the ` resolv.conf ` file to use ` systemd-resolved ` as a stub
47
+ resolver (or both):
48
+
49
+ ### NSS and nssswitch.conf
50
+
51
+ Update your ` /etc/nsswitch.conf ` file to look up DNS via the ` resolve ` service
52
+ (you may need to install the NSS library which connects libnss to
46
53
` systemd-resolved ` ):
47
54
48
55
``` conf
@@ -54,25 +61,42 @@ hosts: files resolve dns myhostname
54
61
hosts: files resolve myhostname
55
62
```
56
63
57
- ** Note** : If you intend on using this script, the latter two are preferred
58
- otherwise the configuration provided by this script will only work on domains
59
- that cannot be resolved by the currently configured DNS servers (i.e. they must
60
- fall back after trying the ones set by your LAN's DHCP server).
64
+ The changes will be applied as soon as the file is saved.
61
65
62
- [ LP1685045 ] : https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1685045
66
+ ### Stub Resolver
63
67
64
- ** Note** : The NSS interface for ` systemd-resolved ` may be deprecated and has
65
- already been flagged for deprecation in Ubuntu (see [ LP #1685045 ] [ LP1685045 ] for
66
- details). In this case, you should set your ` nameserver ` in your
67
- ` /etc/resolv.conf ` to ` 127.0.0.53 ` , which will interact with the stub resolver
68
- (introduced in systemd-231) giving you the improved configuration and routing
69
- support, without having to worry about trying to manage your ` /etc/resolv.conf `
70
- file. This can be done by linking to ` stub-resolv.conf ` :
68
+ The ` systemd-resolved ` service (since systemd-231) also listens on ` 127.0.0.53 `
69
+ via the ` lo ` interface, providing a stub resolver which any client can call to
70
+ request DNS, whether or not it uses the system libraries to resolve DNS, and
71
+ you no longer have to worry about trying to manage your ` /etc/resolv.conf `
72
+ file. This set up can be installed by linking to ` stub-resolv.conf ` :
71
73
72
74
``` bash
73
75
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
74
76
```
75
77
78
+ ### Usage and Ubuntu and Fedora
79
+
80
+ #### Ubuntu
81
+
82
+ [ LP1685045 ] :https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1685045
83
+
84
+ The NSS interface for ` systemd-resolved ` may be deprecated and has
85
+ already been flagged for deprecation in Ubuntu (see [ LP #1685045 ] [ LP1685045 ] for
86
+ details). In this case, you should use the Stub Resolver method now.
87
+
88
+ #### Fedora
89
+
90
+ [ authselect ] :https://github.com/pbrezina/authselect
91
+
92
+ Fedora 28 makes use of ` authselect ` to manage the NSS settings on the system.
93
+ Directly editing ` nsswitch.conf ` is not recommended as it may be overwritten at
94
+ any time if ` authselect ` is run. Proper overrides may not yet be possible - see
95
+ [ pbrezina/authselect] [ authselect ] for details. However, like Ubuntu, the [ Stub
96
+ Resolver] ( #stub-resolver ) method is recommended here too.
97
+
98
+ ### OpenVPN Configuration
99
+
76
100
Finally, update your OpenVPN configuration file and set the ` up ` and ` down `
77
101
options to point to the script, and ` down-pre ` to ensure that the script is run
78
102
before the device is closed:
@@ -86,7 +110,7 @@ down /etc/openvpn/scripts/update-systemd-resolved
86
110
down-pre
87
111
```
88
112
89
- ### up-restart
113
+ #### up-restart
90
114
91
115
It is recommended to use ` up-restart ` in your configuration to ensure that
92
116
` upate-systemd-resolved ` is run on restarts - where the connection is
@@ -95,7 +119,7 @@ original connection has timed out and `persist-tun` is enabled). If you do not
95
119
have ` persist-tun ` set, or you use ` ping-exit ` instead of ` ping-timeout ` , you
96
120
most likely will not need this.
97
121
98
- ### down/pre-down with user/group
122
+ #### down/pre-down with user/group
99
123
100
124
The ` down ` and ` down-pre ` options here will not work as expected where the
101
125
` openvpn ` daemon drops privileges after establishing the connection (i.e. when
0 commit comments