If a private image is created from an ECS or external image file and the VM where the ECS or external image file is located is configured with a static IP address, you need to configure DHCP so that the new ECSs created from the private image can dynamically obtain an IP address.
The configuration method varies depending on OSs.
When registering an external image file as a private image, configure DHCP on the VM where the external image file is located. You are advised to configure DHCP on the VM and then export the image file.
You have logged in to the ECS used to create a Windows private image.
For details about how to log in to an ECS, see Elastic Cloud Server User Guide.
network:version:2renderer:NetworkManagerethernets:eth0:dhcp4: true
network:version:2renderer:NetworkManagerethernets:eth0:dhcp4: noaddresses: [192.168.1.109/24]gateway4: 192.168.1.1nameservers:addresses: [8.8.8.8,114.114.114.114]
Delete the static IP address settings and set dhcp4 to true. You can also use a number sign (#) to comment out the static IP address settings.
network:version:2renderer:NetworkManagerethernets:eth0:dhcp4: true # Set dhcp4 to true.#dhcp4: no # Delete or comment out the static IP address settings.#addresses: [192.168.1.109]#gateway4: 192.168.1.1#nameservers:# addresses: [8.8.8.8,114.114.114.114]
network:version:2renderer:NetworkManagerethernets:eth0:dhcp4: trueeth1:dhcp4: trueeth2:dhcp4: trueeth3:dhcp4: true
vi /etc/network/interfaces
auto loiface lo inet loopbackauto eth0iface eth0 inet dhcpauto eth1iface eth1 inet dhcp
auto loiface lo inet loopbackauto eth0#iface eth0 inet dhcpiface eth0 inet staticaddress 192.168.1.109netmask 255.255.255.0gateway 192.168.1.1
You can also use a number sign (#) to comment out the static IP address settings.
auto loiface lo inet loopbackauto eth0iface eth0 inet dhcp
If the ECS has multiple NICs, you must configure DHCP for all the NICs.
auto loiface lo inet loopbackauto eth0iface eth0 inet dhcpauto eth1iface eth1 inet dhcp
The system saves the settings and exits the vi editor.
Configure DHCP to enable the ECS to obtain IP addresses continuously.