Skip to content

Commit 49cba47

Browse files
committed
Restructure documention with notes on Ubuntu and Fedora for #61
1 parent 16c6927 commit 49cba47

File tree

1 file changed

+41
-17
lines changed

1 file changed

+41
-17
lines changed

README.md

Lines changed: 41 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,22 @@ make
3434

3535
## How to Enable
3636

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:
3839

3940
```bash
4041
systemctl enable systemd-resolved.service
4142
systemctl start systemd-resolved.service
4243
```
4344

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
4653
`systemd-resolved`):
4754

4855
```conf
@@ -54,25 +61,42 @@ hosts: files resolve dns myhostname
5461
hosts: files resolve myhostname
5562
```
5663

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.
6165

62-
[LP1685045]:https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1685045
66+
### Stub Resolver
6367

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`:
7173

7274
```bash
7375
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
7476
```
7577

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+
76100
Finally, update your OpenVPN configuration file and set the `up` and `down`
77101
options to point to the script, and `down-pre` to ensure that the script is run
78102
before the device is closed:
@@ -86,7 +110,7 @@ down /etc/openvpn/scripts/update-systemd-resolved
86110
down-pre
87111
```
88112

89-
### up-restart
113+
#### up-restart
90114

91115
It is recommended to use `up-restart` in your configuration to ensure that
92116
`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
95119
have `persist-tun` set, or you use `ping-exit` instead of `ping-timeout`, you
96120
most likely will not need this.
97121

98-
### down/pre-down with user/group
122+
#### down/pre-down with user/group
99123

100124
The `down` and `down-pre` options here will not work as expected where the
101125
`openvpn` daemon drops privileges after establishing the connection (i.e. when

0 commit comments

Comments
 (0)