pymumu / smartdns

A local DNS server to obtain the fastest website IP for the best Internet experience, support DoT, DoH. 一个本地DNS服务器,获取最快的网站IP,获得最佳上网体验,支持DoH,DoT。
https://pymumu.github.io/smartdns/
GNU General Public License v3.0
8.41k stars 1.08k forks source link

请问“转换成smartdns格式”的自动脚本怎么写 #1184

Closed wzy105 closed 10 months ago

wzy105 commented 1 year ago

之前已经在网上找到脚本了,但是”这个脚本“只能把域名前后都有字的转换成smdns的格式。

          “这个脚本”如下:把 server=/domain/114.114.114.114 转成 nameserver /domain/china

sed -i "s/^server=\/(.)\/[^\/]$/nameserver \/\1\/china/g;/^nameserver/!d" /tmp/smartdns/china.conf 2>/dev/null


如果是把 domain 转换成 nameserver /domain/group ,应该怎么写这串代码呢 !?

PikuZheng commented 1 year ago

建议用Emeditor,可以纵向选择编辑文本 image 按住alt然后 框选出前半部分,之后直接键入 nameserver 即可 image

也可用查找替换功能,Emeditor支持正则表达式查找替换 image 查找替换输入框后面有个 > 按钮,可以给出一些正则表达式规则提示 image

图省事也可以用现成的单一域名文本,然后在domain-set中引用

hpcex commented 1 year ago

!/bin/bash

wget -qO- https://cdn.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/accelerated-domains.china.conf | \ sed "s|^server=(.)/[^/]$|nameserver \1/inside|" > /etc/smartdns/china_domain.conf

wget -qO- https://cdn.jsdelivr.net/gh/felixonmars/dnsmasq-china-list/bogus-nxdomain.china.conf | \ sed "s|=| |" > /etc/smartdns/china_bogus.conf

wget -qO- https://cdn.jsdelivr.net/gh/hectorm/hmirror/data/adguard-simplified/list.txt | \ sed "/./{s/^/address \//;s/$/\/#/}" > /etc/smartdns/adguard.conf

systemctl restart smartdns

liangshixing commented 1 year ago

单独搞到一个文件里,用domain-set来导入:

domain-set -name greatlist -file /etc/smartdns/great.list
nameserver /domain-set:greatlist/greatgroup
wzy105 commented 1 year ago

单独搞到一个文件里,用domain-set来导入:

domain-set -name greatlist -file /etc/smartdns/great.list
nameserver /domain-set:greatlist/greatgroup

👍👍👍,感谢各位师傅们

wzy105 commented 1 year ago

单独搞到一个文件里,用domain-set来导入:

domain-set -name greatlist -file /etc/smartdns/great.list
nameserver /domain-set:greatlist/greatgroup

这是放在smartdns 自定义设置里面吗?

pymumu commented 1 year ago

https://github.com/pymumu/smartdns/tree/luci-dns-forwarding 分支提供了界面配置分流和自动下载,各位有空可以验证下看看。