Looking for a complete example of setup for localhost/LAN brdging

I have found a working solution for this using as reference What is a Bridge? - ScottiByte's Discussion Forum

Edit netplan and apply the edits:

sh -c 'cat <<EOF >> /etc/netplan/50-cloud-init.yaml
    bridges:
        bridge0:
            interfaces: [enp3s0]
            addresses: [192.168.20.17/24]
            routes:
               - to: default
                 via: 192.168.20.1
            nameservers:
              addresses:
                - 1.1.1.1
                - 1.0.0.1
            parameters:
              stp: true
              forward-delay: 4
            dhcp4: no
EOF'

netplan apply

Add a new incus profile and edit it:

incus profile create bridgeprofile
incus profile edit bridgeprofile

Replace contents of bridgeprofile with:

config: {}
description: Bridge to Main LAN
devices:
  eth0:
    nictype: bridged
    parent: bridge0
    type: nic
name: bridgeprofile

Launch two new incus instances using brdidge0 and list all of six instances:

incus launch images:ubuntu/22.04 bc1      --profile default --profile bridgeprofile  # container
incus launch images:ubuntu/22.04 bm1 --vm --profile default --profile bridgeprofile  # virtual

incus list -cns4t
#+------+---------+------------------------+-----------------+
#| NAME |  STATE  |          IPV4          |      TYPE       |
#+------+---------+------------------------+-----------------+
#| bc1  | RUNNING | 192.168.20.40 (eth0)   | CONTAINER       |
#+------+---------+------------------------+-----------------+
#| bm1  | RUNNING | 192.168.20.41 (enp5s0) | VIRTUAL-MACHINE |
#+------+---------+------------------------+-----------------+
#| c1   | RUNNING | 10.79.158.18 (eth0)    | CONTAINER       |
#+------+---------+------------------------+-----------------+
#| mc1  | STOPPED |                        | CONTAINER       |
#+------+---------+------------------------+-----------------+
#| mv1  | STOPPED |                        | VIRTUAL-MACHINE |
#+------+---------+------------------------+-----------------+
#| v1   | RUNNING | 10.79.158.219 (enp5s0) | VIRTUAL-MACHINE |
#+------+---------+------------------------+-----------------+

Ping the new instances:

sh -c 'cat <<EOF >> /etc/hosts
192.168.20.40 bc1
192.168.20.41 bm1
EOF'

ping bc1 # ok from everywhere
ping bm1 # ok from everwhere

Fix the dead macvlan instances:

incus network edit macvlan
# edit 'parent: enp3s0' to 'parent: bridge0'
incus start mc1
incus start mv1
# backup again but their IPv4 addresses are different

1 Like