Can't disable DHCP network config on xenial
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
uvtool |
Confirmed
|
Wishlist
|
Unassigned |
Bug Description
Using uvtool, I am trying to bring up a xenial VM with a bridge to my LAN, and a static network address which I inject using write-files and some bootcmd & runcmd steps (details below).
Following the instructions in /etc/network/
For a trusty VM, this works:
ubuntu@
...
2: eth0: <BROADCAST,
link/ether 52:54:00:e1:8b:c3 brd ff:ff:ff:ff:ff:ff
inet 10.42.20.4/16 brd 10.42.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::5054:
valid_lft forever preferred_lft forever
But for a xenial VM, I find that the VM has two IP addresses: my statically assigned one and another which turns out to have come from DHCP (checked using DHCP logs).
ubuntu@
...
2: ens3: <BROADCAST,
link/ether 52:54:00:1d:e9:17 brd ff:ff:ff:ff:ff:ff
inet 10.42.0.60/16 brd 10.42.255.255 scope global ens3
valid_lft forever preferred_lft forever
inet 10.42.20.4/16 brd 10.42.255.255 scope global secondary ens3
valid_lft forever preferred_lft forever
inet6 fe80::5054:
valid_lft forever preferred_lft forever
My host is running 16.04:
will@host-nwtn25:~$ uname -a
Linux host-nwtn25 4.4.0-42-generic #62-Ubuntu SMP Fri Oct 7 23:11:45 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
will@host-nwtn25:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.1 LTS
Release: 16.04
Codename: xenial
will@host-nwtn25:~$ dpkg -l|grep cloud
ii cloud-image-utils 0.27-0ubuntu24 all cloud image management utilities
ii ubuntu-
will@host-nwtn25:~$ dpkg -l|grep uvt
ii uvtool-libvirt 0~bzr99-0ubuntu1 all Library and tools for using Ubuntu Cloud Images with libvirt
My command is:
sudo uvt-kvm create test-nwtn2 release=xenial arch=amd64 --bridge br0 --cpu 2 --memory 2048 --disk 16384 --user-data cloud-config.yml --log-console-
And cloud-config.yml has:
#cloud-config
...
bootcmd:
- "echo 'network: {config: disabled}' >/etc/cloud/
write_files:
- path: /etc/network/
content: |
auto lo
iface lo inet loopback
auto ens3
iface ens3 inet static
address 10.42.20.4
network 10.42.0.0
broadcast 10.42.255.255
netmask 255.255.0.0
gateway 10.42.0.1
dns-
runcmd:
- ifdown -a && ifup -a
I've also tried removing /etc/network/
(For trusty, the write_files talked about eth0 instead of ens3.)
Looks to me like the network: config: disabled bit should just go in the original cloud-config file, so that is a bit of a red herring.
But DHCP is still happening. It might be being done by networking.service - it seems that cloud-init mostly runs after networking has started up.
There is a cloud-init local step before networking has come up, but it doesn't seem to run bootcmd then?