Networking config Version 1 - cloud-init 25.1.2 documentation (original) (raw)

This network configuration format lets users customize their instance’s networking interfaces by assigning subnet configuration, virtual device creation (bonds, bridges, VLANs) routes and DNS configuration.

Required elements of a network config Version 1 are config andversion.

For example, the following could be present in/etc/cloud/cloud.cfg.d/custom-networking.cfg:

The NoCloud datasource can also provide cloud-initnetworking configuration in this format.

Configuration types

Within the network config portion, users include a list of configuration types. The current list of support type values are as follows:

Physical, Bond, Bridge and VLAN types may also include IP configuration under the key subnets.

Physical

The physical type configuration represents a “physical” network device, typically Ethernet-based. At least one of these entries is required for external network connectivity. Type physical requires only one key:name. A physical device may contain some or all of the following keys:

name: <desired device name>

A device’s name must be less than 15 characters. Names exceeding the maximum will be truncated. This is a limitation of the Linux kernel network-device structure.

mac_address: <MAC Address>

The MAC Address is a device unique identifier that most Ethernet-based network devices possess. Specifying a MAC Address is optional. Letters must be lowercase.

Note

It is best practice to “quote” all MAC addresses, since an unquoted MAC address might be incorrectly interpreted as an integer in YAML.

Note

Cloud-init will handle the persistent mapping between a device’sname and the mac_address.

mtu: <MTU SizeBytes>

The MTU key represents a device’s Maximum Transmission Unit, which is the largest size packet or frame, specified in octets (eight-bit bytes), that can be sent in a packet- or frame-based network. Specifying mtu is optional.

Note

The possible supported values of a device’s MTU are not available at configuration time. It’s possible to specify a value too large or to small for a device, and may be ignored by the device.

accept-ra: <boolean>

The accept-ra key is a boolean value that specifies whether or not to accept Router Advertisements (RA) for this interface. Specifying accept-rais optional.

Physical example

network: version: 1 config: # Simple network adapter - type: physical name: interface0 mac_address: '00:11:22:33:44:55' # Second nic with Jumbo frames - type: physical name: jumbo0 mac_address: 'aa:11:22:33:44:55' mtu: 9000 # 10G pair - type: physical name: gbe0 mac_address: 'cd:11:22:33:44:00' - type: physical name: gbe1 mac_address: 'cd:11:22:33:44:02'

Bond

A bond type will configure a Linux software Bond with one or more network devices. A bond type requires the following keys:

name: <desired device name>

A device’s name must be less than 15 characters. Names exceeding the maximum will be truncated. This is a limitation of the Linux kernel network-device structure.

mac_address: <MAC Address>

When specifying MAC Address on a bond this value will be assigned to the bond device and may be different than the MAC address of any of the underlying bond interfaces. Specifying a MAC Address is optional. If mac_address is not present, then the bond will use one of the MAC Address values from one of the bond interfaces.

Note

It is best practice to “quote” all MAC addresses, since an unquoted MAC address might be incorrectly interpreted as an integer in YAML.

bond_interfaces: <List of network device names>

The bond_interfaces key accepts a list of network device name values from the configuration. This list may be empty.

mtu: <MTU SizeBytes>

The MTU key represents a device’s Maximum Transmission Unit, the largest size packet or frame, specified in octets (eight-bit bytes), that can be sent in a packet- or frame-based network. Specifying mtu is optional.

Note

The possible supported values of a device’s MTU are not available at configuration time. It’s possible to specify a value too large or to small for a device, and may be ignored by the device.

params: <Dictionary of key: value bonding parameter pairs>

The params key in a bond holds a dictionary of bonding parameters. This dictionary may be empty. For more details on what the various bonding parameters mean please read the Linux Kernel Bonding.txt.

Valid params keys are:

Bond example

network: version: 1 config:

Simple network adapter

10G pair

Bridge

Type bridge requires the following keys:

Valid keys are:

Bridge example

network: version: 1 config:

Simple network adapter

Second nic with Jumbo frames

VLAN

Type vlan requires the following keys:

The following optional keys are supported:

mtu: <MTU SizeBytes>

The MTU key represents a device’s Maximum Transmission Unit, the largest size packet or frame, specified in octets (eight-bit bytes), that can be sent in a packet- or frame-based network. Specifying mtu is optional.

Note

The possible supported values of a device’s MTU are not available at configuration time. It’s possible to specify a value too large or to small for a device and may be ignored by the device.

VLAN example

network: version: 1 config: # Physical interfaces. - type: physical name: eth0 mac_address: 'c0:d6:9f:2c:e8:80' # VLAN interface. - type: vlan name: eth0.101 vlan_link: eth0 vlan_id: 101 mtu: 1500

Nameserver

Users can specify a nameserver type. Nameserver dictionaries include the following keys:

Nameserver example

network: version: 1 config: - type: physical name: interface0 mac_address: '00:11:22:33:44:55' subnets: - type: static address: 192.168.23.14/27 gateway: 192.168.23.1 - type: nameserver interface: interface0 # Ties nameserver to interface0 only address: - 192.168.23.2 - 8.8.8.8 search: - exemplary

Route

Users can include static routing information as well. A route dictionary has the following keys:

Route example

network: version: 1 config: - type: physical name: interface0 mac_address: '00:11:22:33:44:55' subnets: - type: static address: 192.168.23.14/24 gateway: 192.168.23.1 - type: route destination: 192.168.24.0/24 gateway: 192.168.24.1 metric: 3

Subnet/IP

For any network device (one of the “config types”) users can define a list ofsubnets which contain ip configuration dictionaries. Multiple subnet entries will create interface aliases, allowing a single interface to use different ip configurations.

Valid keys for subnets include the following:

Subnet types are one of the following:

When making use of dhcp or either of the ipv6_dhcpv6 types, no additional configuration is needed in the subnet dictionary.

Using ipv6_dhcpv6-stateless or ipv6_slaac allows the IPv6 address to be automatically configured with StateLess Address AutoConfiguration (SLAAC). SLAAC requires support from the network, so verify that your cloud or network offering has support before trying it out. With ipv6_dhcpv6-stateless, DHCPv6 is still used to fetch other subnet details such as gateway or DNS servers. If you only want to discover the address, use ipv6_slaac.

Subnet DHCP example

network: version: 1 config: - type: physical name: interface0 mac_address: '00:11:22:33:44:55' subnets: - type: dhcp

Subnet static example

network: version: 1 config: - type: physical name: interface0 mac_address: '00:11:22:33:44:55' subnets: - type: static address: 192.168.23.14/27 gateway: 192.168.23.1 dns_nameservers: - 192.168.23.2 - 8.8.8.8 dns_search: - exemplary.maas

Multiple subnet example

The following will result in an interface0 using DHCP and interface0:1using the static subnet configuration:

network: version: 1 config: - type: physical name: interface0 mac_address: '00:11:22:33:44:55' subnets: - type: dhcp - type: static address: 192.168.23.14/27 gateway: 192.168.23.1 dns_nameservers: - 192.168.23.2 - 8.8.8.8 dns_search: - exemplary

Subnet with routes example

network: version: 1 config: - type: physical name: interface0 mac_address: '00:11:22:33:44:55' subnets: - type: dhcp - type: static address: 10.184.225.122 netmask: 255.255.255.252 routes: - gateway: 10.184.225.121 netmask: 255.240.0.0 destination: 10.176.0.0 - gateway: 10.184.225.121 netmask: 255.240.0.0 destination: 10.208.0.0