Post

在 Debian 上 安装 honk 透明代理

honk 内核 + doona 面板,透明代理从未如此简单

在 Debian 上 安装 honk 透明代理

honk 是由 daeuniverse 团队使用 Rust 编写的实验性 Linux 透明代理引擎,它结合了 dae 的 eBPF 数据面 与 sing-box 风格的出站组和 API 设计。honk 作为 dae 的下一代透明代理,配置文件类似 dae,也是以 confid.dae 命名,dae 的配置稍作修改便可以用作 honk 配置。honk 使用内置的 doona 网页界面,启动 honk 服务后即可直接在浏览器中使用,无需额外配置。

从 Dae Universe 软件源安装 honk

  1. 添加软件源
    1
    2
    3
    
    sudo apt update
    sudo apt install curl
    sudo curl -fsSL -o /etc/apt/sources.list.d/daeuniverse.sources https://daeuniverse.pages.dev/daeuniverse.sources
    
  2. 导入 GPG 公钥
    1
    
    sudo curl -fsSL -o /usr/share/keyrings/daeuniverse-archive-goose.gpg https://daeuniverse.pages.dev/daeuniverse-archive-goose.gpg
    
  3. 安装 honk
    1
    2
    
    sudo apt update
    sudo apt install honk
    

配置 honk

编辑 honk 配置文件

1
vi /etc/honk/config.dae

复制粘贴以下内容

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# ==========================================
# honk configuration
# Converted from Tigress Linux dae example
# ==========================================

global {
    # Transparent proxy
    tproxy_port: 12345

    # Logging
    log_level: info
    log_file: 'honk.log'

    # Interface configuration
    wan_interface: auto

    # Uncomment and replace with your actual LAN interface
    # lan_interface: br-lan

    # Kernel configuration
    auto_config_kernel_parameter: true

    # Node connectivity checks
    tcp_check_url: 'https://www.gstatic.com/generate_204'
    tcp_check_http_method: HEAD
    udp_check_dns: 'dns.google:53,8.8.8.8,2001:4860:4860::8888'
    check_interval: 30s
    check_tolerance: 50ms

    # Connection settings
    auto_config_kernel_parameter: true
    dial_mode: domain
    bootstrap_resolver: '1.1.1.1:53'
    sniffing_timeout: 100ms

    # Data directory
    data_dir: '/var/lib/honk'
    store_subscribe: true
}

# ==========================================
# Subscription
# ==========================================

subscription {
    my_sub: 'https://suburl' {
        route: direct
        cache: true
        interval: 10080m
        ua: 'honk/1.0'
    }
}

# ==========================================
# Proxy nodes
# ==========================================

node {
    local_socks5: 'socks5://127.0.0.1:1080'

    my_vless: 'vless://auto%uuid@ip:port?encryption=none&security=tls&sni=example.com&fp=edge#Netherlands'

    my_vmess: 'vmess://[email protected]:443?encryption=auto&type=ws&security=tls&host=example.com&path=%2Fws#Germany'
}

# ==========================================
# Proxy groups
# ==========================================

group {
    proxy {
        policy: min_moving_avg
        filter: name('🇺🇸 美国 02')
    }

    social_proxy {
        policy: min_moving_avg
        filter: name(keyword: '德国 10')
    }
}

# ==========================================
# DNS configuration
# ==========================================

dns {
    upstream {
        default: 'tcp+udp://192.168.1.1:53' -> direct
        cnnicdns: 'tcp+udp://1.8.8.8:53' -> direct
        onedns: 'tcp+udp://52.80.66.66:53' -> direct
        googledns: 'https://dns.google/dns-query' -> proxy
        securedns: 'https://doh.360.cn/dns-query' -> direct
        cloudflare-dns: 'https://cloudflare-dns.com/dns-query' -> proxy
    }

    routing {
        request {
            qname(geosite:cn, geosite:alibaba, geosite:debian, geosite:category-ru) -> default
            
            qname(geosite:adobe, geosite:linkedin, geosite:meta, geosite:github, geosite:google, geosite:x) -> cloudflare-dns

            qname(geosite:adguard, geosite:amazon, geosite:apple, geosite:microsoft, geosite:mozilla) -> securedns

            qname(geosite:lark, geosite:category-games, geosite:category-dev) -> default

            qname(suffix:bjxuejing.cn, suffix:gh-proxy.org, suffix:meixi-mgo.com, suffix:xzmgo.com, suffix:tuyoo.com, suffix:wanyiwan.top) -> cnnicdns

            fallback: googledns
        }

        response {
            upstream(googledns) -> accept
            ip(geoip: private) && !qname(geosite: cn) -> googledns
            fallback: accept
        }
    }
    optimistic_cache: true
    optimistic_cache_ttl: 600
    max_cache_size: 10000
    fixed_domain_ttl {
        ddns.example.org: 10
        nocache.test: 0

    }
}

# ==========================================
# Traffic routing
# ==========================================

