OpenWrt之DNS设置
OpenWrt之DNS设置
0.前言
本文不涉及smartdns、adguardhome、dns防污染等内容,只介绍DNS的设置
1.WAN口
保存&应用后 客户机发出dns解析请求后路由器用上面的dns回应
2.Lan口
进入openwrt的luci页面。在 网络>网卡>LAN 选择编辑
保存&应用后,路由器自身的dns解析请求 会使用 上面设置的DNS 来回应
3.LAN口DHCP选项
进入openwrt的luci页面。在 网络>网卡>LAN 选择编辑
在 DHCP选项下 填入
6,223.5.5.5,119.29.29.29
效果如下:
该设置会修改连接到路由器LAN的DNS(类似于自定义电脑的DNS)
4.DHCP/DNS
5.总结
电脑DNS(LAN) > DHCP的DNS > WAN口DNS
1.最常用的DNS设置方式。可以由DHCP请求获得,或自行设置。在静态IP的情况下,必须设置,否则无法查询外面的主机
2.如果路由器用于桥接方式,并且使用静态IP时,无法用DHCP请求的方式得到DNS,这是该选项的主要用途。其他场合下,则会忽略由DHCP服务器的DNS设置,改用这个设置。
3.如果该机器是子网的DHCP服务器,用于设置DHCP客户端的DNS。如果留空,默认则用自身的IP。通常客户端看到的DNS是这个(手机,电脑等)
4.如果自己是子网的DNS服务器,用于设置转发服务器。如果不设置,则用上游DNS(由1或2)服务器
当第2、3、4项不设置时,默认使用1的DNS解析
参考(Thanks)
https://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.xhtml#options
https://blog.csdn.net/weixin_41632560/article/details/89448612
https://www.right.com.cn/forum/thread-4059633-1-1.html
附录.DHCP OPTION
以下是部分DHCP OPTION参照表
DHCP OPTION | Meaing |
---|---|
0 | None |
1 | 设置子网掩码 |
2 | "Time Offset in Seconds from UTC |
3 | 设置网关 |
4 | N/4 Timeserver addresses |
5 | N/4 IEN-116 Server addresses |
6 | 设置DNS服务器 |
7 | N/4 Logging Server addresses |
8 | N/4 Quotes Server addresses |
9 | N/4 Printer Server addresses |
10 | N/4 Impress Server addresses |
11 | N/4 RLP Server addresses |
12 | 设置域名选项。 |
13 | Size of boot file in 512 byte chunks |
14 | Client to dump and name the file to dump it to |
15 | 设置域名后缀选项。 |
16 | Swap Server address |
17 | Path name for root disk |
18 | Path name for more BOOTP info |
19 | Enable/Disable IP Forwarding |
20 | Enable/Disable Source Routing |
21 | Routing Policy Filters |
22 | Max Datagram Reassembly Size |
23 | Default IP Time to Live |
24 | Path MTU Aging Timeout |
25 | Path MTU Plateau Table |
26 | Interface MTU Size |
27 | All Subnets are Local |
28 | Broadcast Address |
29 | Perform Mask Discovery |
30 | Provide Mask to Others |
31 | Perform Router Discovery |
32 | Router Solicitation Address |
33 | 设置静态路由选项。该选项中包含一组有分类静态路由(即目的地址的掩码固定为自然掩码,不能划分子网),客户端收到该选项后,将在路由表中添加这些静态路由。如果存在Option121,则忽略该选项。 |
34 | Trailer Encapsulation |
35 | ARP Cache Timeout |
36 | Ethernet Encapsulation |
37 | Default TCP Time to Live |
38 | TCP Keepalive Interval |
39 | TCP Keepalive Garbage |
40 | NIS Domain Name |
41 | NIS Server Addresses |
42 | NTP Server Addresses |
43 | Vendor Specific Information |
44 | 设置NetBios服务器选项。 |
45 | NETBIOS Datagram Distribution |
46 | 设置NetBios节点类型选项。 |
47 | NETBIOS Scope |
48 | X Window Font Server |
49 | X Window Display Manager |
50 | 设置请求IP选项。 |
51 | 设置IP地址租约时间选项。 |
52 | 设置Option附加选项。 |
53 | 设置DHCP消息类型。 |
54 | 设置服务器标识。 |
55 | 设置请求参数列表选项。客户端利用该选项指明需要从服务器获取哪些网络配置参数。该选项内容为客户端请求的参数对应的选项值。 |
56 | DHCP Error Message |
57 | DHCP Maximum Message Size |
58 | 设置续约T1时间,一般是租期时间的50%。 |
59 | 设置续约T2时间。一般是租期时间的87.5%。 |
60 | 设置厂商分类信息选项,用于标识DHCP客户端的类型和配置。 |
61 | 设置客户端标识选项。 |
62 | NetWare/IP Domain Name |
63 | NetWare/IP sub Options |
64 | NIS+ v3 Client Domain Name |
65 | NIS+ v3 Server Addresses |
66 | 设置TFTP服务器名选项,用来指定为客户端分配的TFTP服务器的域名。 |
67 | 设置启动文件名选项,用来指定为客户端分配的启动文件名。 |
68 | Home Agent Addresses |
69 | Simple Mail Server Addresses |
70 | Post Office Server Addresses |
71 | Network News Server Addresses |
72 | WWW Server Addresses |
73 | Finger Server Addresses |
74 | Chat Server Addresses |
75 | StreetTalk Server Addresses |
76 | ST Directory Assist. Addresses |
77 | 设置用户类型标识。 |
78 | directory agent information |
79 | service location agent scope |
80 | Rapid Commit |
81 | Fully Qualified Domain Name |
82 | Relay Agent Information |
83 | Internet Storage Name Service |
85 | Novell Directory Services |
86 | Novell Directory Services |
87 | Novell Directory Services |
90 | Authentication |
93 | Client System Architecture |
94 | Client Network Device Interface |
95 | Lightweight Directory Access Protocol |
97 | UUID/GUID-based Client Identifier |
98 | Open Group's User Authentication |
100 | IEEE 1003.1 TZ String |
101 | Reference to the TZ Database |
108 | Number of seconds that DHCPv4 should be disabled |
109 | DHCPv4 over DHCPv6 Softwire Source Address Option |
112 | NetInfo Parent Server Address |
113 | NetInfo Parent Server Tag |
114 | DHCP Captive-Portal |
116 | DHCP Auto-Configuration |
117 | Name Service Search |
118 | Subnet Selection Option |
119 | DNS domain search list |
120 | SIP Servers DHCP Option |
121 | 设置无分类路由选项。该选项中包含一组无分类静态路由(即目的地址的掩码为任意值,可以通过掩码来划分子网),客户端收到该选项后,将在路由表中添加这些静态路由。 |
122 | CableLabs Client Configuration |
123 | GeoConf Option |
124 | Vendor-Identifying Vendor Class |
125 | Vendor-Identifying Vendor-Specific Information |
138 | CAPWAP Access Controller addresses |
139 | a series of suboptions |
140 | a series of suboptions |
141 | List of domain names to search for SIP User Agent Configuration |
142 | ANDSF IPv4 Address Option for DHCPv4 |
143 | This option provides a list of URIs for SZTP bootstrap servers |
144 | Geospatial Location with Uncertainty |
145 | Forcerenew Nonce Capable |
146 | Information for selecting RDNSS |
147 | The name of the peer DOTS agent. |
148 | N/4 IPv4 addresses of peer DOTS agent(s). |
150 | 设置TFTP服务器地址选项,指定为客户端分配的TFTP服务器的地址。 |
151 | Status code and optional N byte text message describing status. |
152 | "Absolute time (seconds since Jan 1, 1970) message was sent." |
153 | Number of seconds in the past when client entered current state. |
154 | "Absolute time (seconds since Jan 1, 1970) for beginning of query." |
155 | "Absolute time (seconds since Jan 1, 1970) for end of query." |
156 | State of IP address. |
157 | Indicates information came from local or remote server. |
158 | Includes one or multiple lists of PCP server IP addresses; each list is treated as a separate PCP server. |
159 | This option is used to configure a set of ports bound to a shared IPv4 address. |
160 | Previously assigned by [RFC7710]; known to also be used by Polycom. |
161 | Manufacturer Usage Descriptions |