Custom Bridge Static container IP

Hello i created a custom bridge with a dedicated profile for it i am trying to set a static ip for the container but it does not work with the commands below any suggestions?

lxc stop c1
lxc network attach CustonBridg c1 eth0 eth0
lxc config device set c1 eth0 ipv4.address
lxc start c1

What does lxc network show CustomBridg show?

And what does lxc info show?

Note that the container may insist on getting its old IP in some cases. so you may also need to wipe the /var/lib/dhcp/… lease files.

If the custom bridge is not managed by LXD, is it possible to set the IP with


No, it’s not, though there’s no indication that this is the case here, I understood “custom bridge” here to mean that a separate bridge was created only for use by that profile.

the bridge was created this way

lxc network create WEBDNS ipv4.address= ipv4.nat=false

i also made ipv6 nat false, afterwards i copied the default profile and made changes to its parent to match WEBDNS and then started a centos7 container then ran the commands above.

here is the output of the two commands:

lxc info
config: {}
- storage_zfs_remove_snapshots
- container_host_shutdown_timeout
- container_stop_priority
- container_syscall_filtering
- auth_pki
- container_last_used_at
- etag
- patch
- usb_devices
- https_allowed_credentials
- image_compression_algorithm
- directory_manipulation
- container_cpu_time
- storage_zfs_use_refquota
- storage_lvm_mount_options
- network
- profile_usedby
- container_push
- container_exec_recording
- certificate_update
- container_exec_signal_handling
- gpu_devices
- container_image_properties
- migration_progress
- id_map
- network_firewall_filtering
- network_routes
- storage
- file_delete
- file_append
- network_dhcp_expiry
- storage_lvm_vg_rename
- storage_lvm_thinpool_rename
- network_vlan
- image_create_aliases
- container_stateless_copy
- container_only_migration
- storage_zfs_clone_copy
- unix_device_rename
- storage_lvm_use_thinpool
- storage_rsync_bwlimit
- network_vxlan_interface
- storage_btrfs_mount_options
- entity_description
- image_force_refresh
- storage_lvm_lv_resizing
- id_map_base
- file_symlinks
- container_push_target
- network_vlan_physical
- storage_images_delete
- container_edit_metadata
- container_snapshot_stateful_migration
- storage_driver_ceph
- storage_ceph_user_name
- resource_limits
- storage_volatile_initial_source
- storage_ceph_force_osd_reuse
- storage_block_filesystem_btrfs
- resources
- kernel_limits
- storage_api_volume_rename
- macaroon_authentication
- network_sriov
- console
- restrict_devlxd
- migration_pre_copy
- infiniband
- maas_network
- devlxd_events
- proxy
- network_dhcp_gateway
- file_get_symlink
- network_leases
- unix_device_hotplug
- storage_api_local_volume_handling
- operation_description
- clustering
- event_lifecycle
- storage_api_remote_volume_handling
- nvidia_runtime
- candid_authentication
api_status: stable
api_version: "1.0"
auth: trusted
public: false
- tls
  addresses: []
  - x86_64
  - i686
  certificate: |

  certificate_fingerprint: xxx
  driver: lxc
  driver_version: 3.0.2
  kernel: Linux
  kernel_architecture: x86_64
  kernel_version: 4.15.0-38-generic
  server: lxd
  server_pid: 263
  server_version: 3.0.2
  storage: btrfs
  storage_version: 4.15.1
  server_clustered: false
  server_name: Team1
root@Team1:~# lxc network show WEBDNS 
  ipv4.nat: "true"
  ipv6.address: fd42:25c2:5c51:d270::1/64
  ipv6.nat: "false"
description: ""
name: WEBDNS
type: bridge
- /1.0/containers/SocialNetwork
managed: true
status: Created
- none

Okay, I tried and it worked for me.

First, with init. That is, it’s a fresh container that did not launch yet.

$ lxc network create WEBDNS ipv4.address= ipv4.nat=false
Network WEBDNS created

$ ps ax | grep
18691 ?        S      0:00 dnsmasq --strict-order --bind-interfaces --pid-file=/var/snap/lxd/common/lxd/networks/WEBDNS/ --except-interface=lo --interface=WEBDNS --quiet-dhcp --quiet-dhcp6 --quiet-ra --listen-address= --dhcp-no-override --dhcp-authoritative --dhcp-leasefile=/var/snap/lxd/common/lxd/networks/WEBDNS/dnsmasq.leases --dhcp-hostsfile=/var/snap/lxd/common/lxd/networks/WEBDNS/dnsmasq.hosts --dhcp-range,,1h --listen-address=fd42:da26:23c4:bfa5::1 --enable-ra --dhcp-range ::,constructor:WEBDNS,ra-stateless,ra-names -s lxd -S /lxd/ --conf-file=/var/snap/lxd/common/lxd/networks/WEBDNS/dnsmasq.raw -u lxd
18710 pts/7    S+     0:00 grep

$ lxc init ubuntu:18.04 c1
Creating c1

$ lxc network attach WEBDNS c1 eth0 eth0

$ lxc config device set c1 eth0 ipv4.address

$ lxc start c1

$ lxc list c1
| NAME |  STATE  |        IPV4        |                     IPV6                      |
| c1   | RUNNING | (eth0) | fd42:da26:23c4:bfa5:216:3eff:fe11:6a97 (eth0) |

Now, let’s try the same with a container that has been launched with the default profile.

$ lxc launch ubuntu:18.04 c2
Creating c2
Starting c2

$ lxc stop c2

$ lxc network attach WEBDNS c2 eth0 eth0 

$ lxc config device set c2 eth0 ipv4.address 

$ lxc start c2

$ lxc list c2
| NAME |  STATE  |        IPV4        |                     IPV6                      |
| c2   | RUNNING | (eth0) | fd42:da26:23c4:bfa5:216:3eff:fe00:de0b (eth0) |

This also works.

Still, there might be a case where it does not work. You mention that you are using a profile for this containers. It could be indeed a profile issue when you attach to a container.
Can you post a full test case (as I do above) which also shows how such a minimal profile is created?

So after using init and not launching my containers right as i create them using the same commands it does allow me to set the ip i would guess wiping /var/lib/dhcp/… lease files just like stgraber said would have most likely fixed the issue

thank you guys!!