Linux 系统 mihomo 安装教程 - axcsz/Collect GitHub Wiki
-
PS:适用于 Alpine & Debian & Ubuntu 系统;
-
PS:推荐SSH工具【点击进入下载 MobaXterm】、【点击进入下载 FinalShell】;
-
PS:升级更新更换好【点击此处查看 LXC 源】;
-
PS:如果使用第三方工具需要先开启允许登录。【点击此处查看如何开启】。
-
PS:需要开启路由转发功能和开启 TUN
- PS:在 PVE 里面 Shell 操作
echo -e "lxc.cgroup2.devices.allow: c 10:200 rwm\nlxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file" >>/etc/pve/lxc/LXCID.conf
- PS:在创建的 mihomo 的 LXC 容器操作
- PS:这一步会重启系统
echo -e "net.ipv4.ip_forward = 1\nnet.ipv6.conf.all.forwarding = 1" >>/etc/sysctl.conf && reboot
apt update && apt dist-upgrade -y
apt install -y curl git wget nano
PS: 首先查看 最新版 的版本号,下面命令里面的 974332c 版本号,需要修改成最新的版本号!!!
wget https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/mihomo-linux-amd64-compatible-alpha-974332c.gz
wget https://mirror.ghproxy.com/https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/mihomo-linux-amd64-compatible-alpha-974332c.gz
gzip -d mihomo-linux-amd64-compatible-alpha-974332c.gz
chmod 777 mihomo-linux-amd64-compatible-alpha-974332c
mv mihomo-linux-amd64-compatible-alpha-974332c /usr/local/bin/mihomo
mkdir /etc/mihomo
- ps:使用官方推荐配置或者自己按照官方例子修改,也可以使用我提供的 config 文件
nano /etc/mihomo/config.yaml
git clone https://github.com/metacubex/metacubexd.git -b gh-pages /etc/mihomo/ui
git clone https://mirror.ghproxy.com/https://github.com/metacubex/metacubexd.git -b gh-pages /etc/mihomo/ui
git -C /etc/mihomo/ui pull -r
nano /etc/systemd/system/mihomo.service
- PS:先在 官网 看看有没有更新
[Unit]
Description=mihomo Daemon, Another Clash Kernel.
After=network.target NetworkManager.service systemd-networkd.service iwd.service
[Service]
Type=simple
LimitNPROC=500
LimitNOFILE=1000000
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
Restart=always
ExecStartPre=/usr/bin/sleep 1s
ExecStart=/usr/local/bin/mihomo -d /etc/mihomo
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable mihomo
systemctl start mihomo
systemctl status mihomo
journalctl -u mihomo -o cat -e
systemctl reload mihomo
- PS:修改中
- PS:此操作是用 SSH 工具连接 PVE
nano /etc/pve/lxc/LXCID.conf
lxc.net.0.type: phys
lxc.net.0.link: enp4s0
lxc.net.0.flags: up
lxc.net.0.name: eth0
- PS:此操作是用SSH工具连接PVE
lxc-attach LXCID
nano /etc/systemd/network/eth0.network
- PS:{Address是lan口ip地址,Gateway是网关地址)
[Match]
Name = eth0
[Network]
Description = Interface eth0 autoconfigured by PVE
Address = 192.168.1.2/24
Gateway = 192.168.1.1
DHCP = no
IPv6AcceptRA = false
cat << EOF > /etc/systemd/system/mihomo.service
[Unit]
Description=mihomo Daemon, Another Clash Kernel.
After=network.target NetworkManager.service systemd-networkd.service iwd.service
[Service]
Type=simple
LimitNPROC=500
LimitNOFILE=1000000
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SYS_TIME CAP_SYS_PTRACE CAP_DAC_READ_SEARCH CAP_DAC_OVERRIDE
Restart=always
ExecStartPre=/usr/bin/sleep 1s
ExecStart=/usr/local/bin/mihomo -d /etc/mihomo
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
EOF
nano /etc/pve/lxc/LXCID.conf
lxc.cgroup2.devices.allow: c 10:200 rwm
lxc.mount.entry: /dev/net/tun dev/net/tun none bind,create=file
nano /etc/sysctl.conf
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
reboot