How to Static Assign IP to Container and expose it to LAN

Hi,
I have Fedora 42 on a Laptop connected to Linksys Router. The Router does not have any internet connectivity. All connections i am referring in the post are wired connections and not wireless.
I have installed LXD and have 2 containers lxc-001 and lxc-002 with the default bridge network lxdbr0 in the host. Here by host i mean Fedora 42 laptop which is lxd host with the default network bridge lxdbr0 , it also has physical network card LAN interface that is connected to Linksys router. I did not yet configure this interface with any IP so far.

I want to assign IP Address of LAN to container individually like a static IP configuration and not using DHCP of router, the setting is disabled in router.
Linksys Router IP : 192.168.1.1
So my containers lxc-001 should be using 192.168.1.100 and lxc-002 should be using 192.168.1.101 etc…I can even have another laptop [fedora 41] wired to Linksys Router and assign a static IP using IPV4 static assignments you typically do using Network Manager.

Effectively what i am trying to do is assign static IP to all containers on the Linksys IP router network range. At the same time i do not want the lxdbr0 to be modified or changed in any manner. I am going to assign two network interfaces on lxc-001 and lxc-002 , one nic will be using lxdbr0 and another will be using the home linksys local network LAN in the ip range 192.168.1.xx

how will i do that? Please help.

Thanks,
Harishkumar

create a linux bridge or ovs bridge, let’s call it br0.
create a profile, let’s call it lan:

config: {}
description: connect containers to lan
devices:
  eth1:
    name: eth1
    nictype: bridged
    parent: br0
    type: nic

add this profile to containers. Inside containers, create network config for eth1 according to ct ditro instruction, for example systemd network:
/etc/systemd/network/eth1.network

[Match]
Name=eth1

[Network]
Address=192.168.1.101/24
Gateway=192.168.1.1

[DHCPv4]
UseDomains=true

[DHCP]
ClientIdentifier=mac

restart network: systemctl restart systemd-networkd

If I can go step by step it will be helpful for me.

First part: creation of linux bridge.
This bridge will be created on lxd host , fedora 42 system. With slave interface as the LAN card interface that is going to connect to router. In my case enps70 is the ifname.

Should I first assign some ip to this bridge? Or should I leave it blank. Like no configuration of ip just create bridge with physical interface. No static ip assignment for the br0 itself.

Am I getting it correct?

Thanks
Harishkumar

Thanks,
Harish P

I’m using ovs bridge, but I find a website tell you how to config linux bridge in fedora: Build a network bridge with Fedora - Fedora Magazine

IP for the new bridge br0 is only required if your host where lxd is needs to talk to linksys router.

I setup the container profile and bride connectivity and all.
Container start but not getting IPV4 address only getting IPV6 address. Please loot at number 8 interface in the output. Any help please.

Container terminal output:
root@lxc-001:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
6: eth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 00:16:3e:61:27:5f brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 10.191.213.6/24 metric 100 brd 10.191.213.255 scope global dynamic eth0
valid_lft 3598sec preferred_lft 3598sec
inet6 fe80::216:3eff:fe61:275f/64 scope link
valid_lft forever preferred_lft forever
8: eth1@if9: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
** link/ether 00:16:3e:0a:be:51 brd ff:ff:ff:ff:ff:ff link-netnsid 0**
** inet6 fe80::216:3eff:fe0a:be51/64 scope link **
** valid_lft forever preferred_lft forever**

can’t help, you didn’t give any useful information about ct’s network configurations.
which distro the ct use. which software is managing ct network. what is eth1’s configuration. did the bridge actually work.
I guess you didn’t manually config eth1 to use static ipv4 address.

Hi,
I am new to linux networking , please be patient with me i kindly request. i might ask silly or trivial questions.

Linux Host or LXC Host is Fedora 42
root@fedora:~# lxc profile show default
name: default
description: Default LXD profile
config: {}
devices:
eth0:
name: eth0
network: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
used_by:

  • /1.0/instances/lxc-001
  • /1.0/instances/lxc-002
  • /1.0/instances/rhel-lxc-001
    root@fedora:~# lxc profile show bridgeprofile
    name: bridgeprofile
    description: “”
    config: {}
    devices:
    eth1:
    name: eth1
    nictype: bridged
    parent: bridge0
    type: nic
    used_by:
  • /1.0/instances/lxc-001
  • /1.0/instances/rhel-lxc-001

