How do I add multiple options for dnsmasq via raw.dnsmasq

Hi

How do I add multiple dnsmasq options via raw.dnsmasq? It seems that when I use raw.dnsmasq a second time then previous options get overwritten.

As I understand it, you want to append to the raw.dnsmasq.
I think you can only set the value for the option raw.dnsmasq (and all other options).
Which means that if you want to append, you need to read the existing value, make your modifications and then set the final value.

Thanks, then entries would need to be line separated. Any idea how to make that happen? I’ve managed to insert \n but it doesn’t seem to have the desired effect.

Here is one way to do it,

$ lxc network edit lxdbr0
(opens up a text editor)

It should show you the config: section that looks like

config:
  ipv4.address: 10.50.253.1/24
  ipv4.nat: "true"
  ipv6.address: fd42:cba6:557e:1a5f::1/64
  ipv6.nat: "true"

Change as follows:

config:
  ipv4.address: 10.50.253.1/24
  ipv4.nat: "true"
  ipv6.address: fd42:cba6:557e:1a5f::1/64
  ipv6.nat: "true"
  raw.dnsmasq: |-
    no-hosts
    expand-hosts
    dhcp-ttl=3600

Alternatively, you can do:

$ lxc network get lxdbr0 raw.dnsmasq

$ echo -e "no-hosts\nexpand-hosts" | lxc network set lxdbr0 raw.dnsmasq -

$ lxc network get lxdbr0 raw.dnsmasq
no-hosts
expand-hosts
3 Likes

what is this symbol : |- ?

It is part of how YAML works with newlines.

https://yaml.org/spec/1.2.2/#8112-block-chomping-indicator