I am trying out my hands with the LXC for the first time. I need a 22.04 VM that can have access to the internet. My host is a fresh installation of Ubuntu Server 24.04. My local physical LAN is eno33.
I first used neplan to set up a bridge:
network:
version: 2
renderer: networkd
ethernets:
eno33:
dhcp4: false
dhcp6: false
# addresses:
# - 172.16.56.26/23
# routes:
# - to: default
# via: 172.16.57.253
# nameservers:
# addresses: [172.16.99.7,172.16.99.8]
bridges:
br0:
interfaces: [eno33]
addresses: [172.16.56.26/23]
routes:
- to: default
via: 172.16.57.253
nameservers:
addresses: [172.16.99.7,172.16.99.8]
parameters:
stp: true
forward-delay: 4
apetros@host:~$ ip r
default via 172.16.57.253 dev br0 proto static
172.16.56.0/23 dev br0 proto kernel scope link src 172.16.56.26
apetros@host:~$ 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: eno33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
link/ether e4:3d:1a:62:13:16 brd ff:ff:ff:ff:ff:ff
altname enp99s0f0
8: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether ae:f4:ec:9a:d1:c1 brd ff:ff:ff:ff:ff:ff
inet 172.16.56.26/23 brd 172.16.57.255 scope global br0
valid_lft forever preferred_lft forever
inet6 fe80::acf4:ecff:fe9a:d1c1/64 scope link
valid_lft forever preferred_lft forever
I then create the VM:
apetros@host:~$ lxc init ubuntu:22.04 u1 --vm
apetros@host:~$ lxc config device add u1 eth0 nic nictype=bridged parent=br0 name=eth0
apetros@host:~$ lxc restart u1
apetros@host:~$ lxc list
+----------+---------+------+------+-----------------+-----------+
| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS |
+----------+---------+------+------+-----------------+-----------+
| u1 | RUNNING | | | VIRTUAL-MACHINE | 0 |
+----------+---------+------+------+-----------------+-----------+
As you see, no ip is given to the u1. Seeing more details:
apetros@spslab:~$ lxc config show --expanded u1
architecture: x86_64
config:
image.architecture: amd64
image.description: ubuntu 22.04 LTS amd64 (release) (20241004)
image.label: release
image.os: ubuntu
image.release: jammy
image.serial: "20241004"
image.type: disk-kvm.img
image.version: "22.04"
volatile.base_image: ab8380e088c0e3e2d88b7a32224de91723c2fe455f151db61c36eb23900f69cd
volatile.cloud-init.instance-id: 758bffe1-74e5-4ab9-a74c-e7da29a93696
volatile.eth0.host_name: tap3add331f
volatile.eth0.hwaddr: 00:16:3e:17:fb:e6
volatile.last_state.power: RUNNING
volatile.uuid: 9c04c042-b026-44da-a081-06ecbe91f1f5
volatile.uuid.generation: 9c04c042-b026-44da-a081-06ecbe91f1f5
volatile.vsock_id: "1271446946"
devices:
eth0:
name: eth0
nictype: bridged
parent: br0
type: nic
root:
path: /
pool: default
type: disk
ephemeral: false
profiles:
- default
stateful: false
description: ""
A simple:
lxc exec u1 -- apt update
Shows the VM has no internet access. Doing:
apetros@host:~$ lxc exec u1 -- bash
root@u1:~# 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
2: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:16:3e:17:fb:e6 brd ff:ff:ff:ff:ff:ff
inet6 fe80::216:3eff:fe17:fbe6/64 scope link
valid_lft forever preferred_lft forever
So, eth0 is not available inside u1 and only enp5s0 is there.
Any ideas what to do?