dhcp-options on openwrt
dhcp-options on openwrt
参考 https://dongshao.blog.csdn.net/article/details/102713133
参考 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. | RFC 2132 |
1 | 4 | Subnet Mask. | RFC 2132 |
2 | 4 | Time Offset (deprecated). | RFC 2132 |
3 | 4+ | Router. | RFC 2132 |
4 | 4+ | Time Server. | RFC 2132 |
5 | 4+ | Name Server. | RFC 2132 |
6 | 4+ | Domain Name Server. | RFC 2132 |
7 | 4+ | Log Server. | RFC 2132 |
8 | 4+ | Quote Server. | RFC 2132 |
9 | 4+ | LPR Server. | RFC 2132 |
10 | 4+ | Impress Server. | RFC 2132 |
11 | 4+ | Resource Location Server. | RFC 2132 |
12 | 1+ | Host Name. | RFC 2132 |
13 | 2 | Boot File Size. | RFC 2132 |
14 | 1+ | Merit Dump File. | RFC 2132 |
15 | 1+ | Domain Name. | RFC 2132 |
16 | 4 | Swap Server. | RFC 2132 |
17 | 1+ | Root Path. | RFC 2132 |
18 | 1+ | Extensions Path. | RFC 2132 |
19 | 1 | IP Forwarding enable/disable. | RFC 2132 |
20 | 1 | Non-local Source Routing enable/disable. | RFC 2132 |
21 | 8+ | Policy Filter. | RFC 2132 |
22 | 2 | Maximum Datagram Reassembly Size. | RFC 2132 |
23 | 1 | Default IP Time-to-live. | RFC 2132 |
24 | 4 | Path MTU Aging Timeout. | RFC 2132 |
25 | 2+ | Path MTU Plateau Table. | RFC 2132 |
26 | 2 | Interface MTU. | RFC 2132 |
27 | 1 | All Subnets are Local. | RFC 2132 |
28 | 4 | Broadcast Address. | RFC 2132 |
29 | 1 | Perform Mask Discovery. | RFC 2132 |
30 | 1 | Mask supplier. | RFC 2132 |
31 | 1 | Perform router discovery. | RFC 2132 |
32 | 4 | Router solicitation address. | RFC 2132 |
33 | 8+ | Static routing table. | RFC 2132 |
34 | 1 | Trailer encapsulation. | RFC 2132 |
35 | 4 | ARP cache timeout. | RFC 2132 |
36 | 1 | Ethernet encapsulation. | RFC 2132 |
37 | 1 | Default TCP TTL. | RFC 2132 |
38 | 4 | TCP keepalive interval. | RFC 2132 |
39 | 1 | TCP keepalive garbage. | RFC 2132 |
40 | 1+ | Network Information Service Domain. | RFC 2132 |
41 | 4+ | Network Information Servers. | RFC 2132 |
42 | 4+ | NTP servers. | RFC 2132 |
43 | 1+ | Vendor specific information. | RFC 1533, RFC 2132 |
44 | 4+ | NetBIOS over TCP/IP name server. | RFC 1533, RFC 2132 |
45 | 4+ | NetBIOS over TCP/IP Datagram Distribution Server. | RFC 1533, RFC 2132 |
46 | 1 | NetBIOS over TCP/IP Node Type. | RFC 1533, RFC 2132 |
47 | 1+ | NetBIOS over TCP/IP Scope. | RFC 1533, RFC 2132 |
48 | 4+ | X Window System Font Server. | RFC 1533, RFC 2132 |
49 | 4+ | X Window System Display Manager. | RFC 1533, RFC 2132 |
50 | 4 | Requested IP Address. | RFC 1533, RFC 2132 |
51 | 4 | IP address lease time. | RFC 1533, RFC 2132 |
52 | 1 | Option overload. | RFC 1533, RFC 2132 |
53 | 1 | DHCP message type. | RFC 1533, RFC 2132, RFC 3203, RFC 4388 |
54 | 4 | Server identifier. | RFC 1533, RFC 2132 |
55 | 1+ | Parameter request list. | RFC 1533, RFC 2132 |
56 | 1+ | Message. | RFC 1533, RFC 2132 |
57 | 2 | Maximum DHCP message size. | RFC 1533, RFC 2132 |
58 | 4 | Renew time value. | RFC 1533, RFC 2132 |
59 | 4 | Rebinding time value. | RFC 1533, RFC 2132 |
60 | 1+ | Class-identifier. | RFC 1533, RFC 2132 |
61 | 2+ | Client-identifier. | RFC 1533, RFC 2132, RFC 4361 |
62 | 1 to 255 | NetWare/IP Domain Name. | RFC 2242 |
63 | NetWare/IP information. | RFC 2242 | |
64 | 1+ | Network Information Service+ Domain. | RFC 2132 |
65 | 4+ | Network Information Service+ Servers. | RFC 2132 |
66 | 1+ | TFTP server name. | RFC 2132 |
67 | 1+ | Bootfile name. | RFC 2132 |
68 | 0+ | Mobile IP Home Agent. | RFC 2132 |
69 | 4+ | Simple Mail Transport Protocol Server. | RFC 2132 |
70 | 4+ | Post Office Protocol Server. | RFC 2132 |
71 | 4+ | Network News Transport Protocol Server. | RFC 2132 |
72 | 4+ | Default World Wide Web Server. | RFC 2132 |
73 | 4+ | Default Finger Server. | RFC 2132 |
74 | 4+ | Default Internet Relay Chat Server. | RFC 2132 |
75 | 4+ | StreetTalk Server. | RFC 2132 |
76 | 4+ | StreetTalk Directory Assistance Server. | RFC 2132 |
77 | Variable. | User Class Information. | RFC 3004 |
78 | Variable. | SLP Directory Agent. | RFC 2610 |
79 | Variable. | SLP Service Scope. | RFC 2610 |
80 | 0 | Rapid Commit. | RFC 4039 |
81 | 4+. | FQDN, Fully Qualified Domain Name. | RFC 4702 |
82 | Variable. | Relay Agent Information. | RFC 3046, RFC 5010 |
83 | 14+ | Internet Storage Name Service. | RFC 4174 |
84 | RFC 3679 | ||
85 | Variable. | NDS servers. | RFC 2241 |
86 | Variable. | NDS tree name. | RFC 2241 |
87 | Variable. | NDS context. | RFC 2241 |
88 | Variable. | BCMCS Controller Domain Name list. | RFC 4280 |
89 | 4+ | BCMCS Controller IPv4 address list. | RFC 4280 |
90 | Variable. | Authentication. | RFC 3118 |
91 | 4 | client-last-transaction-time. | RFC 4388 |
92 | 4n | associated-ip. | RFC 4388 |
93 | Variable. | Client System Architecture Type. | RFC 4578 |
94 | Variable. | Client Network Interface Identifier. | RFC 4578 |
95 | Variable. | LDAP, Lightweight Directory Access Protocol. | RFC 3679 |
96 | RFC 3679 | ||
97 | Variable. | Client Machine Identifier. | RFC 4578 |
98 | Open Group's User Authentication. | RFC 2485 | |
99 | GEOCONF_CIVIC. | RFC 4776 | |
100 | IEEE 1003.1 TZ String. | RFC 4833 | |
101 | Reference to the TZ Database. | RFC 4833 | |
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 | RFC 2563 |
117 | 2+ | Name Service Search. | RFC 2937 |
118 | 4 | Subnet Selection. | RFC 3011 |
119 | Variable | DNS domain search list. | RFC 3397 |
120 | Variable | SIP Servers DHCP Option. | RFC 3361 |
121 | 5+ | Classless Static Route Option. | RFC 3442 |
122 | Variable | CCC, CableLabs Client Configuration. | RFC 3495, RFC 3594, RFC 3634 |
123 | 16 | GeoConf. | RFC 3825 |
124 | Vendor-Identifying Vendor Class. | RFC 3925 | |
125 | Vendor-Identifying Vendor-Specific. | RFC 3925 | |
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. | RFC 5192 |
137 | variable | LoST Server. | RFC 5223 |
138 | CAPWAP Access Controller addresses. | RFC 5417 | |
139 | OPTION-IPv4_Address-MoS. | RFC 5678 | |
140 | OPTION-IPv4_FQDN-MoS. | RFC 5678 | |
141 | 2+ | SIP UA Configuration Service Domains. | RFC 6011 |
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. | RFC 6607 |
222 223 |
RFC 3942 | ||
224 - 254 |
Private use. | ||
255 | 0 | End. | RFC 2132 |
============= End