pve安装openwrt软路由

概览:

介绍

官网openwrt

The OpenWrt Project is a Linux operating system targeting embedded devices. Instead of trying to create a single, static firmware, OpenWrt provides a fully writable filesystem with package management. This frees you from the application selection and configuration provided by the vendor and allows you to customize the device through the use of packages to suit any application. For developers, OpenWrt is the framework to build an application without having to build a complete firmware around it; for users this means the ability for full customization, to use the device in ways never envisioned.

下载

下载网址:https://downloads.openwrt.org

https://downloads.openwrt.org/releases/22.03.3/targets/x86/generic/

注意⚠️ 之后操作都在pve的shell操作。

1
2
wget https://downloads.openwrt.org/releases/22.03.3/targets/x86/generic/openwrt-22.03.3-x86-generic-generic-squashfs-combined.img.gz
gzip -dk openwrt-22.03.3-x86-generic-generic-squashfs-combined.img.gz

安装

此操作可以参考该文章。建议在第16步(即启动之前扩容),扩容完成后再继续。

扩容

由于openwrt原始镜像空间很小,如火需要安装其他的软件,会使得空间比较紧张。所以可以提前进行扩容。

1
qemu-img resize openwrt-22.03.3-x86-generic-generic-squashfs-combined.img 2048M

然后可以参考这篇文章进行操作。

配置

修改ip

由于我是把openwrt没有作为主路由,所以需要手动设置LAN的静态IP。
注意⚠️ 若不需要,可以跳过该小节。

输入默认用户名密码,一般用户为root,密码password
在命令行输入:后面的ip根据=实际情况修改

1
2
uci set network.lan.ipaddr='192.168.123.1'
uci commit network

修改密码

1
passwd

镜像源

我是用的源: https://mirrors.ustc.edu.cn/help/openwrt.html

1
sed -i 's/downloads.openwrt.org/mirrors.ustc.edu.cn\/openwrt/g' /etc/opkg/distfeeds.conf

问题

无法上网

方法:手动设置openwrt的DNS。

我设置的是114.114.114.114

设置interface LAN的网关地址为上游路由的地址。