Unraid虚拟OpenWrt并安装OpenClash

Unraid虚拟OpenWrt并安装OpenClash

Yinski 6,001 2022-06-02

前言

本文是使用Unraid虚拟化安装Openwrt软路由系统并安装openClash服务科学上网的操作记录。
之所以要绕这么一个弯来使用小猫咪主要是为了解决:

  • 代理Unraid自身的流量
  • 梅林固件的merlinClash稳定性不佳,给家人联网造成困扰
  • 避免流量走入家人的设备

本文所需的工具/安装包

OpenWrt 21.02.3稳定版
这里建议最好不要选择魔改openwrt 例如lede等,因为kernel版本如果和依赖包不匹配会非常麻烦,建议使用openwrt原版镜像。
OpenClash 0.45.12-beta
Clash核心-AMD64

Unraid虚拟Openwrt软路由

将Openwrt镜像解压缩得到.img文件放到unraid目录isos或domains下。按照如图所示选择Seabios以及手动指定磁盘-选择isos目录下的.img镜像,启动虚拟机。
unraid-VM
右键VNC连接虚拟机后输入vi /etc/config/network, 按i修改openwrt的ip地址为你路由器网域下的地址,这里我的路由器网关为192.168.50.1,因此我将openwrt的地址设置为192.168.50.228,按esc结束编辑并输入:wq退出编辑。
vnc
接着输入passwd root设定openwrt的root密码,这也是之后webui的登陆密码。

在地址栏输入设定地址跳转openwrt管理页面,选择网络-接口 编辑br-lan的Lan口的ipv4网关,并且关闭DHCP服务。保存并应用。
lan-ip
lan-dhcp

安装依赖包及openClash服务

接下来则是解决openClash所需的依赖包。由于downloads.openwrt.org访问较慢,我的解决方法是现在电脑上开一个小猫咪给openwrt进行代理加速。
打开powershall或者别的什么ssh客户端

ssh root@192.168.50.228 #填写你的openwrt地址并输入root密码
export http_proxy=http://192.168.50.28:7890 #填写你开启clash lan的电脑或其他设备
export https_proxy=https://192.168.50.28:7890

安装依赖包有两种方法
通过ssh
依次输入以下指令,安装依赖包

opkg update
opkg install coreutils-nohup
opkg install bash
opkg install iptables
opkg install dnsmasq-full
opkg install curl
opkg install ca-certificates
opkg install ipset
opkg install ip-full
opkg install iptables-mod-tproxy
opkg install iptables-mod-extra
opkg install libcap
opkg install libcap-bin
opkg install ruby
opkg install ruby-yaml
opkg install kmod-tun

通过webui
打开-系统-Software,点击update-list更新列表,然后依次输入包名进行安装。
software


# NAS # Unraid # 虚拟机