assign multiple ip to VM using cloud-init

n0bie

Member
Dec 28, 2021
57
2
8
36
does anyone can give us the script cloud-init to build / create VM with 2 ip address directly into os linux ?
in this case cloud-init from proxmox only support 1 ip public..how if we assign 2 ip address?
thanks
 
I don't think this is possible with cloud-init.

Cloud-init is meant to make the newly deployed machine available over the network for other automation tools to take over.

Configure your second IP address with e.g. Ansible after the VM is up and running.
 
Hi,
for each virtual NIC (net[n]) you configure for the VM, you can configure the IP with the corresponding ipconfig[n] cloud-init setting. See man qm for the details of the setting or the Cloud-Init panel for the VM in the UI.
 
Hi,
for each virtual NIC (net[n]) you configure for the VM, you can configure the IP with the corresponding ipconfig[n] cloud-init setting. See man qm for the details of the setting or the Cloud-Init panel for the VM in the UI.
so u mean using cloud-init possible to assign multiple ip? can u give me example under proxmox please? in this case we only able to assign 1 ip only
 
so u mean using cloud-init possible to assign multiple ip? can u give me example under proxmox please? in this case we only able to assign 1 ip only
Example configuration, relevant settings are net{0,1} and ipconfig{0,1}:
Code:
boot: c
bootdisk: scsi0
cipassword: $5$CJNhfoT0$dk7lpMTPhq2c/0MeFy.RePr9VeC7sB6K53ddU1fmpf3
ciuser: rooty
cores: 4
ide2: local:9006/vm-9006-cloudinit.qcow2,media=cdrom
ipconfig0: ip=192.168.20.155/24
ipconfig1: ip=192.168.21.155/24
memory: 4384
meta: creation-qemu=7.0.0,ctime=1663838846
name: foobar
net0: virtio=66:10:DF:FA:72:F9,bridge=vmbr0
net1: virtio=42:B9:7D:DD:53:23,bridge=vmbr1
scsi0: myzpool:vm-9006-disk-0,size=2G
scsihw: virtio-scsi-pci
serial0: socket
smbios1: uuid=d5930ac8-f28a-4f61-9900-38157358495f
vga: serial0
vmgenid: 201debc7-989c-4ed8-a567-be925793ca39
In the UI, just add the NICs in the VM's Hardware tab first and then set the IP Config settings in the Cloudinit tab for the VM.
 
i mean 1 eth0 but contain 2 ips.. possible?

in your tutorial it shows eth0 and eth1.
 
i mean 1 eth0 but contain 2 ips.. possible?

in your tutorial it shows eth0 and eth1.
You can assign one IPv4 and one IPv6 address. I don't think it's possible otherwise with the usual configuration mechanism. Why would you need that?
 
It might actually be possible with cloud-init too if the guest runs something like Netplan. Translating/Summarizing what @mira said here:

You can write a script based on the v2 network config format [1] and pass it as-is to the VM/Netplan via the --cicustom parameter, see section 10.8.3 of [0].

[0] https://pve.proxmox.com/pve-docs/pve-admin-guide.html#qm_cloud_init (10.8.3)
[1] https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v2.html
how about cloud-init in proxmox? they only able to assign 1 ip address only per network ethernet...
 
how about cloud-init in proxmox? they only able to assign 1 ip address only per network ethernet...
Yes, the ipconfigN options only allow one IPv4 and IPv6 address. If you need more advanced configuration, you need to use a different mechanism.
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!