In this article, we’re going to look at the installation of OpenWrt in Proxmox Virtual Environment. OpenWrt can be installed in normal PC, on a Virtual Machine, or a server hardware, and enjoy the power that x86 (Intel/AMD) architecture can offer. OpenWrt Project is based on Linux operating system and created to suit applications in embedded devices in routing traffic. Additionally, OpenWrt provides a fully writable filesystem with package management that unlocks the power of integrations.
OpenWrt can be used for various functions such as:
- Configuring your private VPN server or client
- Setting up Dynamic DNS
- Enhancing your network security
- Improving the overall performance of your network with multiple devices
- Running BitTorrent client inside the router appliance
- Sharing of files between devices with the external storage drive being connected to OpenWrt router
- Using OpenWrt to create a network printer that can be accessed from your LAN
- Performing bandwidth throttling of a particular devices in the network
- For Real time network monitoring
1. Download OpenWrt Image for installation
We will perform the installation of OpenWRT on a Proxmox Virtual Environment. But first we need to download the latest image file for our CPU architecture. I’m on x86_64.
Get the latest release tag. You should run the commands in your Proxmox server.
VER=$(curl --silent "https://api.github.com/repos/openwrt/openwrt/releases/latest"|grep '"tag_name"'|sed -E 's/.*"([^"]+)".*/\1/'|sed 's/v//')
Download the latest OpenWRT image file into your Proxmox server path.
wget -O openwrt.img.gz https://downloads.openwrt.org/releases/$VER/targets/x86/64/openwrt-$VER-x86-64-generic-ext4-combined.img.gz
The file is actually small as can be confirmed below.
$ du -sh openwrt.img.gz
11M openwrt.img.gz
Extract downloaded archive to get raw image file
$ gunzip ./openwrt.img.gz
gzip: ./openwrt.img.gz: decompression OK, trailing garbage ignored
Let’s increase the size of the raw disk to 5GB.
$ qemu-img resize -f raw ./openwrt.img 5G
Image resized.
2. Create OpenWrt Virtual Machine on Proxmox VE
Login to your Proxmox VE shell and set required variables for Virtual Machine creation.
VM_NAME=OpenWrt
VM_ID=$(pvesh get /cluster/nextid)
RAM=2048
CORES=1
BRIDGE=vmbr0
IMAGE=./openwrt.img
Then create the Virtual Machine using qm
command line tool.
qm create --name $VM_NAME \
$VM_ID --memory $RAM \
--cores $CORES --cpu cputype=kvm64 \
--net0 virtio,bridge=$BRIDGE \
--scsihw virtio-scsi-pci --numa 1
You can list available storage domains using the following commands:
# pvesm status
Name Type Status Total Used Available %
local dir active 772966856 53281488 680347384 6.89%
Set storage value in STORAGE variable.
STORAGE=local
Next we import the image into VM’s disk.
# qm importdisk $VM_ID $IMAGE $STORAGE
...
transferred 3.0 GiB of 5.0 GiB (59.75%)
transferred 3.1 GiB of 5.0 GiB (61.41%)
transferred 3.2 GiB of 5.0 GiB (63.07%)
transferred 3.2 GiB of 5.0 GiB (64.73%)
transferred 3.3 GiB of 5.0 GiB (66.39%)
transferred 3.4 GiB of 5.0 GiB (68.05%)
transferred 3.5 GiB of 5.0 GiB (69.71%)
transferred 3.6 GiB of 5.0 GiB (71.37%)
transferred 3.7 GiB of 5.0 GiB (73.03%)
transferred 3.7 GiB of 5.0 GiB (74.69%)
transferred 3.8 GiB of 5.0 GiB (76.35%)
transferred 3.9 GiB of 5.0 GiB (78.01%)
transferred 4.0 GiB of 5.0 GiB (79.67%)
transferred 4.1 GiB of 5.0 GiB (81.33%)
transferred 4.1 GiB of 5.0 GiB (82.99%)
transferred 4.2 GiB of 5.0 GiB (84.65%)
transferred 4.3 GiB of 5.0 GiB (86.31%)
transferred 4.4 GiB of 5.0 GiB (87.97%)
transferred 4.5 GiB of 5.0 GiB (89.63%)
transferred 4.6 GiB of 5.0 GiB (91.29%)
transferred 4.6 GiB of 5.0 GiB (92.95%)
transferred 4.7 GiB of 5.0 GiB (94.61%)
transferred 4.8 GiB of 5.0 GiB (96.27%)
transferred 4.9 GiB of 5.0 GiB (97.93%)
transferred 5.0 GiB of 5.0 GiB (99.59%)
transferred 5.0 GiB of 5.0 GiB (100.00%)
transferred 5.0 GiB of 5.0 GiB (100.00%)
Successfully imported disk as 'unused0:local:102/vm-102-disk-0.raw'
After the importation the disk is not attached to the Virtual machine. Run the following commands to attach it.
# qm set $VM_ID --scsihw virtio-scsi-pci --virtio0 $STORAGE:$VM_ID/vm-$VM_ID-disk-0.raw
update VM 102: -scsihw virtio-scsi-pci -virtio0 local:102/vm-102-disk-0.raw
Set serial console and Boot order priority.
qm set $VM_ID --serial0 socket --vga serial0
qm set $VM_ID --boot c --bootdisk virtio0
Configure the instance to start on system boot.
qm set $VM_ID --onboot 1
3. Access OpenWrt Virtual Machine console
Click the instance name in Proxmox and start the Virtual Machine from console.

Once started it will drop into the shell.

Set new root password using passwd
command.
passwd
As shown in the screenshot.

To list current network information run:
uci show network
To set static IP information in the Virtual Machine edit the network configurations file.
# vim /etc/config/dhcp
You can edit the file and set Static IP address, netmask, and gateway.

Restart Networking service for the changes to take effect.
service network restart
Or with the script execution directly.
/etc/init.d/network restart
With the instance connected to the internet you can update system package index.
opkg update
To install a package use;
opkg install <package-name>
4. Access OpenWrt Web interface
Launch your web browser and input OpenWrt IP address. Login with username root and password set earlier on.

You will get access to OpenWrt web management dashboard from where you can perform many configurations.

Conclusion
OpenWrt is a highly extensible and flexible solution for running in embedded devices and as a router. It is a popular solution among network and systems enthusiasts who desire for a full control over their network hardware and design. In our future articles we’ll have deeper guides on the usage of OpenWrt. Stay connected and take care!.