routing {
    # System processes bypass proxy and DNS interception
    pname(NetworkManager, systemd-resolved, dnsmasq, gnome-weather, sing-box) -> direct(must)

    # Multicast
    dip(224.0.0.0/3, 'ff00::/8') -> direct

    # Private IP
    dip(geoip:private) -> direct

    # Custom direct domains
    domain(suffix:cfysoft.cc, suffix:cndhl.com, suffix:huohua.icu, suffix:jisuimage.com, suffix:mytvapp.cc, suffix:scdn.co, suffix:xmfyy.com) -> direct

    domain(suffix:cdnbuild.net, suffix:cdngslb.com, suffix:icoa.cn, suffix:icoa.vip, suffix:tigress.cc) -> direct

    domain(suffix:bjxuejing.cn, suffix:edu.kg, suffix:hdcdn.store, suffix:ip.sb, suffix:open-meteo.com, suffix:wanyiwan.top) -> direct

    domain(suffix:beacondb.net, suffix:dmcdn.net, suffix:fuckcloudnative.io, suffix:localsend.org, suffix:oceansaver.in, suffix:rustdesk.com) -> direct

    domain(suffix:dynadot.com, suffix:frantech.ca, suffix:gh-proxy.org, suffix:gnome.org, suffix:gwdg.de, suffix:meixi-mgo.com, suffix:xzmgo.com) -> direct

    domain(suffix:accuweather.com, suffix:aviationweather.gov, suffix:met.no, suffix:openweathermap.org, suffix:qweather.com, suffix:weatherapi.com) -> direct

    # Custom proxy domains
    domain(suffix:analytics.google.com, suffix:ads.google.com, suffix:tpc.googlesyndication.com) -> proxy

    domain(suffix:addons.mozilla.org, suffix:onedrive.live.com, suffix:primevideo.com) -> proxy

    domain(suffix:flathub.org, suffix:ml0987.com, suffix:openwrt.org, suffix:steamcommunity.com) -> proxy

    # Advertisement blocking
    domain(geosite:category-ads) -> block

    # China IP direct
    dip(geoip:cn, geoip:private, 8.219.1.15, 47.245.124.74) -> direct

    # Telegram IPv4
    dip(91.108.4.0/22, 91.108.8.0/22, 91.108.12.0/22, 91.108.16.0/22, 91.108.20.0/22, 91.108.36.0/23, 91.108.38.0/23, 91.108.56.0/22) -> proxy

    dip(149.154.160.0/20, 149.154.164.0/22, 149.154.168.0/22, 149.154.172.0/22, 185.76.192.0/22) -> proxy

    # Telegram IPv6
    dip('2001:b28:f23c::/47', '2001:b28:f23f::/48', '2001:67c:4e8::/48') -> proxy
    
    # China and other direct domains
    domain(geosite:alibaba, geosite:cn, geosite:adobe, geosite:category-ru) -> direct

    # Global proxy domains
    domain(geosite:github, geosite:google, geosite:linkedin, geosite:meta, geosite:paypal, geosite:telegram, geosite:tiktok, geosite:x) -> proxy

    domain(geosite:amazon, geosite:apple, geosite:microsoft, geosite:mozilla) -> direct

    # Default outbound
    fallback: proxy
}

# ==========================================
# Native API and doona UI
# ==========================================

experimental {
    native_api {
        enabled: true

        # Localhost only
        listen: '127.0.0.1:9527'

        # Administrator password authentication
        password_auth: true

        # Allow authenticated configuration changes
        config_write: true

        # Embedded doona dashboard
        ui: 'embedded'

        # Runtime statistics
        record_flows: true
        record_traffic: true
        record_memory: true
        record_logs: true
        record_dns_log: true
    }
}

⚠️注意:把以下内容中的订阅链接 https://suburl 换成真实的订阅链接

1
2
3
4
5
6
7
8
subscription {
    my_sub: 'https://suburl' {
        route: direct
        cache: true
        interval: 10080m
        ua: 'honk/1.0'
    }
}

启动 honk 服务

常见 honk 服务管理命令

1
2
3
4
5
6
sudo systemctl start honk	启动服务
sudo systemctl stop honk	停止服务
sudo systemctl restart honk	重启服务(修改主程序或底层配置后常用)
sudo systemctl enable honk	开机自启动
sudo systemctl reload honk	重载配置(不中断连接的情况下平滑加载新配置)
systemctl status honk	查看状态(检查服务是否运行正常及最近几行报错)

查看日志命令

1
2
3
4
5
6
7
honk validate -c /etc/honk/config.dae   校验配置文件语法

journalctl -u honk.service -n 30 -f   实时滚动查看最新日志

journalctl -u honk.service -n 50 --no-pager   一次性查看最近 50 条日志

chown $USER:$USER config.dae   修改文件所有者

使用 doona 面板管理订阅和节点

启动 honk 服务后 systemctl start honk,浏览器打开 http://127.0.0.1:9527/ 即可访问 doona 面板

订阅管理

订阅默认一周更新一次,也可以手动更新;点击每条节点最右边三个点 ➡️ 添加到 proxy 分组即可选定节点。

doona 订阅管理

节点管理

点击 Routings ➡️ Policies,proxy 分组右边的 ✏ 图标,可以添加删除节点。

doona 节点管理

This post is licensed under CC BY 4.0 by the author.