[关闭]
@cdmonkey 2018-10-15T08:55:06.000000Z 字数 27054 阅读 2568

DNSmasq

网络服务


http://www.thekelleys.org.uk/dnsmasq/doc.html
http://blog.csdn.net/rheostat/article/details/7831020

一、简介

默认的情况下,我们平时上网用的本地DNS服务器都是使用电信或者联通的,但是这样也导致了不少的问题,首当其冲的就是上网时经常莫名地弹出广告,或者莫名的流量被消耗掉导致网速变慢。其次是部分网站域名不能正常被解析,莫名其妙地打不开,或者时好时坏。

如果碰上不稳定的本地域名解析服务器,还可能经常出现无法解析的情况。除了要避免“坏”的解析服务的影响,我们还可以利用域名解析服务做些“好”事,例如管理局域网的DNS、给手机应用商店加速、纠正错误的DNS解析记录、保证上网更加安全、去掉网页讨厌的广告等等。

因此我们可以利用该软件来搭建一个属于自己的本地DNS服务器,享受更干净无污染、更智能快速和没有广告干扰的域名解析服务。它能够实现如下这些实用功能:

Provide DNS service.
Give priority to the use of local custom DNS.
Provide DHCP service.

能有效解决局域网中的问题如下:

局域网有很多机器希望使用一份一样的hosts定义一批名称及其对应的IP地址,你需要经常维护这份列表。
你希望局域网的人访问某个域名时,拦截下来到指定的IP地址,做缓存节省带宽或者其它用途都可以。
禁止某个域名的正常解析。

二、安装

Yum Install

简单快捷,但问题就是版本较老。

  1. [root@DNS-A1 ~]# yum install -y dnsmasq

编译安装

安装方法可参见下面的说明:
https://fossies.org/linux/misc/dns/dnsmasq-2.76.tar.gz/dnsmasq-2.76/setup.html

  1. # 需要安装依赖包:
  2. [root@PBSNTP01 ~]# yum install gcc
  3. # 解压后编译安装:
  4. [root@PBSNTP01 tools]# tar zxvf dnsmasq-2.76.tar.gz
  5. [root@PBSNTP01 tools]# cd dnsmasq-2.76
  6. [root@PBSNTP01 dnsmasq-2.76]# make install
  7. # 拷贝主配置文件:
  8. [root@PBSNTP01 dnsmasq-2.76]# cp dnsmasq.conf.example /etc/dnsmasq.conf
  9. # 创建相关的目录:
  10. [root@PBSNTP01 dnsmasq-2.76]# mkdir -pv /etc/dnsmasq.d
  11. [root@PBSNTP01 dnsmasq-2.76]# mkdir -pv /etc/dns

创建应用账号:

  1. [root@PBSNTP01 ~]# useradd -s /sbin/nologin -M dnsmasq

服务启停脚本。需要说明的是,若使用yum进行安装,则该脚本就无需手工创建,但如果是编译安装该版本,就没有服务脚本,因而需要手工创建。

  1. [root@PBSNTP01 ~]# vim /etc/init.d/dnsmasq
  2. #!/bin/sh
  3. # Startup script for the DNS caching server
  4. #
  5. # chkconfig: - 49 50
  6. # description: This script starts your DNS caching server
  7. # processname: dnsmasq
  8. # pidfile: /var/run/dnsmasq.pid
  9. # Source function library.
  10. . /etc/rc.d/init.d/functions
  11. # Source networking configuration.
  12. . /etc/sysconfig/network
  13. # Check that networking is up.
  14. [ ${NETWORKING} = "no" ] && exit 0
  15. dnsmasq=/usr/local/sbin/dnsmasq
  16. [ -f $dnsmasq ] || exit 0
  17. DOMAIN_SUFFIX=`dnsdomainname`
  18. if [ ! -z "${DOMAIN_SUFFIX}" ]; then
  19. OPTIONS="-s $DOMAIN_SUFFIX"
  20. fi
  21. RETVAL=0
  22. PIDFILE="/var/run/dnsmasq.pid"
  23. # See how we were called.
  24. case "$1" in
  25. start)
  26. if [ $UID -ne 0 ] ; then
  27. echo "User has insufficient privilege."
  28. exit 4
  29. fi
  30. echo -n "Starting dnsmasq: "
  31. daemon $dnsmasq $OPTIONS
  32. RETVAL=$?
  33. echo
  34. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dnsmasq
  35. ;;
  36. stop)
  37. if test "x`pidfileofproc dnsmasq`" != x; then
  38. echo -n "Shutting down dnsmasq: "
  39. killproc dnsmasq
  40. fi
  41. RETVAL=$?
  42. echo
  43. [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dnsmasq $PIDFILE
  44. ;;
  45. status)
  46. status -p $PIDFILE dnsmasq
  47. RETVAL=$?
  48. ;;
  49. reload)
  50. if test "x`pidfileofproc dnsmasq`" != x; then
  51. echo -n "Reloading dnsmasq: "
  52. killproc dnsmasq -HUP
  53. fi
  54. RETVAL=$?
  55. echo
  56. ;;
  57. force-reload)
  58. # new configuration takes effect only after restart
  59. $0 stop
  60. $0 start
  61. RETVAL=$?
  62. ;;
  63. restart)
  64. $0 stop
  65. $0 start
  66. RETVAL=$?
  67. ;;
  68. condrestart)
  69. if test "x`pidfileofproc dnsmasq`" != x; then
  70. $0 stop
  71. $0 start
  72. RETVAL=$?
  73. fi
  74. ;;
  75. *)
  76. echo "Usage: $0 {start|stop|restart|reload|condrestart|status}"
  77. exit 2
  78. esac
  79. exit $RETVAL

