OpenWrt | Pure Edition Installation for PVE Environments

OpenWrt 一款嵌入式开源软路由系统,适用各种硬件,各种架构,插件生态非常丰富,互联网上众多第三方编译版本,集成了大量第三方插件,开箱即用,但良莠不齐

如果安装一个纯净版系统,再根据自己所需适量安装插件,或许不错。这里以在PVE环境下,安装OpenWrt VM 为例

步骤

  1. 创建VM
  1. System 页面保持默认 ,然后Next到Disks页面,设置大小为0.001,最后会移除这个disk
  1. Next到CPU页面,类型选择host模式,AES硬解
  1. 其他按需,例如memory 128M差不多够了,网卡目前保持一个。

VM创建后,导航到Hardware选项,移除刚刚创建的Disk

  1. 如果有需要,添加额外网卡,我这里以一块网卡为例,OpenWrt旁路由/代理路由 模式组网
  1. 打开PVE shell,下载openwrt 硬盘文件,下面脚本会自动从官网下载最新稳定版的openwrt磁盘文件
# lookup the latest stable version number
regex='<strong>Current Stable Release - OpenWrt ([^/]*)<\/strong>' && response=$(curl -s https://openwrt.org) && [[ $response =~ $regex ]] && stableVersion="${BASH_REMATCH[1]}"
# download openwrt image
wget -O openwrt.img.gz https://downloads.openwrt.org/releases/$stableVersion/targets/x86/64/openwrt-$stableVersion-x86-64-generic-ext4-combined.img.gz
# extract the openwrt img
gunzip ./openwrt.img.gz
# rename the extracted img
mv ./openwrt*.img ./openwrt.raw
# increase the raw disk to 512 MB
qemu-img resize -f raw ./openwrt.raw 512M
# import the disk to the openwrt vm
# update the vm id and storage device as needed
# usage: qm importdisk
qm importdisk 104 openwrt.raw local-lvm
  1. 导航到vm的Hardware页面,添加刚刚的硬盘
  1. 设置启动项及顺序,从新硬盘启动,
  1. 禁用tablet for pointer
  1. 一切就绪之后,start VM,进入系统后,更改root密码和IP信息
更改root密码
passwd 
  1. 重启网络服务: service network restart

然后通过web登录,一个纯净的OpenWrt 就ok了

  1. 其他可选命令:
# set the lan ip address, use something in the same subnet as your LAN
uci set network.lan.ipaddr='10.10.27.151'
# restart network services
service network restart
# update openwrt packages
opkg update
# install the luci web ui
opkg install luci
  1. 开启sftp,便于上传文件(有网前提)
root@OpenWrt:~# opkg update

root@OpenWrt:~# opkg install vsftpd openssh-sftp-server

root@OpenWrt:~# /etc/init.d/vsftpd enable

root@OpenWrt:~# /etc/init.d/vsftpd start

以上。

参考资料

https://i12bretro.github.io/tutorials/0405.html

https://openwrt.org/

Related Posts

One thought on “OpenWrt | Pure Edition Installation for PVE Environments

Leave a Reply

Your email address will not be published.