惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
MyScale Blog
MyScale Blog
Recent Announcements
Recent Announcements
N
Netflix TechBlog - Medium
GbyAI
GbyAI
Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
阮一峰的网络日志
阮一峰的网络日志
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
V
Visual Studio Blog
Martin Fowler
Martin Fowler
腾讯CDC
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
J
Java Code Geeks
WordPress大学
WordPress大学
P
Proofpoint News Feed
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Y
Y Combinator Blog

方永、南天紫雲

linux透明代理 技术的边界 停机问题通俗说明 Rust与oracle、redis集群的纠结 学习能力的增长 微信调试的原语 mac外接移动硬盘安装ArchLinux linux的死机问题 linux下全键盘操作 漂亮又好用的bspwm linux本机透明代理 ssh、mosh、autossh linux不能待机又一例 从WordPress切换到Hugo 折腾电脑开机 linux系统QQ新思路 Arch Linux的字体渲染 svn管理之submin OpenWrt自动fucking墙記錄 二维码(qrcode)名片的一些事儿 用lua nginx module搭建一个二维码(qr code)生成器 CentOS 7 安裝註記 php程序連接MySQL时只能127.0.0.1而localhost無法連接的問題 ThinkPad之FAN_ERROR、hi fi聲卡 jetty多端口部署 OpenWrt簡單暴力限網 linux中cron之PATH变量 OpenWrt的WDS無線橋接模式 再敘OpenWrt下的rtl8187無線中繼 sed之模擬tail
Linux基于域名的策略路由
zola · 2025-12-01 · via 方永、南天紫雲

最近在某台服务器上配置了基于域名和nftables的策略路由,记录一下配置过程。

用到的工具是 phantun, wireguard, nftables, chinadns-ng

这是

的姊妹篇,随着工具和技术的迭代,这是目前最新的一篇。

chinadns-ng

首先配置dns 解析服务器,可直接修改 /etc/resolv.conf 添加 nameserver 127.0.0.1 并注释掉其它的 nameserver

chinadns-ng 的配置文件:

bind-addr 0.0.0.0
bind-port 53

china-dns udp://100.100.2.136,udp://100.100.2.138
trust-dns udp://10.0.0.1

gfwlist-file gfwlist.txt
default-tag chn

add-taggfw-ip inet@fw@gfwip

cache 4096
cache-stale 86400
cache-refresh 20

nftables

table inet fw {
  set gfwip {
    typeof ip daddr
    flags interval
    auto-merge

    elements = { 10.0.0.1/24 }
  }

  chain gfwip_mark {
    type route hook output priority filter; policy accept;
    ip daddr @gfwip counter mark set 0x15;
  }
}

wireguard

[Interface]
...
Table = 21
PostUp = ip rule add fwmark 0x15 table 21
PreDown = ip rule del fwmark 0x15 table 21