Assign Static IPs to KVM guests using DHCP in Proxmox

This is my setting when assigning static IPs to KVM guests using DHCP in Proxmox. Currently I have 1 public IP and 2 failover IP (both failover IP has MAC address attached).

Install the DHCP server :

apt install isc-dhcp-server

Edit the config:

vi /etc/default/isc-dhcp-server

# Add below lines. The default bridge is vmbr0.
INTERFACES="vmbr0"

Modify the /etc/dhcp/dhcpd.conf. Example:

subnet 0.0.0.0 netmask 0.0.0.0 {
authoritative;
default-lease-time 21600000;
max-lease-time 432000000;
}

# Bind IP by MAC
host VM1 {
hardware ethernet 52:54:xx:xx:xx:x1;
option routers 62.xxx.xxx.1;
option subnet-mask 255.255.255.255;
fixed-address xxx.xxx.xxx.114;
option domain-name-servers 8.8.8.8,8.8.4.4;  
}

host VM2 {
hardware ethernet 52:54:xx:xx:xx:x2;
option routers 62.xxx.xxx.1;
option subnet-mask 255.255.255.255;
fixed-address xxx.xxx.xxx.115;
option domain-name-servers 8.8.8.8,8.8.4.4;  
}

Make sure the dhcp server running after reboot:

systemctl enable isc-dhcp-server
reboot

Later when creating the VM we just need to specify the MAC address for specific IP and than just use DHCP to get the assigned IP.


Related Posts

Published by

danpros

danpros

A self-proclaimed geek, business owner, and part-time blogger.