DE | EN

Prologue

This guide focuses on setting up an OpenWRT virtual machine on top of your Proxmox Server.

With this you can create and manage VLAN networks without the need for a layer 3 switch or a vlan capable physical firewall.

For this to work, you need to follow the steps in this guide first: https://prox.guide/en/vlans.

Downloads

Here is the download link:

OpenWRT: https://downloads.openwrt.org/releases/.

Pick the latest version, in this case 23.05.4, then navigate to: 23.05.4/targets/x86/64/openwrt-23.05.4-x86-64-generic-ext4-combined-efi.img.gz.

Right click the link, and copy the download URL, so you can directly download it on Proxmox.

Create new VM

Create a new VM without disks or installation media, in this case we will name it DMZ-FW1.

Enable Qemu Agent and add an EFI storage. (Uncheck Pre-Enroll keys)

The hardware configuration I use is OVMF (UEFI), 1440fx, 1024 MB of RAM, 1 CPU core.

Downloading the image

Connect to your Proxmox console and issue following command:

Command: wget https://downloads.openwrt.org/releases/23.05.4/targets/x86/64/openwrt-23.05.4-x86-64-generic-ext4-combined-efi.img.gz. (Use the URL you copied.)

Then extract the image:

Command: gunzip openwrt-23.05.4-x86-64-generic-ext4-combined-efi.img.gz.

VM Firewall

Import image to VM

Now run following command to import the disk to the VM:

Command: qm importdisk 100 openwrt-23.05.4-x86-64-generic-ext4-combined-efi.img local-zfs. (Replace the VM-ID and storage target.)

qm importdisk

You can now see the new disk in our VMs Hardware configuration:

VM Hardware

Now double click the Unused Disk 0 and attach it as scsi0:

Attach disk

Change boot order

Navigate to Options and change the boot order:

Boot order

Confirm by clicking OK.

Boot order

Configure management IP

Now click Console and start up your VM for the first time.

Once booted you will see a screen like this:

OpenWRT boot

Press enter into the console, to enter a root shell.

OpenWRT shell

Type in following to open the network configuration:

Command: vi /etc/config/network.

Press i to enter insert mode. (The mode will be shown at the bottom left).

Then use your arrow keys to set the lan interface network configuration.

In our case we will use following configuration:

Option Value
ipaddr 10.0.20.254
netmask 255.255.255.0
gateway 10.0.20.1
dns 1.1.1.1
OpenWRT network config

Press ESC to exit insert mode.

Then type ":" and enter "wq" and press enter.

Now restart the network:

Command: /etc/init.d/network restart:

OpenWRT network restart

You can now try to access the Web-UI by accessing: https://<your-ip>/

Skip the certificate warning and you should see a login like this:

OpenWRT login

Press Log in, since we have not set a password yet.

Click on Go to password configuration and set a password.

OpenWRT set password

Disable IPv6

We don't want IPv6 to interact with our network, so click on Network and navigate to Interfaces:

OpenWRT interfaces

Click Devices and click Configure on eth0:

OpenWRT devices

Set Enable IPv6 to disable, and hit Save:

Disable v6

Click Save & Apply as well.

Install qemu guest agent

Click System and then Software.

You should see a screen like this:

OpenWRT software

Click Update lists....

Then hit Dismiss and you should see some available packages.

Search for qemu-ga and install it:

Qemu GA
Qemu GA

Head back to the OpenWRT console and run reboot to reboot.

Create wan interface

Navigate to Network and Interfaces:

Network device

Then click Add new interface.

Name it wan and set the protocol to Static address, also set the device to Bridge and put it in the firewall zone wan:

OpenWRT interfaces

Configure DMZ firewall interface

We will create a new dmz named lab.

Our dmz will be based on the vlan 50.

The dmz network will be 192.168.0.0/24

Go to your firewall VMs hardware and add a new network device with the vlan 50:

Network device

Great, you should have two network devices now:

Network device

For each demilitarized zone you want one network device on your VM with the according VLAN.

Create interface in OpenWRT

Head back to the Web-UI of OpenWRT, then navigate to Interfaces.

Click Add new interface:

Add new interface

Set the name to the name of your zone, in this case lab, and set the Protocol to Static address.

Also pick the new network device:

Add new interface

Click Create interface.

Now configure following items:

General Settings

IPv4 address IPv4 netmask
192.168.0.1 255.255.255.0

Firewall Settings

Create firewall-zone
custom: lab

Click Save & Apply to create the new interface.

Add new interface

Configure firewall zones

Click Network then Firewall:

OpenWRT firewall

Set the default Output and Input to reject, and change it to the other zones to reject, except on wan.

Delete the lan => wan zone entry, then head to Network and Interfaces:

OpenWRT firewall

Edit the lan interface. Create a lan zone by assigning it to a zone named lan in the Firewall Settings tab:

OpenWRT firewall

Head back to the Network, then Firewall.

Set Input and Output to accept for wan.

When everything's good it should look like this:

OpenWRT firewall

Hit Save & Apply.

Create Traffic rules

Click Network, then Firewall and then Traffic rules.

Delete all the default rules, as we will create our own set:

Traffic rules

Block lan access

We don't want our demilitarized zones to access our lan.

Click Add, then configure like this: (Replace the destination with your network)

Traffic rules

Lab Internet

We do want to be able to access the internet from our lab zone.

Click Add and configure like this:

Traffic rules

If you have more zones, you should configure an internet traffic rule as well for them.

Click Save & Apply.

Create a port forward

We want to access our lab IP from our main network, for this I will use the IP 10.0.20.200.

Navigate to Network, then Interfaces and edit lan.

Next to the IPv4 address, click on "...".

Enter an available IP address:

Add interface ip

Great, now save and click Save & Apply.

Now navigate to Network, then Firewall and then Port Forwards:

Port forwards

Click Add.

You can make this port forward specific to ports, however we will just redirect all ports from 10.0.20.200 to 192.168.0.2.

192.168.0.2 will be our test client win1 later on.

Configure the port forward so it looks like this:

Port forward win1

In the Advanced Settings tab, select the IP address we just gave our lan interface.

Port forward win1

Click Save, then Save & Apply.

Testing our demilitarized zone

Testing is important, always test your configurations to avoid unintentional access.

I create a new VM on our Proxmox, and install Windows 11 on it.

During the VM creation I set the network card to use VLAN 50:

VLAN in network

Here's the network configuration within the VM:

VM network

With a ping we can confirm that we have internet:

VM network ping

We can also confirm that we have no access to our local lan, by pinging a device, in this case the Proxmox server:

VM network ping

I'll install openssh server on the Windows 11 machine, so I can test our port forwarding rule.

After that I head over to our Proxmox server console, and ssh into our Windows 11 VM, using 10.0.20.200:

Port forward
Port forward

As you can see, it works. We can access our VM, however the VM can't access our local lan.

You can create more demilitarized zones by adding more network interfaces your VM.

Notes

  • Always use a different unused network for each VLAN.
  • Always test your configurations for optimal security.
  • If you have a layer 3 switch, you can still tag the port of the Proxmox server and other ports on the switch with your VLANs and use them with physical devices.
  • You can remove the OpenWRT image file from your Proxmox /root directory, if you don't need it anymore.

🎉 Congratulations, you now have a way to isolate virtual machines from your network.