lxc-001 is container - not getting IPV4 Address aggigned, only ipv6 gets assigned.
rhel-lxc-001 is virtual machine getting IPV4 assigned , after i boot into rhel i used nmtui to add a new network profile with MAC ID of NIC and DHCP setting. After this it is getting IPV4 assigned by DHCP.

The following is output of “ip a” command.
root@fedora:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: enp7s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether fc:3f:db:d5:f2:94 brd ff:ff:ff:ff:ff:ff
altname enxfc3fdbd5f294
3: wlp13s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 16:f4:f9:40:8a:9a brd ff:ff:ff:ff:ff:ff permaddr 30:f7:72:0e:46:99
altname wlx30f7720e4699
inet 192.168.40.2/24 brd 192.168.40.255 scope global dynamic noprefixroute wlp13s0
valid_lft 862450sec preferred_lft 862450sec
inet6 2401:4900:266d:50a5:edeb:2143:12c9:dbef/64 scope global dynamic noprefixroute
valid_lft 334563sec preferred_lft 334563sec
inet6 fe80::fcfa:4a1:7003:f538/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: bridge0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 4e:58:ce:81:fa:f4 brd ff:ff:ff:ff:ff:ff
5: lxdbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 00:16:3e:c0:f8:83 brd ff:ff:ff:ff:ff:ff
inet 10.191.213.1/24 scope global lxdbr0
valid_lft forever preferred_lft forever

Number 5 : lxdbr0 is the default lxd bridge created, i did not create it.
Number 4 : bridge0 is the bridge i created with Number 2 : enp7s0 as slave or physical NIC LAN adapter which connects to Linksys Router. This router has no internet functionality. Only DHCP Enabled.

Please ignore lxc-002 as of now, i am not booting that container at all.
lxc-001 and lxc-002 both are ubuntu 22.04 images from lxd launch image command.

lxc-001 and rhel-lxc-001 are assigned two profiles - one default and another bridge profile.

Please let me know for any further configuration.

Thanks,
Harishkumar

Your lxc-001 didn’t get a global unicast address, it just generated a link-local address. So no, it didn’t get an ipv6 address.

Oh, sorry. I missed you tell both instances are ubuntu. So they use netplan. you can read this website to config eth1 in instances:
https://people.ubuntu.com/~slyon/netplan-docs/examples/

Hi Harish!

LXD is no longer supported in this discussion forum

Instead, the Linux Containers project has moved to developing Incus. See how to migrate to Incus, which is a rather easy process.

Hi,
i cannot do that to linux container lxc-001 beacuse the interface name keeps changing across restart of container.
its like eth1@if12 and i restart lxc-001 it becomes eth1@if9 etc…it just keeps changing.

thanks,
harishkumar

Hi,
I am willing to go for incus, but will the scenario that i am trying to achieve is possible right? hope i am not making any mistakes in my setup.

Incus Host will be fedora 42.
Containers inside Incus specifically ubuntu 22.04 will be able to communicate with other containers using the default bridge for internet and at the same time will get IP assigned from my Linsys Router via DHCP or Static. So in essence the Container will have two network interfaces one default for internet via default bridge, another via local LAN network using my Linksys Router[IP Address V4 will be either dynamic or static. Will start with dynamic make it work later i can make it static thats the plan. ]

please let me know.

What you are trying to do, can be achieved with either. But we do Incus here.

Also, tips on formatting.

use eth1 will be ok, don’t worry about what come with @.

Hi,
Thanks for the suggestion. I configured netplan with static IP and DHCP both ways.
I got it working. One mistake was in the text of bridgeprofile.

  • root@fedora:~# lxc profile show bridgeprofile
    name: bridgeprofile
    description: “”
    config: {}
    devices:
    eth1:
    name: eth1 – I had to remove this entry. That created so much problem. That alone did not solve the issue, obviously after this removal from bridge profile entry netplan changes also helped.
    nictype: bridged
    parent: bridge0
    type: nic
    used_by:
  • /1.0/instances/lxc-001
  • /1.0/instances/rhel-lxc-001

Thanks to All,
Harishkumar