授予可执行权限:

  1. [root@PBSNTP01 ~]# chmod +x /etc/init.d/dnsmasq

修改配置

1. 修改主配置文件

首先需要修改主配置文件:

  1. [root@PBSNTP01 ~]# vim /etc/dnsmasq.conf
  2. # 确保下面的配置项被取消注释,并进行相应的配置:
  3. resolv-file=/etc/resolv.dnsmasq.conf # 表示该服务会从这个指定的文件中寻找上游DNS服务器,事实证明该条目可以不配置。
  4. strict-order # 取消注释。
  5. ------------------
  6. # 检查一下“no-hosts”是不是已经注释掉了,默认的情况下是注释的,服务会首先寻找本地的hosts文件再去寻找缓存下来的域名,最后去上游DNS服务器寻找。
  7. #no-hosts
  8. ------------------
  9. # 下面的配置项去掉注释,并进行如下设置,表示该服务本机自己使用有效。
  10. listen-address=127.0.0.1 # 生产中该条目没有配置。

生产中实际上只于主配置文件中追加了下面三行:

  1. user=dnsmasq
  2. group=dnsmasq
  3. conf-dir=/etc/dnsmasq.d
  4. port=53
  5. neg-ttl=3600

小提示:若配置文件发生变化需要重启服务,reload是不行的,reload只适用于解析文件发生变化的情况。

2. 创建扩展配置文件

许多实际要使用的配置条目于该文件中进行配置。

  1. [root@PBSNTP01 ~]# vim /etc/dnsmasq.d/dns.conf
  2. addn-hosts=/etc/dns/dns.suixingpay
  3. no-resolv
  4. cache-size=10240
  5. #ipv6 DNS for google
  6. #server=2001:4860:4860::8888
  7. #server=2001:4860:4860::8844
  8. #ipv6 DNS for opendns
  9. #server=2620:0:ccc::2
  10. #server=2620:0:ccd::2
  11. #other ipv4 server
  12. # The DNS Server on Internet
  13. #server=/cn/114.114.114.114
  14. server=/goole.com/8.8.8.8
  15. server=223.5.5.5
  16. server=223.6.6.6
  17. server=/paxsh.com/223.5.5.5
  18. #server=/suixingpay.com/223.5.5.5
  19. server=/fir.suixingpay.com/172.16.20.74
  20. # Set suixingpay DNS
  21. address=/.suixingpay.local/127.0.0.1
  22. address=/dh.suixingpay.com/172.16.132.241
  23. address=/ss.suixingpay.com/210.74.5.253
  24. #address=/report.suixingpay.com/10.1.30.192
  25. #address=/ad.youku.com/127.0.0.1
  26. #address=/ad.iqiyi.com/127.0.0.1

3. 创建解析文件

创建本地域名解析文件:

  1. [root@PBSNTP01 ~]# vim /etc/dns/dns.suixingpay
  2. 172.16.132.2 IaaS.suixingpay.local
  3. 172.16.132.3 vCAC-SERVER.suixingpay.local
  4. ...

4. 最后的工作

另外我们还需要修改/etc/resolv.conf这个文件,将本地主机的DNS服务器设定为自身:

  1. #
  2. [root@DNS-A1 ~]# echo "nameserver 127.0.0.1" > /etc/resolv.conf
  3. #
  4. [root@DNS-A1 ~]# cp /etc/resolv.conf /etc/resolv.dnsmasq.conf
  5. #通过resolv.dnsmasq.conf中设置的是真正的名称服务器,可以用谷歌、阿里等公共的DNS服务器。
  6. [root@DNS-A1 ~]# echo "nameserver 8.8.8.8" > /etc/resolv.dnsmasq.conf
  7. [root@DNS-A1 ~]# cp /etc/hosts /etc/dnsmasq.hosts
  8. [root@DNS-A1 ~]# echo "addn-hosts=/etc/dnsmasq.hosts" >> /etc/dnsmasq.conf

最后,需要将主机名能够解析为回环地址:

  1. [root@PBSNTP01 ~]# vim /etc/hosts
  2. 127.0.0.1 localhost.localdomain localhost.localdomain ... localhost PBSNTP01
  3. ...

启动服务

  1. [root@PBSNTP01 ~]# /etc/init.d/dnsmasq start
  2. Starting dnsmasq: [ OK ]

