dnstrack: golang 实现的基于 bpf 特性的 dns 查询追踪工具 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
爱意满满的作品展示区。
chenjiandongx
V2EX    分享创造

dnstrack: golang 实现的基于 bpf 特性的 dns 查询追踪工具

  •  1
     
      chenjiandongx 2024-05-29 10:03:09 +08:00 1701 次点击
    这是一个创建于 550 天前的主题,其中的信息可能已经有所发展或是发生改变。

    dnstrack 是一款使用 golang+bpf 实现的 dns 查询最追踪工具,可以查看机器上的 dns 查询事件。

    项目地址: https://github.com/chenjiandongx/dnstrack

    用法

    > dnstrack -h # A dns-query tracking tool written in go Usage: dnstrack [flags] Examples: # list all the net-devices $ dnstrack -l # filters google dns server packet attached in lo0 dev and output with json format $ dnstrack -s 8.8.8.8 -o j -d '^lo0$' Flags: -a, --all-devices listen all devices if present (default true) -d, --devices string devices regex pattern filter -h, --help help for dnstrack -l, --list list all devices name -o, --output-format string output format [json(j)|yaml(y)|question(q)|verbose(v)] (default "verbose") -s, --server string dns server filter -t, --type string dns query type filter [A/AAAA/CNAME/...] -v, --version version for dnstrack 

    示例

    --output-format verbose

    > dnstrack -d '^lo$|^ens' -------------------- ; <ens160>@172.16.22.2:53, ID: 49390, OpCpde: Query, Status: Success ;; When: 2024-05-29T00:42:52+08:00 ;; Query Time: 57.667s ;; Msg Size: 292B ;; Question Section: google.com. A ;; Answer Section: google.com. 5 A INET 93.46.8.90 ;; Authority Section: google.com. NS INET ns2.google.com. google.com. NS INET ns1.google.com. google.com. NS INET ns4.google.com. google.com. NS INET ns3.google.com. ;; Additional Section: ns2.google.com. AAAA INET 2001:4860:4802:34::a ns4.google.com. AAAA INET 2001:4860:4802:38::a ns3.google.com. AAAA INET 2001:4860:4802:36::a ns1.google.com. AAAA INET 2001:4860:4802:32::a ns2.google.com. A INET 216.239.34.10 ns4.google.com. A INET 216.239.38.10 ns3.google.com. A INET 216.239.36.10 ns1.google.com. A INET 216.239.32.10 

    --output-format question

    > dnstrack -d '^lo$|^ens' -oq 2024-05-29T00:44:02+08:00 <ens160>@172.16.22.2:53 A 44.959s facebook.com. 2024-05-29T00:44:02+08:00 <lo>@127.0.0.53:53 A 16.416s facebook.com. 2024-05-29T00:44:02+08:00 <lo>@127.0.0.53:53 A 33.125s facebook.com. 2024-05-29T00:44:04+08:00 <lo>@127.0.0.53:53 A 35.125s twitter.com. 2024-05-29T00:44:04+08:00 <lo>@127.0.0.53:53 A 59.166s twitter.com. 2024-05-29T00:44:04+08:00 <ens160>@172.16.22.2:53 A 72.373058ms twitter.com. 2024-05-29T00:44:08+08:00 <ens160>@172.16.22.2:53 A 72.008765ms google.com. 2024-05-29T00:44:08+08:00 <lo>@127.0.0.53:53 A 72.072515ms google.com. 2024-05-29T00:44:08+08:00 <lo>@127.0.0.53:53 A 72.309974ms google.com. 2024-05-29T00:44:13+08:00 <ens160>@172.16.22.2:53 A 80.584s x.com. 2024-05-29T00:44:13+08:00 <lo>@127.0.0.53:53 A 39.667s x.com. 2024-05-29T00:44:13+08:00 <lo>@127.0.0.53:53 A 72.417s x.com. 
    5 条回复    2024-10-04 14:16:17 +08:00
    wentx
        1
    wentx  
       2024-05-29 10:18:53 +08:00
    这个应用场景是啥?
    chenjiandongx
        2
    chenjiandongx  
    OP
       2024-05-29 10:23:27 +08:00
    监听网卡监测机器上正在执行哪些 dns 查询
    povsister
        3
    povsister  
       2024-05-29 10:36:32 +08:00
    是仅支持检测 UDP DNS query ?
    chenjiandongx
        4
    chenjiandongx  
    OP
       2024-05-29 10:47:31 +08:00
    是的,基于 tcp 的暂时还不支持。
    sbilly
        5
    sbilly  
       2024-10-04 14:16:17 +08:00
    dig www.sina.com.cn +trace
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2489 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 40ms UTC 04:40 PVG 12:40 LAX 20:40 JFK 23:40
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86