dhcp-options on openwrt
参考
参考 https://openwrt.org/zh/docs/guide-user/base-system/dhcp_configuration
参考 http://www.networksorcery.com/enp/protocol/bootp/options.htm
参考 http://www.iana.org/assignments/bootp-dhcp-parameters/bootp-dhcp-parameters.txt
如上图,如果需要设置DHCP分配的网关地址为:192.168.1.254,那么只需要在DHCP-选项中输入3,192.168.254即可。同理,如果想设置指定的DNS,输入6,192.168.1.1即可将192.168.1.1分配给客户端的DNS。
root@ACU:~# cat /etc/config/dhcp
config dnsmasq
option domainneeded '1'
option boguspriv '1'
option filterwin2k '0'
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 authoritative '1'
option readethers '1'
option leasefile '/tmp/dhcp.leases'
option resolvfile '/tmp/resolv.conf.auto'
option localservice '1'
config dhcp 'lan'
option interface 'lan'
option start '100'
option limit '150'
option leasetime '12h'
list dhcp_option '3,172.17.143.254'
list dhcp_option '6,114.114.114.114,8.8.8.8'
config dhcp 'SAT'
option interface 'SAT'
option ignore '1'
config dhcp '4G'
option interface '4G'
option ignore '1'
config dhcp 'wan'
option interface 'wan'
option ignore '1'
config odhcpd 'odhcpd'
option maindhcp '0'
option leasefile '/tmp/hosts/odhcpd'
option leasetrigger '/usr/sbin/odhcpd-update'
root@ACU:~#
The set of option-names known by dnsmasq can be discovered by running “dnsmasq --help dhcp”.
附DHCP设置相关参数含义:
Options号 | Options作用 |
1 | 设置子网掩码选项。 |
3 | 设置网关地址选项。 |
6 | 设置DNS服务器地址选项。 |
12 | 设置域名选项。 |
15 | 设置域名后缀选项。 |
33 | 设置静态路由选项。该选项中包含一组有分类静态路由(即目的地址的掩码固定为自然掩码,不能划分子网),客户端收到该选项后,将在路由表中添加这些静态路由。如果存在Option121,则忽略该选项。 |
44 | 设置NetBios服务器选项。 |
46 | 设置NetBios节点类型选项。 |
50 | 设置请求IP选项。 |
51 | 设置IP地址租约时间选项。 |
52 | 设置Option附加选项。 |
53 | 设置DHCP消息类型。 |
54 | 设置服务器标识。 |
55 | 设置请求参数列表选项。客户端利用该选项指明需要从服务器获取哪些网络配置参数。该选项内容为客户端请求的参数对应的选项值。 |
58 | 设置续约T1时间,一般是租期时间的50%。 |
59 | 设置续约T2时间。一般是租期时间的87.5%。 |
60 | 设置厂商分类信息选项,用于标识DHCP客户端的类型和配置。 |
61 | 设置客户端标识选项。 |
66 | 设置TFTP服务器名选项,用来指定为客户端分配的TFTP服务器的域名。 |
67 | 设置启动文件名选项,用来指定为客户端分配的启动文件名。 |
77 | 设置用户类型标识。 |
121 | 设置无分类路由选项。该选项中包含一组无分类静态路由(即目的地址的掩码为任意值,可以通过掩码来划分子网),客户端收到该选项后,将在路由表中添加这些静态路由。 |
148 | EasyDeploy中Commander的IP地址。 |
149 | SFTP和FTPS服务器的IP地址。 |
150 | 设置TFTP服务器地址选项,指定为客户端分配的TFTP服务器的地址。 |
Code | Data length | Description | References |
0 | 0 | Pad. | |
1 | 4 | ||
2 | 4 | Time Offset (deprecated). | |
3 | 4+ | ||
4 | 4+ | ||
5 | 4+ | ||
6 | 4+ | ||
7 | 4+ | ||
8 | 4+ | ||
9 | 4+ | ||
10 | 4+ | ||
11 | 4+ | ||
12 | 1+ | ||
13 | 2 | ||
14 | 1+ | ||
15 | 1+ | ||
16 | 4 | ||
17 | 1+ | ||
18 | 1+ | ||
19 | 1 | ||
20 | 1 | ||
21 | 8+ | ||
22 | 2 | ||
23 | 1 | ||
24 | 4 | ||
25 | 2+ | ||
26 | 2 | ||
27 | 1 | ||
28 | 4 | ||
29 | 1 | ||
30 | 1 | ||
31 | 1 | ||
32 | 4 | ||
33 | 8+ | ||
34 | 1 | ||
35 | 4 | ||
36 | 1 | ||
37 | 1 | ||
38 | 4 | ||
39 | 1 | ||
40 | 1+ | ||
41 | 4+ | ||
42 | 4+ | ||
43 | 1+ | Vendor specific information. | |
44 | 4+ | NetBIOS over TCP/IP name server. | |
45 | 4+ | NetBIOS over TCP/IP Datagram Distribution Server. | |
46 | 1 | NetBIOS over TCP/IP Node Type. | |
47 | 1+ | NetBIOS over TCP/IP Scope. | |
48 | 4+ | X Window System Font Server. | |
49 | 4+ | X Window System Display Manager. | |
50 | 4 | Requested IP Address. | |
51 | 4 | IP address lease time. | |
52 | 1 | Option overload. | |
53 | 1 | DHCP message type. | |
54 | 4 | Server identifier. | |
55 | 1+ | Parameter request list. | |
56 | 1+ | Message. | |
57 | 2 | Maximum DHCP message size. | |
58 | 4 | Renew time value. | |
59 | 4 | Rebinding time value. | |
60 | 1+ | Class-identifier. | |
61 | 2+ | Client-identifier. | |
62 | 1 to 255 | NetWare/IP Domain Name. | |
63 | | NetWare/IP information. | |
64 | 1+ | Network Information Service+ Domain. | |
65 | 4+ | Network Information Service+ Servers. | |
66 | 1+ | TFTP server name. | |
67 | 1+ | Bootfile name. | |
68 | 0+ | Mobile IP Home Agent. | |
69 | 4+ | Simple Mail Transport Protocol Server. | |
70 | 4+ | Post Office Protocol Server. | |
71 | 4+ | Network News Transport Protocol Server. | |
72 | 4+ | Default World Wide Web Server. | |
73 | 4+ | Default Finger Server. | |
74 | 4+ | Default Internet Relay Chat Server. | |
75 | 4+ | StreetTalk Server. | |
76 | 4+ | StreetTalk Directory Assistance Server. | |
77 | Variable. | User Class Information. | |
78 | Variable. | SLP Directory Agent. | |
79 | Variable. | SLP Service Scope. | |
80 | 0 | Rapid Commit. | |
81 | 4+. | FQDN, Fully Qualified Domain Name. | |
82 | Variable. | ||
83 | 14+ | Internet Storage Name Service. | |
84 | | | RFC 3679 |
85 | Variable. | NDS servers. | |
86 | Variable. | NDS tree name. | |
87 | Variable. | NDS context. | |
88 | Variable. | BCMCS Controller Domain Name list. | |
89 | 4+ | BCMCS Controller IPv4 address list. | |
90 | Variable. | Authentication. | |
91 | 4 | client-last-transaction-time. | |
92 | 4n | associated-ip. | |
93 | Variable. | Client System Architecture Type. | |
94 | Variable. | Client Network Interface Identifier. | |
95 | Variable. | LDAP, Lightweight Directory Access Protocol. | RFC 3679 |
96 | | | RFC 3679 |
97 | Variable. | Client Machine Identifier. | |
98 | | Open Group's User Authentication. | |
99 | | GEOCONF_CIVIC. | RFC 4776 |
100 | | IEEE 1003.1 TZ String. | |
101 | | Reference to the TZ Database. | |
102 - 111 | | | RFC 3679 |
112 | Variable. | NetInfo Parent Server Address. | RFC 3679 |
113 | Variable. | NetInfo Parent Server Tag. | RFC 3679 |
114 | Variable. | URL. | RFC 3679 |
115 | | | RFC 3679 |
116 | 1 | Auto-Configure | |
117 | 2+ | Name Service Search. | |
118 | 4 | Subnet Selection. | |
119 | Variable | DNS domain search list. | |
120 | Variable | SIP Servers DHCP Option. | |
121 | 5+ | Classless Static Route Option. | |
122 | Variable | CCC, CableLabs Client Configuration. | |
123 | 16 | ||
124 | | Vendor-Identifying Vendor Class. | |
125 | | Vendor-Identifying Vendor-Specific. | |
126 | | | RFC 3679 |
127 | | | RFC 3679 |
128 | | TFTP Server IP address. | RFC 4578 |
129 | | Call Server IP address. | RFC 4578 |
130 | | Discrimination string. | RFC 4578 |
131 | | Remote statistics server IP address. | RFC 4578 |
132 | | 802.1P VLAN ID. | RFC 4578 |
133 | | 802.1Q L2 Priority. | RFC 4578 |
134 | | Diffserv Code Point. | RFC 4578 |
135 | | HTTP Proxy for phone-specific applications. | RFC 4578 |
136 | 4+ | PANA Authentication Agent. | |
137 | variable | LoST Server. | |
138 | | CAPWAP Access Controller addresses. | |
139 | | OPTION-IPv4_Address-MoS. | RFC 5678 |
140 | | OPTION-IPv4_FQDN-MoS. | RFC 5678 |
141 | 2+ | SIP UA Configuration Service Domains. | |
142 | | OPTION-IPv4_Address-ANDSF. | RFC 6153 |
143 | | OPTION-IPv6_Address-ANDSF. | RFC 6153 |
144 - 149 | | | RFC 3942 |
150 | | TFTP server address. | RFC 5859 |
150 | | Etherboot. GRUB configuration path name. | |
151 | | status-code. | |
152 | | base-time. | |
153 | | start-time-of-state. | |
154 | | query-start-time. | |
155 | | query-end-time. | |
156 | | dhcp-state. | |
157 | | data-source. | |
158 - 174 | | | RFC 3942 |
175 | | Etherboot. | |
176 | | IP Telephone. | |
177 | | Etherboot. PacketCable and CableHome. | |
178 - 207 | | | RFC 3942 |
208 | | pxelinux.magic (string) = F1:00:74:7E (241.0.116.126). | RFC 5071 |
209 | | pxelinux.configfile (text). | RFC 5071 |
210 | | pxelinux.pathprefix (text). | RFC 5071 |
211 | | pxelinux.reboottime (unsigned integer 32 bits). | RFC 5071 |
212 | 18+ | OPTION_6RD. | RFC 5969 |
213 | | OPTION_V4_ACCESS_DOMAIN. | RFC 5986 |
214 - 219 | | | |
220 | | Subnet Allocation. | |
221 | 1+ | Virtual Subnet Selection. | |
222 223 | | | RFC 3942 |
224 - 254 | | Private use. | |
255 | 0 | End. |
============= End