前情须知:带有“#”为部分不需要操作,推荐配合视频操作,大神请自便 前期准备: 打开Linux系统ssh远程访问 编辑指定文件 nano /etc/ssh/sshd_config 文件最后填写下面两行 PermitRootLogin yes 重启ssh服务 systemctl restart sshd 安装所需工具 apt update apt install iptables -y apt install zip -y 启用ipv4转发以及禁用ipv6 编辑以下文件 nano /etc/sysctl.conf 文件最后填写下面两行 net.ipv4.ip_forward=1 net.ipv6.conf.all.disable_ipv6 = 1 检查 sysctl -p 清楚DNS缓存(debian12不需要) systemctl restart systemd-resolved.service DNS部分: AdGuardHmoe github #https://github.com/AdguardTeam/AdGuardHome 下载AdGuardHome到本机 curl -s -S -L https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v wget --no-verbose -O - https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v fetch -o - https://raw.githubusercontent.com/AdguardTeam/AdGuardHome/master/scripts/install.sh | sh -s -- -v 启动 systemctl start AdGuardHome 状态 systemctl status AdGuardHome 开机自启 systemctl enable AdGuardHome #重启 systemctl restart AdGuardHome #停止 systemctl stop AdGuardHome DoT/DoH 加密 DNS https://dns.icoa.cn/dot-doh/ DNS过滤规则(注意改托管配置文件的服务器到晚上有可能维护,如果始终无法下载,白天尝试) https://github.com/sbwml/halflife-list https://cdn.jsdelivr.net/gh/sbwml/halflife-list@master/ad-pc.txt mosdns github #https://github.com/IrineSistiana/mosdns/releases 下载mosdns到本机 wget https://github.com/IrineSistiana/mosdns/releases/download/v5.1.3/mosdns-linux-amd64.zip 创建所需目录及文件 mkdir /etc/mosdns mkdir /var/mosdns touch /var/disable-ads.txt 检查53端口是否占用并且移除占用 检查 lsof -i :53 停止占用53端口的服务 systemctl stop systemd-resolved.service 移除开机自启 systemctl disable systemd-resolved.service 重新检查 lsof -i :53 解压 unzip -o -d mosdns mosdns-xxx-xxx.zip 上传所需文件 移动所需文件到指定目录 mv /root/mosdns/mosdns /usr/bin/ chmod +x /usr/bin/mosdns mv etc/mosdns/* /etc/mosdns/ mv var/mosdns/* /var/mosdns/ 修改配置文件服务端口号和 安装服务 #mosdns service install -d 工作目录绝对路径 -c 配置文件路径 mosdns service install -d /usr/bin -c /etc/mosdns/config.yaml 安装成功后手动运行服务。(服务仅设定为随系统自启,安装成功后并不会马上自动运行) 启动mosdns mosdns service start 检查状态 systemctl status mosdns.service #卸载 mosdns service stop mosdns service uninstall 重启 reboot 重新检查一下AdGuardHome和MosDNS systemctl status AdGuardHome.service systemctl status mosdns.service lsof -i :53 把主路由DNS指向虚拟机,测试DNS是否正常,保证正常后继续下一步 Clash部分 确保在root目录下 cd Country.mmdb github #是一个IP 地理数据库 #https://github.com/Dreamacro/maxmind-geoip 下载Country.mmdb文件到本机 wget https://github.com/Dreamacro/maxmind-geoip/releases/download/20230612/Country.mmdb yacd面板 #https://github.com/haishanh/yacd 下载yacd面板到本机 wget https://github.com/haishanh/yacd/releases/download/v0.3.8/yacd.tar.xz 解压并移动到指定目录 tar -xf yacd.tar.xz mkdir /etc/clash mv public /etc/clash/yacd Clash github #https://github.com/Dreamacro/clash/releases #v3的解释 GOAMD64=v1(默认):基线。专门生成所有 64 位 x86 处理器都可以执行的指令。 GOAMD64=v2:所有 v1 指令,加上 CMPXCHG16B、LAHF、SAHF、POPCNT、SSE3、SSE4.1、SSE4.2、SSSE3。 GOAMD64=v3:所有 v2 指令,加上 AVX、AVX2、BMI1、BMI2、F16C、FMA、LZCNT、MOVBE、OSXSAVE。 GOAMD64=v4:所有 v3 指令,加上 AVX512F、AVX512BW、AVX512CD、AVX512DQ、AVX512VL。 上传配置文件 下载clash到本机 wget https://github.com/Dreamacro/clash/releases/download/v1.17.0/clash-linux-amd64-v1.17.0.gz 解压文件,注意替换文件名,可敲Tab补全文件名 gzip -d clash-linux-xxxx-xxxx.gz 上传配置文件 移动文件到指定目录 mv clash-linux-xxxx-xxx /usr/local/bin/clash mv config.yaml /etc/clash/ mv Country.mmdb /etc/clash/ 赋可执行权限 chmod +x /usr/local/bin/clash 设置clash开机自启 nano /etc/systemd/system/clash.service 或touch /etc/systemd/system/clash.service 复制下列文件到上面新建文件 #开始 [Unit] Description=Clash daemon, A rule-based proxy in Go. After=network-online.target [Service] Type=simple Restart=always ExecStart=/usr/local/bin/clash -d /etc/clash [Install] WantedBy=multi-user.target #结束 重新加载 systemd: systemctl daemon-reload 启动Clash systemctl start clash 查看启动状态 systemctl status clash 开机自动启动Clash: systemctl enable clash #停止 systemctl stop clash 访问yacd面板 http://xxx.xxx.xxx.xxx/ui/ 登录后打开‘切换代理时自动断开旧连接’ 设置防火墙 iptables -t nat -A PREROUTING -p tcp --dport 22 -j ACCEPT iptables -t nat -A PREROUTING -p tcp --dport 53 -j ACCEPT iptables -t nat -A PREROUTING -p udp --dport 53 -j ACCEPT iptables -t nat -A PREROUTING -d 192.168.88.117 -p tcp --dport 80 -j ACCEPT iptables -t nat -A PREROUTING -p tcp --dport 3000 -j ACCEPT iptables -t nat -A PREROUTING -p tcp -j REDIRECT --to-ports 7892 iptables -t nat -A PREROUTING -p udp -j REDIRECT --to-ports 7892 保存防火墙 apt update apt install iptables-persistent -y netfilter-persistent save 常用端口 22,587,465,995,993,143,80,443,853,9418 其他: #ssr-plus源码: https://github.com/fw876/helloworld/blob/master/luci-app-ssr-plus/root/etc/init.d/shadowsocksr