Question

Private IP is not created for custom image

I am using the API to spin up a droplet that uses a custom image. I have enabled private ip at the time of creation but no network is created in the droplet. I can see in the DigitalOcean control panel that private networking is enabled and an ip is assigned but nothing in the VM.

Do I need to do something with cloud-init/user_data?

This is the result of ifconfig inside the droplet. The private ip is reported as 10.138.228.115 in the DO control panel.

cni0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet 10.42.0.1  netmask 255.255.255.0  broadcast 0.0.0.0
        inet6 fe80::6cd8:2ff:fead:197c  prefixlen 64  scopeid 0x20<link>
        ether 6e:d8:02:ad:19:7c  txqueuelen 1000  (Ethernet)
        RX packets 16493  bytes 5822810 (5.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14985  bytes 5568640 (5.5 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 138.197.215.166  netmask 255.255.240.0  broadcast 138.197.223.255
        inet6 fe80::2861:54ff:fecb:cf11  prefixlen 64  scopeid 0x20<link>
        ether 2a:61:54:cb:cf:11  txqueuelen 1000  (Ethernet)
        RX packets 22260  bytes 195862505 (195.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 14195  bytes 3272184 (3.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet6 fe80::c047:b9ff:fec5:a9d2  prefixlen 64  scopeid 0x20<link>
        ether c2:47:b9:c5:a9:d2  txqueuelen 1000  (Ethernet)
        RX packets 14  bytes 1056 (1.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 17  bytes 1486 (1.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

flannel.1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet 10.42.0.0  netmask 255.255.255.255  broadcast 10.42.0.0
        inet6 fe80::a05c:1dff:fe85:35e1  prefixlen 64  scopeid 0x20<link>
        ether a2:5c:1d:85:35:e1  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 7 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 54328  bytes 16474969 (16.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 54328  bytes 16474969 (16.4 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth18f05a6b: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet6 fe80::6c14:c2ff:fe3d:7b59  prefixlen 64  scopeid 0x20<link>
        ether 6e:14:c2:3d:7b:59  txqueuelen 0  (Ethernet)
        RX packets 16  bytes 1188 (1.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 60  bytes 4496 (4.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth2172da13: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet6 fe80::8894:11ff:fef8:b374  prefixlen 64  scopeid 0x20<link>
        ether 8a:94:11:f8:b3:74  txqueuelen 0  (Ethernet)
        RX packets 3875  bytes 356564 (356.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3945  bytes 950682 (950.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

veth9cf7a2ae: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet6 fe80::b004:27ff:feea:198d  prefixlen 64  scopeid 0x20<link>
        ether b2:04:27:ea:19:8d  txqueuelen 0  (Ethernet)
        RX packets 5315  bytes 4296860 (4.2 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4185  bytes 2032236 (2.0 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethb375b810: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet6 fe80::401:77ff:fe2a:995d  prefixlen 64  scopeid 0x20<link>
        ether 06:01:77:2a:99:5d  txqueuelen 0  (Ethernet)
        RX packets 4033  bytes 370761 (370.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4057  bytes 1286040 (1.2 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vethe08e53f8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet6 fe80::f8cc:e5ff:fe3b:48ed  prefixlen 64  scopeid 0x20<link>
        ether fa:cc:e5:3b:48:ed  txqueuelen 0  (Ethernet)
        RX packets 2839  bytes 769892 (769.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2862  bytes 785522 (785.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

The device itself is properly created ( ens4 ) so the missing piece is likely the integration of the metadata with the interface configuration. This is generally done with cloud-init, which should be aware of using the ConfigDrive datasource ( https://cloudinit.readthedocs.io/en/latest/topics/datasources/configdrive.html ).

You may want to check the cloud-init logs for any issues and ensure that your image is prepared with a release of cloud-init that can handle this data for properly configuring the network interface. Depending on the image and environment, this may use an intermediate layer to produce the configuration ( e.g. netplan <-> systemd-networkd/NetworkManager ) but is highly dependent on the software included in the image.