Setting Up OpenWRT on a Virtual Machine with Proxmox

Introduction

OpenWRT is a popular open-source firmware for routers and embedded devices. This guide will walk you through setting up OpenWRT on a virtual machine using Proxmox, a powerful virtualization platform. We’ll cover downloading the OpenWRT image, creating the VM, and configuring a LAN bridge.

Step 1: Download the OpenWRT Image

First, you need to download the latest OpenWRT image. You can get the image from the following URL:

https://images.linuxcontainers.org/images/openwrt/23.05/amd64/default/

OR

https://downloads.openwrt.org/releases/23.05.2/targets/x86/64/

This link points to the root filesystem in tar.xz format for OpenWRT 22.05 on an AMD64 architecture.

Step 2: Create the Virtual Machine

After downloading the image, the next step is to create a new VM in Proxmox. Use the following command to create a VM with the necessary specifications:

pct create 202 /var/lib/vz/template/cache/OpenWRT.tar.xz --arch amd64 --hostname OpenWrt-21.02 --rootfs local-lvm:20 --memory 1024 --cores 2 --ostype unmanaged --unprivileged 1

This command creates a VM with ID 202, sets the hostname to ‘OpenWrt-21.02’, allocates 20GB of root filesystem space, sets the memory to 1024MB, and assigns 2 CPU cores.

Step 3: Configure the LAN Bridge

The final step is to configure the LAN bridge. This will allow your VM to communicate with your network. Edit the network configuration file using vim:

vim /etc/config/network

Then, add the following configuration for the LAN interface:

config interface 'lan'
        option type 'bridge'
        option ifname 'eth0'
        option proto 'static'
        option netmask '255.255.255.0'
        option ipaddr '192.168.1.*'

Replace 192.168.1.* with the desired static IP address for your VM.

Conclusion

With these steps, you have successfully set up OpenWRT on a VM using Proxmox. This setup allows for a flexible and powerful network management solution. Feel free to explore more advanced configurations and enjoy the benefits of OpenWRT on your virtualized environment.

hi, your link is broken.

Thank you for letting me know. I did update it on here.

i got this error (storage ‘local-lvm’ does not exist)

Make sure you backup anything before proceeding

This issue can occur for a few reasons:

  1. LVM Storage Not Configured: If the ‘local-lvm’ storage was never set up on your Proxmox server, any attempt to access it would result in this error.
  2. Configuration Error: There might be a misconfiguration in your Proxmox setup where a VM or container is configured to use ‘local-lvm’, but it isn’t available.
  3. LVM Storage Deleted or Renamed: If ‘local-lvm’ was previously configured but later deleted or renamed, references to the old name could cause this error.
  4. Corrupted LVM Metadata: Rarely, LVM metadata corruption can lead to the system being unable to recognize existing LVM storage.

Here are steps to diagnose and potentially fix the issue:

  1. Verify LVM Configuration:
  • Use lvdisplay, vgdisplay, and pvdisplay commands to list Logical Volumes, Volume Groups, and Physical Volumes, respectively. Check if ‘local-lvm’ or similar entries exist.
  1. Check Proxmox Storage Configuration:
  • In the Proxmox web interface, go to “Datacenter” → “Storage” and see if ‘local-lvm’ is listed and correctly configured.
  1. Review VM/Container Configuration:
  • Check the configuration files of your VMs and containers (located in /etc/pve/qemu-server/ for VMs and /etc/pve/lxc/ for containers). Ensure they are not set to use ‘local-lvm’ if it doesn’t exist.
  1. Reconfigure or Create Storage:
  • If ‘local-lvm’ was intended to be used but isn’t set up, you can create and configure it using LVM tools and then add it to Proxmox via the web interface.
  1. Update References:
  • If you’ve renamed or removed ‘local-lvm’, update any references to the correct storage name in VM/container configurations.
  1. Proxmox Server Restart:
  • Sometimes, restarting the Proxmox server can help if the issue is due to a temporary glitch.
  1. Check for Corruptions:
  • If you suspect LVM metadata corruption, tools like vgck can be used to check the integrity of Volume Groups.

Hi. The link appears to be broken again. It would seem they only index the last 3 builds and then retire the older ones. I suggest to link to the downloads page rather than the direct link to the file.

https://images.linuxcontainers.org/images/openwrt/23.05/amd64/default/20240105_11%3A57/rootfs.tar.xz
https://images.linuxcontainers.org/images/openwrt/23.05/amd64/default/

Thanks for the writeup. I have been playing with opnsense and it’s much more than I need for a home router. I am hoping openwrt on proxmox will do the trick.

Ya, that would probably be a good idea. I changed it to the downloads page. Thanks for the suggestion.

Pfsense or opnsense is awesome, though :slight_smile:

hi, your link is broken and i couldn’t find rootfs.tar.xz
please update your links
thank you

Are these links not working for you?