×


Set Up and use and DNS for Virtual Machines on a NAT Network in Proxmox - How to do it ?

A homelab is a great way to learn about virtualization and networking. It's also a great way to experiment with different operating systems and applications.


If you're looking to set up a homelab, Proxmox is a great choice. Proxmox is a free and open-source virtualization platform that's easy to use and manage.


Here at IbmiMedia, we will show you how to set up a homelab and DNS with Proxmox and two NICs.


Prerequisites

  • A Proxmox server with at least one public IP address
  • A DHCP server for the private network


Steps to take
  • Create a new bridge in Proxmox.
  • Configure the bridge to use NAT.
  • Assign an IP address and subnet mask to the bridge.
  • Configure the DHCP server to use the bridge.
  • Create a new virtual machine.
  • Configure the virtual machine to use the bridge.


1. Creating a New Bridge

To create a new bridge, follow these steps:

  • Log in to the Proxmox web interface.
  • Click on the Networking tab.
  • Click on the Bridges tab.
  • Click on the Add button.
  • Enter a name for the bridge.
  • Select the NAT option.
  • Assign an IP address and subnet mask to the bridge.
  • Click on the Create button.


2. Configuring the Bridge to Use NAT

To configure the bridge to use NAT, follow these steps:

  • Open the /etc/network/interfaces file on the Proxmox server.
  • Find the line that starts with iface vmbr0.
  • Add the following lines to the end of the file:
post-up echo 1 > /proc/sys/net/ipv4/ip_forward
post-up iptables -t nat -A POSTROUTING -s '192.168.1.0/24' -o vmbr0 -j MASQUERADE

NOTE: Remember to use the details of your server accordingly.


3. Assigning an IP Address and Subnet Mask to the Bridge

To assign an IP address and subnet mask to the bridge, follow these steps:

  • Open the /etc/network/interfaces file on the Proxmox server.
  • Find the line that starts with iface vmbr0.
  • Update the address and netmask parameters to match the IP address and subnet mask you want to use.


4. Configuring the DHCP Server to Use the Bridge

If you are using a DHCP server to assign IP addresses to the virtual machines, you need to configure the DHCP server to use the bridge.

The exact steps for configuring the DHCP server will vary depending on the DHCP server you are using. 

However, the general steps are as follows:

  • Open the DHCP server configuration file.
  • Add a new subnet entry for the bridge.
  • Set the gateway parameter to the IP address of the bridge.


5. Creating a New Virtual Machine

To create a new virtual machine, follow these steps:

  • Log in to the Proxmox web interface.
  • Click on the Virtual Machines tab.
  • Click on the Create button.
  • Enter a name for the virtual machine.
  • Select the Linux operating system.
  • Select the NAT network.
  • Click on the Create button.


6. Configuring the Virtual Machine to Use the Bridge

Once the virtual machine is created, you need to configure the virtual machine to use the bridge.

The exact steps for configuring the virtual machine will vary depending on the operating system you are using. 

However, the general steps are as follows:

  • Open the network configuration file for the virtual machine.
  • Set the interface parameter to the bridge name.
  • Set the address and netmask parameters to the IP address and subnet mask you assigned to the bridge.



How to Configure the Virtual Machine to Use DNS ?

In order for a virtual machine to use DNS, you need to configure the virtual machine's network settings to use the DNS server. The exact steps for configuring the virtual machine will vary depending on the operating system you are using. 


However, the general steps are as follows:

  • Open the network configuration file for the virtual machine via /etc/network/interfaces.
  • Find the line that starts with dns-nameservers.
  • Add the IP addresses of the DNS servers you want to use.


For example, if you want to use Google's DNS servers, you would add the following lines to the dns-nameservers parameter:

dns-nameservers 8.8.8.8 8.8.4.4

Once you have configured the virtual machine's network settings, you need to restart the virtual machine for the changes to take effect.

In Linux, you can do this by running the following command:

$ sudo service networking restart

After you have restarted the network service, the virtual machine will be able to use DNS to resolve domain names.


Conclusion

In this guide, we showed you how to set up virtual machines on a NAT network in Proxmox.