配置文件详解

  1. # Configuration file for dnsmasq.
  2. #
  3. # Format is one option per line, legal options are the same
  4. # as the long options legal on the command line. See
  5. # "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
  6. # Listen on this specific port instead of the standard DNS port
  7. # (53). Setting this to zero completely disables DNS function,
  8. # leaving only DHCP and/or TFTP.
  9. #port=5353
  10. # The following two options make you a better netizen, since they
  11. # tell dnsmasq to filter out queries which the public DNS cannot
  12. # answer, and which load the servers (especially the root servers)
  13. # unnecessarily. If you have a dial-on-demand link they also stop
  14. # these requests from bringing up the link unnecessarily.
  15. # Never forward plain names (without a dot or domain part)
  16. #domain-needed
  17. # Never forward addresses in the non-routed address spaces.
  18. #bogus-priv
  19. # Uncomment these to enable DNSSEC validation and caching:
  20. # (Requires dnsmasq to be built with DNSSEC option.)
  21. #conf-file=%%PREFIX%%/share/dnsmasq/trust-anchors.conf
  22. #dnssec
  23. # Replies which are not DNSSEC signed may be legitimate, because the domain
  24. # is unsigned, or may be forgeries. Setting this option tells dnsmasq to
  25. # check that an unsigned reply is OK, by finding a secure proof that a DS
  26. # record somewhere between the root and the domain does not exist.
  27. # The cost of setting this is that even queries in unsigned domains will need
  28. # one or more extra DNS queries to verify.
  29. #dnssec-check-unsigned
  30. # Uncomment this to filter useless windows-originated DNS requests
  31. # which can trigger dial-on-demand links needlessly.
  32. # Note that (amongst other things) this blocks all SRV requests,
  33. # so don't use it if you use eg Kerberos, SIP, XMMP or Google-talk.
  34. # This option only affects forwarding, SRV records originating for
  35. # dnsmasq (via srv-host= lines) are not suppressed by it.
  36. #filterwin2k
  37. # Change this line if you want dns to get its upstream servers from
  38. # somewhere other that /etc/resolv.conf
  39. #resolv-file=
  40. # By default, dnsmasq will send queries to any of the upstream
  41. # servers it knows about and tries to favour servers to are known
  42. # to be up. Uncommenting this forces dnsmasq to try each query
  43. # with each server strictly in the order they appear in
  44. # /etc/resolv.conf
  45. #strict-order
  46. # If you don't want dnsmasq to read /etc/resolv.conf or any other
  47. # file, getting its servers from this file instead (see below), then
  48. # uncomment this.
  49. #no-resolv
  50. # If you don't want dnsmasq to poll /etc/resolv.conf or other resolv
  51. # files for changes and re-read them then uncomment this.
  52. #no-poll
  53. # Add other name servers here, with domain specs if they are for
  54. # non-public domains.
  55. #server=/localnet/192.168.0.1
  56. # Example of routing PTR queries to nameservers: this will send all
  57. # address->name queries for 192.168.3/24 to nameserver 10.1.2.3
  58. #server=/3.168.192.in-addr.arpa/10.1.2.3
  59. # Add local-only domains here, queries in these domains are answered
  60. # from /etc/hosts or DHCP only.
  61. #local=/localnet/
  62. # Add domains which you want to force to an IP address here.
  63. # The example below send any host in double-click.net to a local
  64. # web-server.
  65. #address=/double-click.net/127.0.0.1
  66. # --address (and --server) work with IPv6 addresses too.
  67. #address=/www.thekelleys.org.uk/fe80::20d:60ff:fe36:f83
  68. # Add the IPs of all queries to yahoo.com, google.com, and their
  69. # subdomains to the vpn and search ipsets:
  70. #ipset=/yahoo.com/google.com/vpn,search
  71. # You can control how dnsmasq talks to a server: this forces
  72. # queries to 10.1.2.3 to be routed via eth1
  73. # server=10.1.2.3@eth1
  74. # and this sets the source (ie local) address used to talk to
  75. # 10.1.2.3 to 192.168.1.1 port 55 (there must be a interface with that
  76. # IP on the machine, obviously).
  77. # server=10.1.2.3@192.168.1.1#55
  78. # If you want dnsmasq to change uid and gid to something other
  79. # than the default, edit the following lines.
  80. #user=
  81. #group=
  82. # If you want dnsmasq to listen for DHCP and DNS requests only on
  83. # specified interfaces (and the loopback) give the name of the
  84. # interface (eg eth0) here.
  85. # Repeat the line for more than one interface.
  86. #interface=
  87. # Or you can specify which interface _not_ to listen on
  88. #except-interface=
  89. # Or which to listen on by address (remember to include 127.0.0.1 if
  90. # you use this.)
  91. #listen-address=
  92. # If you want dnsmasq to provide only DNS service on an interface,
  93. # configure it as shown above, and then use the following line to
  94. # disable DHCP and TFTP on it.
  95. #no-dhcp-interface=
  96. # On systems which support it, dnsmasq binds the wildcard address,
  97. # even when it is listening on only some interfaces. It then discards
  98. # requests that it shouldn't reply to. This has the advantage of
  99. # working even when interfaces come and go and change address. If you
  100. # want dnsmasq to really bind only the interfaces it is listening on,
  101. # uncomment this option. About the only time you may need this is when
  102. # running another nameserver on the same machine.
  103. #bind-interfaces
  104. # If you don't want dnsmasq to read /etc/hosts, uncomment the
  105. # following line.
  106. #no-hosts
  107. # or if you want it to read another file, as well as /etc/hosts, use
  108. # this.
  109. #addn-hosts=/etc/banner_add_hosts
  110. # Set this (and domain: see below) if you want to have a domain
  111. # automatically added to simple names in a hosts-file.
  112. #expand-hosts
  113. # Set the domain for dnsmasq. this is optional, but if it is set, it
  114. # does the following things.
  115. # 1) Allows DHCP hosts to have fully qualified domain names, as long
  116. # as the domain part matches this setting.
  117. # 2) Sets the "domain" DHCP option thereby potentially setting the
  118. # domain of all systems configured by DHCP
  119. # 3) Provides the domain part for "expand-hosts"
  120. #domain=thekelleys.org.uk
  121. # Set a different domain for a particular subnet
  122. #domain=wireless.thekelleys.org.uk,192.168.2.0/24
  123. # Same idea, but range rather then subnet
  124. #domain=reserved.thekelleys.org.uk,192.68.3.100,192.168.3.200
  125. # Uncomment this to enable the integrated DHCP server, you need
  126. # to supply the range of addresses available for lease and optionally
  127. # a lease time. If you have more than one network, you will need to
  128. # repeat this for each network on which you want to supply DHCP
  129. # service.
  130. #dhcp-range=192.168.0.50,192.168.0.150,12h
  131. # This is an example of a DHCP range where the netmask is given. This
  132. # is needed for networks we reach the dnsmasq DHCP server via a relay
  133. # agent. If you don't know what a DHCP relay agent is, you probably
  134. # don't need to worry about this.
  135. #dhcp-range=192.168.0.50,192.168.0.150,255.255.255.0,12h
  136. # This is an example of a DHCP range which sets a tag, so that
  137. # some DHCP options may be set only for this network.
  138. #dhcp-range=set:red,192.168.0.50,192.168.0.150
  139. # Use this DHCP range only when the tag "green" is set.
  140. #dhcp-range=tag:green,192.168.0.50,192.168.0.150,12h
  141. # Specify a subnet which can't be used for dynamic address allocation,
  142. # is available for hosts with matching --dhcp-host lines. Note that
  143. # dhcp-host declarations will be ignored unless there is a dhcp-range
  144. # of some type for the subnet in question.
  145. # In this case the netmask is implied (it comes from the network
  146. # configuration on the machine running dnsmasq) it is possible to give
  147. # an explicit netmask instead.
  148. #dhcp-range=192.168.0.0,static
  149. # Enable DHCPv6. Note that the prefix-length does not need to be specified
  150. # and defaults to 64 if missing/
  151. #dhcp-range=1234::2, 1234::500, 64, 12h
  152. # Do Router Advertisements, BUT NOT DHCP for this subnet.
  153. #dhcp-range=1234::, ra-only
  154. # Do Router Advertisements, BUT NOT DHCP for this subnet, also try and
  155. # add names to the DNS for the IPv6 address of SLAAC-configured dual-stack
  156. # hosts. Use the DHCPv4 lease to derive the name, network segment and
  157. # MAC address and assume that the host will also have an
  158. # IPv6 address calculated using the SLAAC alogrithm.
  159. #dhcp-range=1234::, ra-names
  160. # Do Router Advertisements, BUT NOT DHCP for this subnet.
  161. # Set the lifetime to 46 hours. (Note: minimum lifetime is 2 hours.)
  162. #dhcp-range=1234::, ra-only, 48h
  163. # Do DHCP and Router Advertisements for this subnet. Set the A bit in the RA
  164. # so that clients can use SLAAC addresses as well as DHCP ones.
  165. #dhcp-range=1234::2, 1234::500, slaac
  166. # Do Router Advertisements and stateless DHCP for this subnet. Clients will
  167. # not get addresses from DHCP, but they will get other configuration information.
  168. # They will use SLAAC for addresses.
  169. #dhcp-range=1234::, ra-stateless
  170. # Do stateless DHCP, SLAAC, and generate DNS names for SLAAC addresses
  171. # from DHCPv4 leases.
  172. #dhcp-range=1234::, ra-stateless, ra-names
  173. # Do router advertisements for all subnets where we're doing DHCPv6
  174. # Unless overriden by ra-stateless, ra-names, et al, the router
  175. # advertisements will have the M and O bits set, so that the clients
  176. # get addresses and configuration from DHCPv6, and the A bit reset, so the
  177. # clients don't use SLAAC addresses.
  178. #enable-ra
  179. # Supply parameters for specified hosts using DHCP. There are lots
  180. # of valid alternatives, so we will give examples of each. Note that
  181. # IP addresses DO NOT have to be in the range given above, they just
  182. # need to be on the same network. The order of the parameters in these
  183. # do not matter, it's permissible to give name, address and MAC in any
  184. # order.
  185. # Always allocate the host with Ethernet address 11:22:33:44:55:66
  186. # The IP address 192.168.0.60
  187. #dhcp-host=11:22:33:44:55:66,192.168.0.60
  188. # Always set the name of the host with hardware address
  189. # 11:22:33:44:55:66 to be "fred"
  190. #dhcp-host=11:22:33:44:55:66,fred
  191. # Always give the host with Ethernet address 11:22:33:44:55:66
  192. # the name fred and IP address 192.168.0.60 and lease time 45 minutes
  193. #dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m
  194. # Give a host with Ethernet address 11:22:33:44:55:66 or
  195. # 12:34:56:78:90:12 the IP address 192.168.0.60. Dnsmasq will assume
  196. # that these two Ethernet interfaces will never be in use at the same
  197. # time, and give the IP address to the second, even if it is already
  198. # in use by the first. Useful for laptops with wired and wireless
  199. # addresses.
  200. #dhcp-host=11:22:33:44:55:66,12:34:56:78:90:12,192.168.0.60
  201. # Give the machine which says its name is "bert" IP address
  202. # 192.168.0.70 and an infinite lease
  203. #dhcp-host=bert,192.168.0.70,infinite
  204. # Always give the host with client identifier 01:02:02:04
  205. # the IP address 192.168.0.60
  206. #dhcp-host=id:01:02:02:04,192.168.0.60
  207. # Always give the Infiniband interface with hardware address
  208. # 80:00:00:48:fe:80:00:00:00:00:00:00:f4:52:14:03:00:28:05:81 the
  209. # ip address 192.168.0.61. The client id is derived from the prefix
  210. # ff:00:00:00:00:00:02:00:00:02:c9:00 and the last 8 pairs of
  211. # hex digits of the hardware address.
  212. #dhcp-host=id:ff:00:00:00:00:00:02:00:00:02:c9:00:f4:52:14:03:00:28:05:81,192.168.0.61
  213. # Always give the host with client identifier "marjorie"
  214. # the IP address 192.168.0.60
  215. #dhcp-host=id:marjorie,192.168.0.60
  216. # Enable the address given for "judge" in /etc/hosts
  217. # to be given to a machine presenting the name "judge" when
  218. # it asks for a DHCP lease.
  219. #dhcp-host=judge
  220. # Never offer DHCP service to a machine whose Ethernet
  221. # address is 11:22:33:44:55:66
  222. #dhcp-host=11:22:33:44:55:66,ignore
  223. # Ignore any client-id presented by the machine with Ethernet
  224. # address 11:22:33:44:55:66. This is useful to prevent a machine
  225. # being treated differently when running under different OS's or
  226. # between PXE boot and OS boot.
  227. #dhcp-host=11:22:33:44:55:66,id:*
  228. # Send extra options which are tagged as "red" to
  229. # the machine with Ethernet address 11:22:33:44:55:66
  230. #dhcp-host=11:22:33:44:55:66,set:red
  231. # Send extra options which are tagged as "red" to
  232. # any machine with Ethernet address starting 11:22:33:
  233. #dhcp-host=11:22:33:*:*:*,set:red
  234. # Give a fixed IPv6 address and name to client with
  235. # DUID 00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2
  236. # Note the MAC addresses CANNOT be used to identify DHCPv6 clients.
  237. # Note also the they [] around the IPv6 address are obilgatory.
  238. #dhcp-host=id:00:01:00:01:16:d2:83:fc:92:d4:19:e2:d8:b2, fred, [1234::5]
  239. # Ignore any clients which are not specified in dhcp-host lines
  240. # or /etc/ethers. Equivalent to ISC "deny unknown-clients".
  241. # This relies on the special "known" tag which is set when
  242. # a host is matched.
  243. #dhcp-ignore=tag:!known
  244. # Send extra options which are tagged as "red" to any machine whose
  245. # DHCP vendorclass string includes the substring "Linux"
  246. #dhcp-vendorclass=set:red,Linux
  247. # Send extra options which are tagged as "red" to any machine one
  248. # of whose DHCP userclass strings includes the substring "accounts"
  249. #dhcp-userclass=set:red,accounts
  250. # Send extra options which are tagged as "red" to any machine whose
  251. # MAC address matches the pattern.
  252. #dhcp-mac=set:red,00:60:8C:*:*:*
  253. # If this line is uncommented, dnsmasq will read /etc/ethers and act
  254. # on the ethernet-address/IP pairs found there just as if they had
  255. # been given as --dhcp-host options. Useful if you keep
  256. # MAC-address/host mappings there for other purposes.
  257. #read-ethers
  258. # Send options to hosts which ask for a DHCP lease.
  259. # See RFC 2132 for details of available options.
  260. # Common options can be given to dnsmasq by name:
  261. # run "dnsmasq --help dhcp" to get a list.
  262. # Note that all the common settings, such as netmask and
  263. # broadcast address, DNS server and default route, are given
  264. # sane defaults by dnsmasq. You very likely will not need
  265. # any dhcp-options. If you use Windows clients and Samba, there
  266. # are some options which are recommended, they are detailed at the
  267. # end of this section.
  268. # Override the default route supplied by dnsmasq, which assumes the
  269. # router is the same machine as the one running dnsmasq.
  270. #dhcp-option=3,1.2.3.4
  271. # Do the same thing, but using the option name
  272. #dhcp-option=option:router,1.2.3.4
  273. # Override the default route supplied by dnsmasq and send no default
  274. # route at all. Note that this only works for the options sent by
  275. # default (1, 3, 6, 12, 28) the same line will send a zero-length option
  276. # for all other option numbers.
  277. #dhcp-option=3
  278. # Set the NTP time server addresses to 192.168.0.4 and 10.10.0.5
  279. #dhcp-option=option:ntp-server,192.168.0.4,10.10.0.5
  280. # Send DHCPv6 option. Note [] around IPv6 addresses.
  281. #dhcp-option=option6:dns-server,[1234::77],[1234::88]
  282. # Send DHCPv6 option for namservers as the machine running
  283. # dnsmasq and another.
  284. #dhcp-option=option6:dns-server,[::],[1234::88]
  285. # Ask client to poll for option changes every six hours. (RFC4242)
  286. #dhcp-option=option6:information-refresh-time,6h
  287. # Set option 58 client renewal time (T1). Defaults to half of the
  288. # lease time if not specified. (RFC2132)
  289. #dhcp-option=option:T1:1m
  290. # Set option 59 rebinding time (T2). Defaults to 7/8 of the
  291. # lease time if not specified. (RFC2132)
  292. #dhcp-option=option:T2:2m
  293. # Set the NTP time server address to be the same machine as
  294. # is running dnsmasq
  295. #dhcp-option=42,0.0.0.0
  296. # Set the NIS domain name to "welly"
  297. #dhcp-option=40,welly
  298. # Set the default time-to-live to 50
  299. #dhcp-option=23,50
  300. # Set the "all subnets are local" flag
  301. #dhcp-option=27,1
  302. # Send the etherboot magic flag and then etherboot options (a string).
  303. #dhcp-option=128,e4:45:74:68:00:00
  304. #dhcp-option=129,NIC=eepro100
  305. # Specify an option which will only be sent to the "red" network
  306. # (see dhcp-range for the declaration of the "red" network)
  307. # Note that the tag: part must precede the option: part.
  308. #dhcp-option = tag:red, option:ntp-server, 192.168.1.1
  309. # The following DHCP options set up dnsmasq in the same way as is specified
  310. # for the ISC dhcpcd in
  311. # http://www.samba.org/samba/ftp/docs/textdocs/DHCP-Server-Configuration.txt
  312. # adapted for a typical dnsmasq installation where the host running
  313. # dnsmasq is also the host running samba.
  314. # you may want to uncomment some or all of them if you use
  315. # Windows clients and Samba.
  316. #dhcp-option=19,0 # option ip-forwarding off
  317. #dhcp-option=44,0.0.0.0 # set netbios-over-TCP/IP nameserver(s) aka WINS server(s)
  318. #dhcp-option=45,0.0.0.0 # netbios datagram distribution server
  319. #dhcp-option=46,8 # netbios node type
  320. # Send an empty WPAD option. This may be REQUIRED to get windows 7 to behave.
  321. #dhcp-option=252,"\n"
  322. # Send RFC-3397 DNS domain search DHCP option. WARNING: Your DHCP client
  323. # probably doesn't support this......
  324. #dhcp-option=option:domain-search,eng.apple.com,marketing.apple.com
  325. # Send RFC-3442 classless static routes (note the netmask encoding)
  326. #dhcp-option=121,192.168.1.0/24,1.2.3.4,10.0.0.0/8,5.6.7.8
  327. # Send vendor-class specific options encapsulated in DHCP option 43.
  328. # The meaning of the options is defined by the vendor-class so
  329. # options are sent only when the client supplied vendor class
  330. # matches the class given here. (A substring match is OK, so "MSFT"
  331. # matches "MSFT" and "MSFT 5.0"). This example sets the
  332. # mtftp address to 0.0.0.0 for PXEClients.
  333. #dhcp-option=vendor:PXEClient,1,0.0.0.0
  334. # Send microsoft-specific option to tell windows to release the DHCP lease
  335. # when it shuts down. Note the "i" flag, to tell dnsmasq to send the
  336. # value as a four-byte integer - that's what microsoft wants. See
  337. # http://technet2.microsoft.com/WindowsServer/en/library/a70f1bb7-d2d4-49f0-96d6-4b7414ecfaae1033.mspx?mfr=true
  338. #dhcp-option=vendor:MSFT,2,1i
  339. # Send the Encapsulated-vendor-class ID needed by some configurations of
  340. # Etherboot to allow is to recognise the DHCP server.
  341. #dhcp-option=vendor:Etherboot,60,"Etherboot"
  342. # Send options to PXELinux. Note that we need to send the options even
  343. # though they don't appear in the parameter request list, so we need
  344. # to use dhcp-option-force here.
  345. # See http://syslinux.zytor.com/pxe.php#special for details.
  346. # Magic number - needed before anything else is recognised
  347. #dhcp-option-force=208,f1:00:74:7e
  348. # Configuration file name
  349. #dhcp-option-force=209,configs/common
  350. # Path prefix
  351. #dhcp-option-force=210,/tftpboot/pxelinux/files/
  352. # Reboot time. (Note 'i' to send 32-bit value)
  353. #dhcp-option-force=211,30i
  354. # Set the boot filename for netboot/PXE. You will only need
  355. # this is you want to boot machines over the network and you will need
  356. # a TFTP server; either dnsmasq's built in TFTP server or an
  357. # external one. (See below for how to enable the TFTP server.)
  358. #dhcp-boot=pxelinux.0
  359. # The same as above, but use custom tftp-server instead machine running dnsmasq
  360. #dhcp-boot=pxelinux,server.name,192.168.1.100
  361. # Boot for Etherboot gPXE. The idea is to send two different
  362. # filenames, the first loads gPXE, and the second tells gPXE what to
  363. # load. The dhcp-match sets the gpxe tag for requests from gPXE.
  364. #dhcp-match=set:gpxe,175 # gPXE sends a 175 option.
  365. #dhcp-boot=tag:!gpxe,undionly.kpxe
  366. #dhcp-boot=mybootimage
  367. # Encapsulated options for Etherboot gPXE. All the options are
  368. # encapsulated within option 175
  369. #dhcp-option=encap:175, 1, 5b # priority code
  370. #dhcp-option=encap:175, 176, 1b # no-proxydhcp
  371. #dhcp-option=encap:175, 177, string # bus-id
  372. #dhcp-option=encap:175, 189, 1b # BIOS drive code
  373. #dhcp-option=encap:175, 190, user # iSCSI username
  374. #dhcp-option=encap:175, 191, pass # iSCSI password
  375. # Test for the architecture of a netboot client. PXE clients are
  376. # supposed to send their architecture as option 93. (See RFC 4578)
  377. #dhcp-match=peecees, option:client-arch, 0 #x86-32
  378. #dhcp-match=itanics, option:client-arch, 2 #IA64
  379. #dhcp-match=hammers, option:client-arch, 6 #x86-64
  380. #dhcp-match=mactels, option:client-arch, 7 #EFI x86-64
  381. # Do real PXE, rather than just booting a single file, this is an
  382. # alternative to dhcp-boot.
  383. #pxe-prompt="What system shall I netboot?"
  384. # or with timeout before first available action is taken:
  385. #pxe-prompt="Press F8 for menu.", 60
  386. # Available boot services. for PXE.
  387. #pxe-service=x86PC, "Boot from local disk"
  388. # Loads <tftp-root>/pxelinux.0 from dnsmasq TFTP server.
  389. #pxe-service=x86PC, "Install Linux", pxelinux
  390. # Loads <tftp-root>/pxelinux.0 from TFTP server at 1.2.3.4.
  391. # Beware this fails on old PXE ROMS.
  392. #pxe-service=x86PC, "Install Linux", pxelinux, 1.2.3.4
  393. # Use bootserver on network, found my multicast or broadcast.
  394. #pxe-service=x86PC, "Install windows from RIS server", 1
  395. # Use bootserver at a known IP address.
  396. #pxe-service=x86PC, "Install windows from RIS server", 1, 1.2.3.4
  397. # If you have multicast-FTP available,
  398. # information for that can be passed in a similar way using options 1
  399. # to 5. See page 19 of
  400. # http://download.intel.com/design/archives/wfm/downloads/pxespec.pdf
  401. # Enable dnsmasq's built-in TFTP server
  402. #enable-tftp
  403. # Set the root directory for files available via FTP.
  404. #tftp-root=/var/ftpd
  405. # Do not abort if the tftp-root is unavailable
  406. #tftp-no-fail
  407. # Make the TFTP server more secure: with this set, only files owned by
  408. # the user dnsmasq is running as will be send over the net.
  409. #tftp-secure
  410. # This option stops dnsmasq from negotiating a larger blocksize for TFTP
  411. # transfers. It will slow things down, but may rescue some broken TFTP
  412. # clients.
  413. #tftp-no-blocksize
  414. # Set the boot file name only when the "red" tag is set.
  415. #dhcp-boot=tag:red,pxelinux.red-net
  416. # An example of dhcp-boot with an external TFTP server: the name and IP
  417. # address of the server are given after the filename.
  418. # Can fail with old PXE ROMS. Overridden by --pxe-service.
  419. #dhcp-boot=/var/ftpd/pxelinux.0,boothost,192.168.0.3
  420. # If there are multiple external tftp servers having a same name
  421. # (using /etc/hosts) then that name can be specified as the
  422. # tftp_servername (the third option to dhcp-boot) and in that
  423. # case dnsmasq resolves this name and returns the resultant IP
  424. # addresses in round robin fasion. This facility can be used to
  425. # load balance the tftp load among a set of servers.
  426. #dhcp-boot=/var/ftpd/pxelinux.0,boothost,tftp_server_name
  427. # Set the limit on DHCP leases, the default is 150
  428. #dhcp-lease-max=150
  429. # The DHCP server needs somewhere on disk to keep its lease database.
  430. # This defaults to a sane location, but if you want to change it, use
  431. # the line below.
  432. #dhcp-leasefile=/var/lib/misc/dnsmasq.leases
  433. # Set the DHCP server to authoritative mode. In this mode it will barge in
  434. # and take over the lease for any client which broadcasts on the network,
  435. # whether it has a record of the lease or not. This avoids long timeouts
  436. # when a machine wakes up on a new network. DO NOT enable this if there's
  437. # the slightest chance that you might end up accidentally configuring a DHCP
  438. # server for your campus/company accidentally. The ISC server uses
  439. # the same option, and this URL provides more information:
  440. # http://www.isc.org/files/auth.html
  441. #dhcp-authoritative
  442. # Run an executable when a DHCP lease is created or destroyed.
  443. # The arguments sent to the script are "add" or "del",
  444. # then the MAC address, the IP address and finally the hostname
  445. # if there is one.
  446. #dhcp-script=/bin/echo
  447. # Set the cachesize here.
  448. #cache-size=150
  449. # If you want to disable negative caching, uncomment this.
  450. #no-negcache
  451. # Normally responses which come from /etc/hosts and the DHCP lease
  452. # file have Time-To-Live set as zero, which conventionally means
  453. # do not cache further. If you are happy to trade lower load on the
  454. # server for potentially stale date, you can set a time-to-live (in
  455. # seconds) here.
  456. #local-ttl=
  457. # If you want dnsmasq to detect attempts by Verisign to send queries
  458. # to unregistered .com and .net hosts to its sitefinder service and
  459. # have dnsmasq instead return the correct NXDOMAIN response, uncomment
  460. # this line. You can add similar lines to do the same for other
  461. # registries which have implemented wildcard A records.
  462. #bogus-nxdomain=64.94.110.11
  463. # If you want to fix up DNS results from upstream servers, use the
  464. # alias option. This only works for IPv4.
  465. # This alias makes a result of 1.2.3.4 appear as 5.6.7.8
  466. #alias=1.2.3.4,5.6.7.8
  467. # and this maps 1.2.3.x to 5.6.7.x
  468. #alias=1.2.3.0,5.6.7.0,255.255.255.0
  469. # and this maps 192.168.0.10->192.168.0.40 to 10.0.0.10->10.0.0.40
  470. #alias=192.168.0.10-192.168.0.40,10.0.0.0,255.255.255.0
  471. # Change these lines if you want dnsmasq to serve MX records.
  472. # Return an MX record named "maildomain.com" with target
  473. # servermachine.com and preference 50
  474. #mx-host=maildomain.com,servermachine.com,50
  475. # Set the default target for MX records created using the localmx option.
  476. #mx-target=servermachine.com
  477. # Return an MX record pointing to the mx-target for all local
  478. # machines.
  479. #localmx
  480. # Return an MX record pointing to itself for all local machines.
  481. #selfmx
  482. # Change the following lines if you want dnsmasq to serve SRV
  483. # records. These are useful if you want to serve ldap requests for
  484. # Active Directory and other windows-originated DNS requests.
  485. # See RFC 2782.
  486. # You may add multiple srv-host lines.
  487. # The fields are <name>,<target>,<port>,<priority>,<weight>
  488. # If the domain part if missing from the name (so that is just has the
  489. # service and protocol sections) then the domain given by the domain=
  490. # config option is used. (Note that expand-hosts does not need to be
  491. # set for this to work.)
  492. # A SRV record sending LDAP for the example.com domain to
  493. # ldapserver.example.com port 389
  494. #srv-host=_ldap._tcp.example.com,ldapserver.example.com,389
  495. # A SRV record sending LDAP for the example.com domain to
  496. # ldapserver.example.com port 389 (using domain=)
  497. #domain=example.com
  498. #srv-host=_ldap._tcp,ldapserver.example.com,389
  499. # Two SRV records for LDAP, each with different priorities
  500. #srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,1
  501. #srv-host=_ldap._tcp.example.com,ldapserver.example.com,389,2
  502. # A SRV record indicating that there is no LDAP server for the domain
  503. # example.com
  504. #srv-host=_ldap._tcp.example.com
  505. # The following line shows how to make dnsmasq serve an arbitrary PTR
  506. # record. This is useful for DNS-SD. (Note that the
  507. # domain-name expansion done for SRV records _does_not
  508. # occur for PTR records.)
  509. #ptr-record=_http._tcp.dns-sd-services,"New Employee Page._http._tcp.dns-sd-services"
  510. # Change the following lines to enable dnsmasq to serve TXT records.
  511. # These are used for things like SPF and zeroconf. (Note that the
  512. # domain-name expansion done for SRV records _does_not
  513. # occur for TXT records.)
  514. #Example SPF.
  515. #txt-record=example.com,"v=spf1 a -all"
  516. #Example zeroconf
  517. #txt-record=_http._tcp.example.com,name=value,paper=A4
  518. # Provide an alias for a "local" DNS name. Note that this _only_ works
  519. # for targets which are names from DHCP or /etc/hosts. Give host
  520. # "bert" another name, bertrand
  521. #cname=bertand,bert
  522. # For debugging purposes, log each DNS query as it passes through
  523. # dnsmasq.
  524. #log-queries
  525. # Log lots of extra information about DHCP transactions.
  526. #log-dhcp
  527. # Include another lot of configuration options.
  528. #conf-file=/etc/dnsmasq.more.conf
  529. #conf-dir=/etc/dnsmasq.d
  530. # Include all the files in a directory except those ending in .bak
  531. #conf-dir=/etc/dnsmasq.d,.bak
  532. # Include all files in a directory which end in .conf
  533. #conf-dir=/etc/dnsmasq.d/,*.conf
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注