Install OpenWRT in PVE

If you have an OpenWRT x86_64 image, you can install it in PVE very fast.

Sometimes you will have 3 types of OpenWRT x86_images.

(1) openwrt-x86-64-generic-squashfs-combined-efi.img

(2) openwrt-x86-64-generic-squashfs-combined.img

(3) openwrt-x86-64-generic-squashfs-rootfs.img

 

Image (1) has an extra EFI partition in the raw file. For setting VM BIOS, you should choose OVMF(EFI).

Image (2) has only MBR bootable sector in the raw file. For setting VM BIOS, you should choose Default(SeaBIOS).

Image (3) is the "/" raw file of the OpenWRT, it is not bootable! (Not very useful, but you can use this to recover your broken OpenWRT OS).

 

Upload these files to 

 

 

Let's create a PVE VM.

For example, it's like this chart.

In this scenario, the BIOS is set to "OVMF (UEFI)", so we need the image file: openwrt-x86-64-generic-squashfs-combined-efi.img

But after you created a the VM, you can delete the hard drive. Because later you need to recover the "img" file to a local-lvm disk.

 

Here's a very helpful tutorial about how to install OpenWRT in PVE. : https://blog.csdn.net/u012374381/article/details/130650909

In PVE terminal,

qm importdisk 103 /var/lib/vz/template/iso/YOUR_OPENWRT.img local-lvm

103 is your VM id.

---

Notice,

you would need to change the default IP of the LAN on OpenWRT. Also you would need to add several ethernet cards to OpenWRT VM. For me, I added 1 virtual ethernet card and passthroughed a physical i226-V 2.5Gbps ethernet cards to the OpenWRT VM. The physical RJ45 port can be connected to switch/router. (You use add a PCIE device, here it refers to a 2.5Gbps i226-V ethernet card). If you don't know which PCIE address is your ethernet card. Go to PVE console, try commands "lspci" to view PCIE devices.

 

Use this command to lookup your ethernet cards in OpenWRT VM.

ifconfig

You will see eth0 and eth1. 

eth0 is the virtual ethernet card.

eth1 is the physical ethernet card (passthrough).

And change the file /etc/config/network

Use eth1 as LAN. change it like this.

 

eth1 for LAN

eth0 for WAN (DHCP, it will automatically get an IP from the router which PVE connects with. E.g. PVE has IP 192.168.10.253, and the gateway of the upstream router which PVE connected to has IP 192.168.10.1. eth0 will get an IP like 192.168.10.108 (something like this)).

then reboot your openWRT VM.

Connect the eth1 (RJ45 cable) to your computer. You computer will get an IP such as 192.168.250.9 (something like this)

Go visit http://192.168.250.1 you will see your OpenWRT web admin page. (By default it's 192.168.1.1)

You can visit http://192.168.10.108 to view the OpenWRT web admin page as well.

 

posted @ 2023-05-18 00:13  spaceship9  阅读(262)  评论(0编辑  收藏  举报