Using Dnsmasq DHCP Server in Proxmox for VMs IP | ComputingForGeeks

Using Dnsmasq DHCP Server in Proxmox for VMs IP

  • May 8, 2021

Dnsmasq is an easy to configure and lightweight DHCP Server and DNS forwarder. Dnsmasq is designed primarily to provide DNS service and optionally, DHCP, in a small network setup. The DHCP server in Dnsmasq integrates with the DNS server seamlessly. The machines with IP addresses allocated by DHCP server appear in the DNS with names configured either in each host or in a central configuration file.

Dnsmasq support dynamic and static DHCP leases. On top of stated features it has support for BOOTP/TFTP which can be used for network booting of diskless machines. Dnsmasq can be used in Proxmox virtualization platform to assign IP addresses dynamically or statically, and also to manage DNS. We’ll run Dnsmasq in one Proxmox hypervisor, with the service bound to specific network interface / bridge.

Step 1: Install dnsmasq on Proxmox VE 6.x

I’ll install dnsmasq in one Proxmox hypervisor from the default upstream repositories.

td-g-rec td-g-rec-id-content_inline tdi_2 td_block_template_1

sudo apt update
sudo apt install dnsmasq

Proceed to install dnsmasq on Proxmox VE 6.x

Reading state information... Done
The following additional packages will be installed:
  dns-root-data dnsmasq-base
Suggested packages:
  resolvconf
The following NEW packages will be installed:
  dns-root-data dnsmasq dnsmasq-base
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 463 kB of archives.
After this operation, 1,027 kB of additional disk space will be used.
Do you want to continue? [Y/n] y

Also install dnsutils package which provides dig command:

sudo apt install dnsutils -y

Test your installation:

$ dig computingforgeeks.com @localhost
nslookup computingforgeeks.com localhost

The DNS function in Dnsmasq is configured to forward all requests to your system’s default DNS settings as configured in /etc/resolv.conf file.

Step 2: Configure DHCP Server using Dnsmasq

After successful installation of Dnsmasq on your Proxmox server you can the start to configure DHCP service.

sudo vim /etc/dnsmasq.conf

Set domain for dnsmasq:

domain=example.com

Let dnsmasq know which ethernet interface it will use to listen for DHCP requests:

#Around line 106
interface=vmbr1
# Or which to listen on by address (remember to include 127.0.0.1 if you use this.)
#listen-address=

Set DHCP server range of IP addresses to hand out.

#around line 159
dhcp-range=192.168.50.50,192.168.50.200,12h

Set default route supplied by dnsmasq:

#around line 337
dhcp-option=vmbr1,3,192.168.50.1
#dhcp-option=eth0,3,192.168.50.1

Provide upstream DNS servers:

# You can use Google's open DNS servers
server=8.8.8.8
server=8.8.4.4

Set path to a file for the DHCP lease database:

dhcp-leasefile=/var/lib/misc/dnsmasq.leases

Test your configurations:

$ sudo dnsmasq --test
dnsmasq: syntax check OK.

Restart dnsmasq service:

sudo systemctl restart dnsmasq
sudo systemctl enable dnsmasq

Step 3: Create a VM on the network with DHCP service

Create a new Virtual Machine from Proxmox web console.

|image2|

Let’s give it a name and choose node where it will run.

|image3|

Select OS installation disc.

|image4|

Pick correct network (should be same as one used in dnsmasq DHCP configurations)

|image5|

Install the operating system and once completed reboot and check IP address if from DHCP.

|image6|

If the interface didn’t get IP address assigned by DHCP server automatically you can try manual request:

sudo dhclient interface

That marks the end of our article. Feel free to share your setup and test results via comments section.

Also check:

td-g-rec td-g-rec-id-content_bottom tdi_4 td_block_template_1

YOU CAN SUPPORT OUR WORK WITH A CUP OF COFFEE

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online.

Thank You for your support as we work to give you the best of guides and articles. Click below to buy us a coffee.

|PayPal Support|

Josphat Mutai

https://computingforgeeks.com/

Founder of Computingforgeeks. Expertise in Virtualization, Cloud, Linux/UNIX Administration, Automation,Storage Systems,

© 2014-2022 - ComputingforGeeks - Home for *NIX Enthusiasts


Last update: Nov 20, 2024