I downloaded CentOS Atomic Host from here and installed in VirtualBox VM with Bridged adapter as the network adapter. Default installation and I only setup root password and nothing else. Then I logged in the VM and ran the command systemctl enable cloud-init
to initialize my instance and reboot
.
The user-data and meta-data files of cloud-init are as follows:
#meta-data | #user-data
--------------------------------------------------------------------------------
instance-id: magicatomic | #cloud-config
local-hostname: ss.magicatomic | groups:
network-interfaces: | | - docker: [root]
auto enp0s3 | write_files:
iface enp0s3 inet static | - content: |
address 192.168.1.110 | {
network 192.168.1.0 | "debug": true,
netmask 255.255.255.0 | "hosts": ["tcp://192.168.1.110:2375"]
broadcast 192.168.1.255 | }
gateway 192.168.1.1 | path: /etc/docker/daemon.json
| runcmd:
| - sudo systemctl daemon-reload
| - sudo systemctl restart docker.service
But the configuration is half broken, meaning:
Default Gateway is not set and Protocol is not set to static in /etc/sysconfig/network-scripts/ifcfg-enp0s3
When I do cat /etc/sysconfig/network-scripts/ifcfg-enp0s3
I get
BOOTPROTO=none
DEVICE=enp0s3
IPADDR=192.168.1.110
NETMASK=255.255.255.0
ONBOOT=yes
TYPE=ethernet
USERCTL=no
And when I do route -n
Kernel IP Routing Table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
192.168.1.0 0.0.0.0 255.255.255.0 U 100 0 0 enp0s3
QUESTION: No Default Gateway is set
Best Answer
Maybe it's only 25% broken... Your cloud-init configuration results in "BOOTPROTO=none", which is equivalent with "BOOTPROTO=static" More info at these links.
https://access.redhat.com/solutions/41630 or https://unix.stackexchange.com/questions/167083/bootproto-none-static-dhcp-and-etc-resolv-conf
I'm still looking for why the default gateway is not set. Have you tried removing that line? I'm reviewing the docs... http://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v1.html
Update: This appears to be a known issue, and is being actively worked on. The bugs tracking this issue are https://bugzilla.redhat.com/show_bug.cgi?id=1492726 and https://bugs.launchpad.net/cloud-init/+bug/1686856
As a workaround, I would suggest adding a line to runcmd with something like this
nmcli con modify enp0s3 ipv4.gateway 192.168.1.1