Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Minae Lee <[email protected]>
Signed-off-by: K Kovács <[email protected]>
  • Loading branch information
kkovacs and minaelee authored Dec 11, 2024
1 parent 878d2a5 commit 2d5ee63
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions doc/howto/network_bridge_resolved.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,19 @@ You must repeat the commands after each reboot and after LXD is restarted, or ma

## Make the `resolved` configuration persistent

### Solution "A"

You can automate the `systemd-resolved` DNS configuration, so that it is applied on system start and takes effect when LXD creates the network interface.

To do so, create a `systemd` network file named `/etc/systemd/network/<network_bridge>.network` with the following content:
You can automate the systemd-resolved DNS configuration so that it is applied on system start and takes effect when LXD creates the network interface. To do so, there are two approaches you can take, detailed below. Use only one of the approaches.

The first approach is recommended as more resilient; it is reapplied if the lxdbr0 network is re-created at any point. For example, updating and restarting LXD can occasionally cause the lxdbr0 network to be recreated.

If you are unable to use the recommended approach for some reason, the second alternative approach can be used. However, if the lxdbr0 network is re-created, you must reapply that solution manually.

### Recommended approach

#### Create a `systemd` network file

Create a `systemd` network file named `/etc/systemd/network/<network_bridge>.network` with the following content:

```
[Match]
Expand All @@ -94,20 +102,24 @@ DNS=10.167.146.1
Domains=~lxd
```

If you have NOT freshly installed `lxd` (you've rebooted since install), then you only need to reload `systemd-resolved`:
#### Apply the updated configuration

If you have rebooted since you first installed LXD, you only need to reload `systemd-resolved`:

systemctl restart systemd-resolved.service

In case you **haven't rebooted yet since first initializing `lxd`**, then you need to either A) reboot the system, or B) reload `systemd-networkd` (to reload the `.network` files) and restart `lxd` (to add the routing).
If you have _not_ rebooted your system since you first installed LXD, you must either:
1. reboot the system, or
1. reload `systemd-networkd` (to reload the `.network` files) and restart `lxd` (to add the routing):

networkctl reload
snap restart lxd

You can test that the configuration got applied by running:
You can test that the updated configuration was applied by running:

resolvectl status

The output should contain a part similar to this (you can see the DNS server and the `.lxd` domain mentioned):
The output should contain a section similar to the example shown below. You should see the configured DNS server and the `~lxd` domain:

```
[...]
Expand All @@ -120,13 +132,10 @@ Current DNS Server: 10.167.146.1
[...]
```

This solution "A" is better than solution "B" in the sense that it is more resilient, and gets reapplied if the `lxdbr0` network is re-created for some reason (LXD update+restart occasionally does this).
### Alternative approach

### Solution "B"

You can automate the `systemd-resolved` DNS configuration, so that it is applied on system start and takes effect when LXD creates the network interface.

To do so, create a `systemd` unit file named `/etc/systemd/system/lxd-dns-<network_bridge>.service` with the following content:
Create a `systemd` unit file named `/etc/systemd/system/lxd-dns-<network_bridge>.service` with the following content:

```
[Unit]
Expand Down

0 comments on commit 2d5ee63

Please sign in to comment.