Reserving IP for bridge networks

Hi all,

My bridge looks like below.

name: lxdbr0
description: ""
type: bridge
managed: true
status: Created
config:
  ipv4.address: 10.152.22.1/24
  ipv4.nat: "true"
  ipv6.address: none

1 Where do lxd keeps track of IPs released to instances/containers? Is there some dhcp server kind of thingy? I wanted to crated HA k8s on three machine containers using kube-VIP. So this needs IP (for virtual IP purposes) to be reserved for HA in k8s. This IP has to be part of same SM as instances.

Lets say I want to reserve IP 10.152.22.254, 253 for HA purpose. how do I do that? Once reserved these IPs should not be assinged to any VMs/instances created later.

2 With /24 254 IPs are possible. Is there any way I cand modify this subnet?

edit - for 2, looks like editing lxc network edit lxdbr0 and changing values of ipv4.address is suffice for SM change. Only thing is - you need delete existing instances to get IP from new range

Mak

ps -ef | grep lxd tells me this

lxd 71964 0.0 0.0 10500 4144 ? Ss 17:18 0:00 dnsmasq --keep-in-foreground --strict-order --bind-interfaces --except-interface=lo --pid-file= --no-ping --interface=lxdbr0 --dhcp-rapid-commit --no-negcache --quiet-dhcp --quiet-dhcp6 --quiet-ra --listen-address=10.2.0.1 --dhcp-no-override --dhcp-authoritative --dhcp-leasefile=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.leases --dhcp-hostsfile=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.hosts --dhcp-range 10.2.0.2,10.2.15.254,1h -s lxd --interface-name _gateway.lxd,lxdbr0 -S /lxd/ --conf-file=/var/snap/lxd/common/lxd/networks/lxdbr0/dnsmasq.raw -u lxd -g lxd

So I went to /var/snap/lxd/common/lxd/networks/lxdbr0/ and there dnsmsq.pid file have thse arguments. Tried editing the dhcp-range argument on this file and bounced lxd service from snap.

Futile

For bridge networks LXD uses dnsmasq.

You can specify the ranges of IPs that LXD will allocate dynamic addresses from by specifying:

https://documentation.ubuntu.com/lxd/en/latest/reference/network_bridge/#network-bridge-network-conf:ipv4.dhcp.ranges

E.g.

lxc network set lxdbr0 ipv4.dhcp.ranges=192.0.2.10-192.0.2.20

Anything outside of the range can then be used freely.

2 Likes

Thanks a lot for help.

1 Like