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