在LEDE/OpenWrt中设置拨号连接的DNS,有以下几种方法:
方法一:通过LuCI Web界面设置
网络 → 接口 → WAN(编辑) ↓ 高级设置 → 使用自定义的DNS服务器
填入DNS服务器地址,如:
114.114.114.114(电信)
223.5.5.5(阿里)
8.8.8.8(Google)
网络 → DHCP/DNS → 常规设置 ↓ DNS转发:填写DNS服务器
方法二:通过配置文件修改
vi /etc/config/network
在WAN接口配置中添加DNS:
config interface 'wan'
option proto 'pppoe' # 或dhcp/static
option username 'your_username'
option password 'your_password'
list dns '223.5.5.5'
list dns '223.6.6.6'vi /etc/config/dhcp
修改dnsmasq配置:
config dnsmasq
option domainneeded '1'
option boguspriv '1'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option local '/lan/'
option domain 'lan'
option expandhosts '1'
option nonegcache '0'
option cachesize '1000'
option authoritative '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.auto'
list server '223.5.5.5'
list server '8.8.8.8'方法三:通过命令行设置
修改resolv.conf echo "nameserver 223.5.5.5" > /tmp/resolv.conf.auto echo "nameserver 8.8.8.8" >> /tmp/resolv.conf.auto 重启dnsmasq /etc/init.d/dnsmasq restart
使用uci命令 uci set network.wan.dns='223.5.5.5' uci add_list network.wan.dns='8.8.8.8' uci commit network /etc/init.d/network restart
常见DNS服务器推荐
电信:114.114.114.114 阿里:223.5.5.5 / 223.6.6.6 百度:180.76.76.76 腾讯:119.29.29.29
Google:8.8.8.8 / 8.8.4.4 Cloudflare:1.1.1.1 / 1.0.0.1
特殊设置技巧
安装相关软件包 opkg update opkg install dnscrypt-proxy2 配置DNS加密
国内域名 → 国内DNS 国外域名 → 国外DNS(通过代理)
查看当前DNS cat /tmp/resolv.conf.auto 测试DNS解析 nslookup www.baidu.com
注意事项
1、PPPoE拨号:有些ISP会在拨号时强制分配DNS,需要在路由器中设置覆盖
2、防火墙设置:确保DNS端口53未被阻断
3、缓存清理:修改DNS后清理本地DNS缓存
4、多WAN环境:需要为每个WAN接口单独设置DNS
修改完成后,建议重启网络服务:
/etc/init.d/network restart /etc/init.d/dnsmasq restart
通过以上任一方法,都可以成功设置LEDE的拨号DNS。
文章摘自:https://idc.huochengrm.cn/dns/24478.html
评论
戢洁玉
回复在LEDE中设置拨号DNS,需进入网络配置界面,选择WAN接口,找到并编辑DNS服务器地址。