在openwrt uci命令行中更改DNS设置

时间:2019-05-26 01:02:52

标签: dns router openwrt uci

如何在openwrt路由器中使用命令行更改DNS设置? 我在这里here

看到这些文件

/etc/config/ddns /etc/config/ipset-dns 但我看到安装了dnsmasq

但不确定哪个可以更改路由器上的DNS服务器

我的最终目标是添加一个cron作业,每天添加几个小时的自定义DNS,然后还原为原始DNS

编辑:我找到了以下命令,有人可以解释吗?

uci set network.wan.dns='<list of space-separated DNS server IPs>'

uci commit network

reload_config

uci set network.wan.peerdns='0'

uci del network.wan.dns

uci add_list network.wan.dns='9.9.9.9'

uci add_list network.wan.dns='149.112.112.112'

uci commit

1 个答案:

答案 0 :(得分:1)

您可以执行以下操作将DNS请求转发到特定服务器:

uci add_list dhcp.@dnsmasq[0].server="SERVER_ADDRESS"

uci commit dhcp

service dnsmasq restart/etc/init.d/dnsmasq restart

您可以在此处了解更多信息:https://openwrt.org/docs/guide-user/base-system/dhcp_configuration(向下滚动或找到“ DNS转发”)