Incus is also an educational tool, that helps learn about networks and what not.
Let’s learn!
First, we create a network incusbr1
, so that it is cleaner when we sudo tshark -r incusbr1
. No packets from other managed interfaces.
$ incus network create incusbr1 ipv4.address=10.10.12.1/24 ipv4.nat=true ipv6.address=none ipv6.nat=false
Network incusbr1 created
$ incus network show incusbr1
config:
ipv4.address: 10.10.12.1/24
ipv4.nat: "true"
ipv6.address: none
ipv6.nat: "false"
description: ""
name: incusbr1
type: bridge
used_by: []
managed: true
status: Created
locations:
- none
project: default
$
Then, we create a fresh new Ubuntu 12.04 instance. It assumes that your Ubuntu 12.04 image is stored locally, and is called ubuntu-from-canonical-12.04
.
$ incus create ubuntu-from-canonical-12.04 myinstance-1204 --network incusbr1
Creating myinstance-1204
$
Then, on a separate terminal, we run (and keep running) the following.
$ sudo tshark -i incusbr1
Running as user "root" and group "root". This could be dangerous.
Capturing on 'incusbr1'
** (tshark:88801) 14:36:26.891459 [Main MESSAGE] -- Capture started.
** (tshark:88801) 14:36:26.891522 [Main MESSAGE] -- File: "/tmp/wireshark_incusbr17Y81U2.pcapng"
Subsequently, on the initial terminal window, we start the container myinstance-1204
. This instance did its network initialization, and we switch terminal window to harvest the results.
$ incus start myinstance-1204
$ incus list myinstance-1204 -c ns4
+-----------------+---------+------+
| NAME | STATE | IPV4 |
+-----------------+---------+------+
| myinstance-1204 | RUNNING | |
+-----------------+---------+------+
$ sudo tshark -i incusbr1
Running as user "root" and group "root". This could be dangerous.
Capturing on 'incusbr1'
** (tshark:88801) 14:36:26.891459 [Main MESSAGE] -- Capture started.
** (tshark:88801) 14:36:26.891522 [Main MESSAGE] -- File: "/tmp/wireshark_incusbr17Y81U2.pcapng"
1 0.000000000 :: → ff02::16 ICMPv6 90 Multicast Listener Report Message v2
2 0.302373430 0.0.0.0 → 255.255.255.255 DHCP 342 DHCP Discover - Transaction ID 0x97c8946
3 0.302517451 10.10.12.1 → 10.10.12.111 DHCP 358 DHCP Offer - Transaction ID 0x97c8946
4 0.302579237 0.0.0.0 → 255.255.255.255 DHCP 342 DHCP Request - Transaction ID 0x97c8946
5 0.304688165 10.10.12.1 → 10.10.12.111 DHCP 358 DHCP ACK - Transaction ID 0x97c8946
Wow, what’s with that DHCP ACK? Did it…? Let’s see. Yep, it did!
$ incus exec myinstance-1204 -- cat /var/lib/dhcp/dhclient.eth0.leases
lease {
interface "eth0";
fixed-address 10.10.12.145;
option subnet-mask 255.255.255.0;
option routers 10.10.12.1;
option dhcp-lease-time 3600;
option dhcp-message-type 5;
option domain-name-servers 10.10.12.1;
option dhcp-server-identifier 10.10.12.1;
option dhcp-renewal-time 1800;
option broadcast-address 10.10.12.255;
option dhcp-rebinding-time 3150;
option host-name "myinstance-1204";
option domain-name "incus";
renew 3 2024/09/25 12:25:47;
rebind 3 2024/09/25 12:48:52;
expire 3 2024/09/25 12:56:22;
}
$
But did the instance set the interface’s IP address? Nope.
$ incus exec myinstance-1204 -- ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:3e:0a:9e:d6
inet6 addr: fe80::216:1eff:fe1a:c0ed/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:842 (842.0 B) TX bytes:1480 (1.4 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
$
Verdict? Something is wrong inside the Ubuntu 12.04 runtime and the instance does not set the IPv4 address properly. It gets the DHCP lease but does not set it.
Probably this would require a bit more investigation and the problem in the Ubuntu 12.04 runtime can be identified. We are so close to figuring this out. Anyone can take this up and reach the end of the investigation.
For now though, you can add some script in the instance to manually ifconfig
the IPv4 allocation.