Closed ruishuangvmw closed 2 weeks ago
Thank you @ruishuangvmw for filing this bug and making cloud-init better. I believe the absence of dhcp4/static config config type would be enough to prevent IPV4 configuration in the target Linux image on boot.
This details of this bug are a bit vague and I'm not quite certain from the bug where things are not working for you.
Provided those types you mentioned in the bug and our docs, we can see cloud-init rendering the appropriate network config content for the supported network backends: ENI (/etc/network/interfaces), sysconfig, netplan and network manager.
Here are some example network config files that represent configuration which does not setup IPV4-based config.
cat > static-ipv6.yaml <<EOF
network:
config:
- mac_address: aa:12:bc:34:ee:ac
name: eno3
subnets:
- address: fd00::12/64
dns_nameservers: ['fd00:2::15']
gateway: fd00::1
ipv6: true
routes:
- netmask: '32'
network: 'fd00:12::'
gateway: 'fd00::2'
type: static6
type: physical
version: 1
EOF
network:
config:
- mac_address: aa:12:bc:34:ee:ac
name: eno3
subnets:
- type: dhcp6
type: physical
version: 1
To check the network config files that cloud-init would generate without having to boot a machine you can run the net-convert command either on a system which has cloud-init installed, or from a clone of our cloud-init repo:
# on a system with cloud-init pre-installed render example netplan configuration for iPV6 static config file ./out.d/etc/netplan 50-cloud-init.yaml:
cloud-init devel net-convert --kind=yaml --network-data=ipv6.yaml --output-kind=netplan --directory=out.d --distro debian
# In a cloned cloud-init source repository, render example dhcp6-only config sysconfig files in out.d/etc/network/sysconfi for RedHat/suse systems:
git clone https://github.com/canonical/cloud-init.git
cd cloud-init
PYTHONPATH=. python3 -m cloud-init.cmd.main devel net-convert --kind=yaml --network-data=dhcp6.yaml --output-kind=sysconfig --directory=out.d --distro rhel
If a specific rendered network config does not work for your desired Linux distribution and/or desired network backend (network-manager, networkd, sysconfig, networkd. netplan, eni) please add the details of that source network config v1 and the problematic --output-kind
that is causing issues in your environment.
I'll make this issue as incomplete until we have more specifics to help us understand what isn't working in your environment.
Thank @blackboxsw for your reply. Great! This v1 config work on my testbed, and it could disable IPv4 network on RHEL, Debian and SLES OS. I will close this issue since I think cloud-init's existing features already meet our requirements. Thanks again
Hi, Can I disable IPv4 and configure an IPv6-only network on some mainstream Linux by cloud-init? My datastore uses https://cloudinit.readthedocs.io/en/latest/reference/network-config-format-v1.html format config file.
The above subnet type has no disable ipv4 options currently. And from the testing, the nic was configured either DHCP or static. Thanks,