第 9 章 Setting up a static networking configuration by using cloud-init
You can set up network configuration with cloud-init by adding a network-interfaces section to the metadata.
Red Hat Enterprise Linux (RHEL) provides its default networking service through NetworkManager, a dynamic network control and configuration daemon that keeps network devices and connections up and active when they are available.
+
Your datasource might provide a network configuration. For details, see the cloud-init section Network Configuration Sources.
If you do not specify network configuration for cloud-init and have not disabled network configuration, cloud-init tries to determine if any attached devices have an existing connection. If it finds a connected device, it generates a network configuration that issues a DHCP request on the interface. Refer to the cloud-init documentation section Fallback Network Configuration for more information.
Prerequisites
Depending on the requirements of your datasource, edit the
user-datafile or add the following directive to thecloud.cfg.ddirectory:注意All user directives include
#cloud-configat the top of the file so thatcloud-initrecognizes the file as containing user directives. When you include directives in thecloud.cfg.ddirectory, name the file*.cfg, and always include#cloud-configat the top of the file.
Procedure
Add a
network-interfacessection. For example:network: version: 1 config: - type: physical name: eth0 subnets: - type: static address: 192.0.2.1/24 gateway: 192.0.2.254
You can disable a network configuration by adding the following information to your metadata.
network:
config: disabled