旁路由搭建参考
Debian 做旁路由,只需要搭建3个核心服务,极简、稳定、无冗余
我给你整理最精简、最实用、家用100%够用的旁路由搭建清单,不用装乱七八糟的东西,一步到位。
一、旁路由必须装的 3 个核心服务
1. dhcpcd / network-manager(固定IP用)
旁路由必须静态IP,不能自动获取。
Debian 默认一般自带,不用额外装。
2. iptables (NAT 转发,最关键)
负责把流量从局域网 → 互联网转发
apt install iptables iptables-persistent -y3. dnsmasq (DNS + 可选DHCP)
旁路由最常用的 DNS 解析、广告过滤、加速服务
apt install dnsmasq -y二、如果你要科学上网(可选)
再加一个:
4. clash / sing-box (二选一)
# 常用方案
apt install curl wget unzip
# 然后安装 sing-box 或 clash三、极简搭建命令(直接复制运行)
1. 安装依赖
apt update && apt upgrade -y
apt install iptables iptables-persistent dnsmasq -y2. 开启内核转发(必须)
echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf
sysctl -p3. 配置 NAT 转发(让设备能上网)
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables-save > /etc/iptables/rules.v44. 配置 DNS(用国内高速DNS)
编辑 /etc/dnsmasq.conf
server=223.5.5.5
server=119.29.29.29
cache-size=10000重启:
systemctl restart dnsmasq四、最终你的旁路由结构(最稳)
主路由(DHCP关闭/开启都行)
↓
Debian 旁路由
├─ iptables 转发(上网)
├─ dnsmasq DNS(加速+去广告)
└─ sing-box/clash(科学上网,可选)五、你只需要记住
Debian 旁路由 = 内核转发 + iptables + dnsmasq
这三个就是最小稳定系统,比 OpenWrt 还轻、还稳、还不容易崩。
评论已关闭