dnsmasq

Dnsmaq-2.48使用帮助信息


dnsmaq支持一包软件代码集合了TFTP Server,DHCP Server, DHCPv6 Server, DNS Server等多种Server服务功能。实际上要启用的支持的Server服务集要在编译时进行配置,可执行二进制文件生成之后支持的Server能力集就已经确定无法更改。
dnsmasq支持大量命令行Option选项,在串口中执行命令'dnsmasq --help'可以查看所有选项的帮助信息,其中一些命令行选项可以很方便的用于问题Debug&TroubeShoot.
root@/tmp# dnsmasq --help
Usage: dnsmasq [options]

Valid options are:
-a, --listen-address=<ipaddr>                          Specify local address(es) to listen on.
-A, --address=/<domain>/<ipaddr>                       Return ipaddr for all hosts in specified domains.
-b, --bogus-priv                                       Fake reverse lookups for RFC1918 private address ranges.
-B, --bogus-nxdomain=<ipaddr>                          Treat ipaddr as NXDOMAIN (defeats Verisign wildcard).
-c, --cache-size=<integer>                             Specify the size of the cache in entries (defaults to 150).
-C, --conf-file=<path>                                 Specify configuration file (defaults to /etc/dnsmasq.conf).
-d, --no-daemon                                        Do NOT fork into the background: run in debug mode.
-D, --domain-needed                                    Do NOT forward queries with no domain part.
-e, --selfmx                                           Return self-pointing MX records for local hosts.
-E, --expand-hosts                                     Expand simple names in /etc/hosts with domain-suffix.
-f, --filterwin2k                                      Don't forward spurious DNS requests from Windows hosts.
-F, --dhcp-range=<ipaddr>,...                          Enable DHCP in the range given with lease duration.
-g, --group=<groupname>                                Change to this group after startup (defaults to dip).
-G, --dhcp-host=<hostspec>                             Set address or hostname for a specified machine.
    --dhcp-hostsfile=<path>                            Read DHCP host specs from file.
    --dhcp-optsfile=<path>                             Read DHCP option specs from file.
    --dhcp-hostsdir=<path>                             Read DHCP host specs from a directory.
    --dhcp-optsdir=<path>                              Read DHCP options from a directory.
    --tag-if=tag-expression                            Evaluate conditional tag expression.
-h, --no-hosts                                         Do NOT load /etc/hosts file.
-H, --addn-hosts=<path>                                Specify a hosts file to be read in addition to /etc/hosts.
    --hostsdir=<path>                                  Read hosts files from a directory.
-i, --interface=<interface>                            Specify interface(s) to listen on.
-I, --except-interface=<interface>                     Specify interface(s) NOT to listen on.
-j, --dhcp-userclass=set:<tag>,<class>                 Map DHCP user class to tag.
    --dhcp-circuitid=set:<tag>,<circuit>               Map RFC3046 circuit-id to tag.
    --dhcp-remoteid=set:<tag>,<remote>                 Map RFC3046 remote-id to tag.
    --dhcp-subscrid=set:<tag>,<remote>                 Map RFC3993 subscriber-id to tag.
-J, --dhcp-ignore=tag:<tag>...                         Don't do DHCP for hosts with tag set.
    --dhcp-broadcast[=tag:<tag>...]                    Force broadcast replies for hosts with tag set.
-k, --keep-in-foreground                               Do NOT fork into the background, do NOT run in debug mode.
-K, --dhcp-authoritative                               Assume we are the only DHCP server on the local network.
-l, --dhcp-leasefile=<path>                            Specify where to store DHCP leases (defaults to /var/lib/misc/dnsmasq.leases).
-L, --localmx                                          Return MX records for local hosts.
-m, --mx-host=<host_name>,<target>,<pref>              Specify an MX record.
-M, --dhcp-boot=<bootp opts>                           Specify BOOTP options to DHCP server.
-n, --no-poll                                          Do NOT poll /etc/resolv.conf file, reload only on SIGHUP.
-N, --no-negcache                                      Do NOT cache failed search results.
-o, --strict-order                                     Use nameservers strictly in the order given in /etc/resolv.conf.
-O, --dhcp-option=<optspec>                            Specify options to be sent to DHCP clients.
    --dhcp-option-force=<optspec>                      DHCP option sent even if the client does not request it.
-p, --port=<integer>                                   Specify port to listen for DNS requests on (defaults to 53).
-P, --edns-packet-max=<integer>                        Maximum supported UDP packet size for EDNS.0 (defaults to 4096).
-q, --log-queries                                      Log DNS queries.
-Q, --query-port=<integer>                             Force the originating port for upstream DNS queries.
-R, --no-resolv                                        Do NOT read resolv.conf.
-r, --resolv-file=<path>                               Specify path to resolv.conf (defaults to /etc/resolv.conf).
    --servers-file=<path>                              Specify path to file with server= options
-S, --server=/<domain>/<ipaddr>                        Specify address(es) of upstream servers with optional domains.
    --rev-server=<addr>/<prefix>,<ipaddr>              Specify address of upstream servers for reverse address queries
    --local=/<domain>/                                 Never forward queries to specified domains.
-s, --domain=<domain>[,<range>]                        Specify the domain to be assigned in DHCP leases.
-t, --mx-target=<host_name>                            Specify default target in an MX record.
-T, --local-ttl=<integer>                              Specify time-to-live in seconds for replies from /etc/hosts.
    --neg-ttl=<integer>                                Specify time-to-live in seconds for negative caching.
    --max-ttl=<integer>                                Specify time-to-live in seconds for maximum TTL to send to clients.
    --max-cache-ttl=<integer>                          Specify time-to-live ceiling for cache.
    --min-cache-ttl=<integer>                          Specify time-to-live floor for cache.
-u, --user=<username>                                  Change to this user after startup. (defaults to nobody).
-U, --dhcp-vendorclass=set:<tag>,<class>               Map DHCP vendor class to tag.
-v, --version                                          Display dnsmasq version and copyright information.
-V, --alias=<ipaddr>,<ipaddr>,<netmask>                Translate IPv4 addresses from upstream servers.
-W, --srv-host=<name>,<target>,...                     Specify a SRV record.
-w, --help                                             Display this message. Use --help dhcp or --help dhcp6 for known DHCP options.
-x, --pid-file=<path>                                  Specify path of PID file (defaults to /var/run/dnsmasq.pid).
-X, --dhcp-lease-max=<integer>                         Specify maximum number of DHCP leases (defaults to 1000).
-y, --localise-queries                                 Answer DNS queries based on the interface a query was sent to.
-Y, --txt-record=<name>,<txt>[,<txt]                   Specify TXT DNS record.
    --ptr-record=<name>,<target>                       Specify PTR DNS record.
    --interface-name=<name>,<interface>                Give DNS name to IPv4 address of interface.
-z, --bind-interfaces                                  Bind only to interfaces in use.
-Z, --read-ethers                                      Read DHCP static host information from /etc/ethers.
-1, --enable-dbus[=<busname>]                          Enable the DBus interface for setting upstream servers, etc.
    --enable-ubus                                      Enable the UBus interface.
-2, --no-dhcp-interface=<interface>                    Do not provide DHCP on this interface, only provide DNS.
-3, --bootp-dynamic[=tag:<tag>]...                     Enable dynamic address allocation for bootp.
-4, --dhcp-mac=set:<tag>,<mac address>                 Map MAC address (with wildcards) to option set.
    --bridge-interface=<iface>,<alias>..               Treat DHCP requests on aliases as arriving from interface.
-5, --no-ping                                          Disable ICMP echo address checking in the DHCP server.
-6, --dhcp-script=<path>                               Shell script to run on DHCP lease creation and destruction.
    --dhcp-luascript=path                              Lua script to run on DHCP lease creation and destruction.
    --dhcp-scriptuser=<username>                       Run lease-change scripts as this user.
    --script-arp                                       Call dhcp-script with changes to local ARP table.
-7, --conf-dir=<path>                                  Read configuration from all the files in this directory.
-8, --log-facility=<facility>|<file>                   Log to this syslog facility or file. (defaults to DAEMON)
-9, --leasefile-ro                                     Do not use leasefile.
-0, --dns-forward-max=<integer>                        Maximum number of concurrent DNS queries. (defaults to 150)
    --clear-on-reload                                  Clear DNS cache when reloading /etc/resolv.conf.
    --dhcp-ignore-names[=tag:<tag>]...                 Ignore hostnames provided by DHCP clients.
    --dhcp-no-override                                 Do NOT reuse filename and server fields for extra DHCP options.
    --enable-tftp[=<intr>[,<intr>]]                    Enable integrated read-only TFTP server.
    --tftp-root=<dir>[,<iface>]                        Export files by TFTP only from the specified subtree.
    --tftp-unique-root[=ip|mac]                        Add client IP or hardware address to tftp-root.
    --tftp-secure                                      Allow access only to files owned by the user running dnsmasq.
    --tftp-no-fail                                     Do not terminate the service if TFTP directories are inaccessible.
    --tftp-max=<integer>                               Maximum number of concurrent TFTP transfers (defaults to 50).
    --tftp-mtu=<integer>                               Maximum MTU to use for TFTP transfers.
    --tftp-no-blocksize                                Disable the TFTP blocksize extension.
    --tftp-lowercase                                   Convert TFTP filenames to lowercase
    --tftp-port-range=<start>,<end>                    Ephemeral port range for use by TFTP transfers.
    --log-dhcp                                         Extra logging for DHCP.
    --log-async[=<integer>]                            Enable async. logging; optionally set queue length.
    --stop-dns-rebind                                  Stop DNS rebinding. Filter private IP ranges when resolving.
    --rebind-localhost-ok                              Allow rebinding of 127.0.0.0/8, for RBL servers.
    --rebind-domain-ok=/<domain>/                      Inhibit DNS-rebind protection on this domain.
    --all-servers                                      Always perform DNS queries to all servers.
    --dhcp-match=set:<tag>,<optspec>                   Set tag if client includes matching option in request.
    --dhcp-name-match=set:<tag>,<string>[*]            Set tag if client provides given name.
    --dhcp-alternate-port[=<ports>]                    Use alternative ports for DHCP.
    --naptr-record=<name>,<naptr>                      Specify NAPTR DNS record.
    --min-port=<port>                                  Specify lowest port available for DNS query transmission.
    --max-port=<port>                                  Specify highest port available for DNS query transmission.
    --dhcp-fqdn                                        Use only fully qualified domain names for DHCP clients.
    --dhcp-generate-names[=tag:<tag>]                  Generate hostnames based on MAC address for nameless clients.
    --dhcp-proxy[=<ipaddr>]...                         Use these DHCP relays as full proxies.
    --dhcp-relay=<local-addr>,<server>[,<iface>]       Relay DHCP requests to a remote server
    --cname=<alias>,<target>[,<ttl>]                   Specify alias name for LOCAL DNS name.
    --pxe-prompt=<prompt>,[<timeout>]                  Prompt to send to PXE clients.
    --pxe-service=<service>                            Boot service for PXE menu.
    --test                                             Check configuration syntax.
    --add-mac[=base64|text]                            Add requestor's MAC address to forwarded DNS queries.
    --add-subnet=<v4 pref>[,<v6 pref>]                 Add specified IP subnet to forwarded DNS queries.
    --add-cpe-id=<text>                                Add client identification to forwarded DNS queries.
    --proxy-dnssec                                     Proxy DNSSEC validation results from upstream nameservers.
    --dhcp-sequential-ip                               Attempt to allocate sequential IP addresses to DHCP clients.
    --conntrack                                        Copy connection-track mark from queries to upstream connections.
    --dhcp-client-update                               Allow DHCP clients to do their own DDNS updates.
    --enable-ra                                        Send router-advertisements for interfaces doing DHCPv6
    --dhcp-duid=<enterprise>,<duid>                    Specify DUID_EN-type DHCPv6 server DUID
    --host-record=<name>,<address>[,<ttl>]             Specify host (A/AAAA and PTR) records
    --caa-record=<name>,<flags>,<tag>,<value>          Specify certification authority authorization record
    --dns-rr=<name>,<RR-number>,[<data>]               Specify arbitrary DNS resource record
    --bind-dynamic                                     Bind to interfaces in use - check for new interfaces
    --auth-server=<NS>,<interface>                     Export local names to global DNS
    --auth-zone=<domain>,[<subnet>...]                 Domain to export to global DNS
    --auth-ttl=<integer>                               Set TTL for authoritative replies
    --auth-soa=<serial>[,...]                          Set authoritative zone information
    --auth-sec-servers=<NS>[,<NS>...]                  Secondary authoritative nameservers for forward domains
    --auth-peer=<ipaddr>[,<ipaddr>...]                 Peers which are allowed to do zone transfer
    --ipset=/<domain>[/<domain>...]/<ipset>...         Specify ipsets to which matching domains should be added
    --synth-domain=<domain>,<range>,[<prefix>]         Specify a domain and address range for synthesised names
    --dnssec                                           Activate DNSSEC validation
    --trust-anchor=<domain>,[<class>],...              Specify trust anchor key digest.
    --dnssec-debug                                     Disable upstream checking for DNSSEC debugging.
    --dnssec-check-unsigned                            Ensure answers without DNSSEC are in unsigned zones.
    --dnssec-no-timecheck                              Don't check DNSSEC signature timestamps until first cache-reload
    --dnssec-timestamp=<path>                          Timestamp file to verify system clock for DNSSEC
    --ra-param=<iface>,[mtu:<value>|<interface>|off,][<Set MTU, priority, resend-interval and router-lifetime
    --quiet-dhcp                                       Do not log routine DHCP.
    --quiet-dhcp6                                      Do not log routine DHCPv6.
    --quiet-ra                                         Do not log RA.
    --local-service                                    Accept queries only from directly-connected networks.
    --dns-loop-detect                                  Detect and remove DNS forwarding loops.
    --ignore-address=<ipaddr>                          Ignore DNS responses containing ipaddr.
    --dhcp-ttl=<ttl>                                   Set TTL in DNS responses with DHCP-derived addresses.
    --dhcp-reply-delay=<integer>                       Delay DHCP replies for at least number of seconds.
    --dhcp-rapid-commit                                Enables DHCPv4 Rapid Commit option.
    --dumpfile=<path>                                  Path to debug packet dump file
    --dumpmask=<hex>                                   Mask which packets to dump
    --stbenable=stbenable                              STB DHCP enable
    --stbminaddress=stbminaddress                      STB assign min address
    --stbmaxaddress=stbmaxaddress                      STB assign max address
    --phoneenable=phoneenable                          PHONE DHCP enable
    --phoneminaddress=phoneminaddress                  PHONE assign min address
    --phonemaxaddress=phonemaxaddress                  PHONE assign max address
    --cameraenable=cameraenable                        CAMERA DHCP enable
    --cameraminaddress=cameraminaddress                CAMERA assign min address
    --cameramaxaddress=cameramaxaddress                CAMERA assign max address
    --computerenable=computerenable                    COMPUTER DHCP enable
    --computerminaddress=computerminaddress            COMPUTER assign min address
    --computermaxaddress=computermaxaddress            COMPUTER assign max address
root@/tmp# 

Dnsmasq2.48开启debug,查看DNS打印信息


'dnsmasq -d -q'或'dnsmasq -d --log-queries'启用log打印
命令行选项: '-d'表示不变为后台进程,并且运行在debug模式,'-q'表示打印出DNS Queries包的Log信息.
使用命令'dnsmasq -d --log-queries=extra',设置'--log-queries'值为'extra’,会打印出额外的DNS Query包Source Port, Source IP Address的信息

dnsmasq 在运行时会打印收到的DNS Query包内容,dnsmasq包对DNS Query向上级DNS Serveer转发Query请求包,和处理DNS Reply包的流程
dnsmasq: 52 127.0.0.1/46996 query[A] www.ok.com from 127.0.0.1
dnsmasq: 52 127.0.0.1/46996 forwarded www.ok.com to 10.10.171.100
dnsmasq: 52 127.0.0.1/46996 forwarded www.ok.com to 10.10.171.199
dnsmasq: 55 fe80::2100:2c40:30e0:a0e4%br0/65345 query[A] bp.conf2.f.360.cn from fe80::2100:2c40:30e0:a0e4
dnsmasq: 55 fe80::2100:2c40:30e0:a0e4%br0/65345 forwarded bp.conf2.f.360.cn to 10.10.171.100
dnsmasq: 55 fe80::2100:2c40:30e0:a0e4%br0/65345 forwarded bp.conf2.f.360.cn to 10.10.171.199


启用--dumpfile 抓取保存包tcpdump格式数据包内容


dnsmasq -d --log-queries --dumpfile=/tmp/test.pcap --dumpmask 0xff
--dumpfile /tmp/test.pcap,抓取到的DNS数据包保存到指定文件
--dumpmask 0xff, 掩码0xff表示抓取所有的包,mask 0x00表示不匹配抓取任何包

抓取到的数据包'/tmp/test.pcap',可以用tftp或者U盘把文件导出到PC上用Wirshark打开分析
cd /tmp
tftp -p -l /tmp/test.pcap 192.168.101.100
PC 上用Wireshark打开保存的抓取包内容,如下:
因为Dnsmasq通过socket收到DNS Query请求包时,只能通过RecvMsg()函数的controlMsg辅助信息知道数据包的源IP地址地址,所以对于dnsmqsq收到的DNS Query请求包会打印出源IP,目的IP都显示为'0.0.0.0'。
同理对Dnsmasq转发到WAN侧DNS Query包,发送的时候DNS Masq只知道目的IP地址,源IP地址显示为'0.0.0.0 '


标准C库函数getaddrinfo() 与 /etc/resolv.conf 和 dnsmasq-2.48服务的关系


POSIX标准要求C库函数提供API getaddrinfo(), getAddrinfo()支持从域名<domin>到IP address的解析。哪标准C库函数'getaddrinfo()'解析域名的实现和标准系统文件'/etc/resolve'和dnsmasq-2.48提供的DNS解析服务的关系是怎么样的哪?


库函数'getaddrinfo()'又是怎么实现域名到IP地址的解析的哪?
阅读了uClibc C函数库中的getaddrinfo.c文件,查看uClibc C语言库中getaddrinfo.c文件实现的源代码,发现当传递给getaddrinfo()函数的参数是<domain>域名格式的字符串时,getaddrinfo()会调用uClibc库中的gethostbyname()来实现域名到IP的解析。
uClibc C语言库中函数 gethostbyname()会首先查新系统本的'/etc/hosts'文件,查看要解析的域名是否在hosts文件中,若在就返回hosts文件中记录。若不在gethostbyname()就进行下一步,调用DNS query请求。
uClibc C语言库中函数 gethostbyname(),查询系统标准文件'/etc/resolv.conf',在系统标准文件'/etc/resolv'中定义的需要把DNS Query请求转发到的DNS Server地址。
dnsmaq.2.48自带的resolv.conf,并且被拷贝都系统'/etc/resolv.conf'位置,内容如下:
root:/sbin # cat /etc/resolv.conf 
nameserver 127.0.0.1
root:/sbin #
指定'gethostbyname()’把DNS Query请求包转发到本机IP地址: 127.0.0.1,这样就被dnsmasq-2.48 的DNS解析服务监听到。
查询man 手册‘man resolver’, ' man resolv.conf'获取更多细节信息
/etc/hosts 文件的标准格式
'/etc/hosts'文件是一个计算机发展历史上早期的一个域名和Host IP对应关系文件,其文件格式被RFC952文档标准化。在DNS技术出现之前,域名和IP Host的对应关系记录在这个文件中。
当前Linux系统的dnsmasq-2.48按照惯例,还会读取这个'/etc/hosts'文件,获取本地的local domain 域名和IP Host关系。
其文件格式为:
<IP> <Domain> <Alias>

 例如:
 192.168.101.2 dimon.com dimon
 192.168.101.3 aiyou.com 
 70.0.0.1      yoo.com   yoo
 #Hosts 文件也支持IPv6 地址
 3001::1       dimon.com dimon 
 3001::1       lily.com 
dnsmasq默认读取系统/etc/hosts,使用--addn-hosts指定额外的hosts文件实现一个域名对应多个Host IP
dnsmasq-2.48在启动时默认读取系统'/etc/hosts'获取本地的local域名和IP地址对应记录。
系统'/etc/hosts'文件的格式是标准格式,由RFC规范规定,一般形式为:
 <IP>  <Domain> <Alias>
 例如:
 192.168.101.2 dimon.com dimon
 192.168.101.3 aiyou.com 
 70.0.0.1      yoo.com   yoo
 这种格式的/etc/hosts文件中,一个<domain>域名只能对应一个<IP>地址。并且一个<domain>在/etc/hosts文件中只能出现一次。
如果一个<domain>对应多个<IP>地址,通过'man dnsmasq'查询man手册,发现可以通过 --addn-hosts 选型指定多个hosts文件实现

 例子:
 echo "70.0.0.1 dimon.com dimon" >/etc/hosts
 echo "70.0.0.2 dimon.com dimon" >/etc/hosts1
 echo "70.0.0.3 dimon.com dimon" >/etc/hosts2
 echo "70.0.0.4 dimon.com dimon" >/etc/hosts3
 dnsmasq -d -q --addn-hosts=/etc/hosts1 --addn-hosts=/etc/hosts2  --addn-hosts=/etc/hosts3
 
 使用 --addn-options 指定了三个额外的hosts文件,'/etc/hosts1/', '/etc/hosts2', '/etc/hosts3',Dnsmasq-2.48启动时读取除默认系统‘/etc/hosts’外,还会读取指定的额外hosts文件,在额外的hosts文件里对同一个域名'dimon.com'定义了不同的'IP'地址。
  dnsmasq.2.48通过读取这些Hosts文件,获取到同一个<domain>域名对应多个IP的信息。从而在收到对'dimon.com'的域名解析服务时,回复多个域名对应的IP地址。
启用-T 选项 指定/etc/hosts中的local domain的生命周期TTL
dnsmasq-2.48启动时会读取系统默认'/etc/hosts'文件,获取local domain信息更新到dnsmasq-2.48信息库中,默认的hosts中的域名的生命周期TTL为0,这样DNS Resolver解析者收到TTL=0的域名解析结果时就不会再cache中缓存这条TTL=0的域名解析记录。
可以通过 '-T xx' 选型修改默认的'/etc/hosts'中的local域名的默认TTL生命周期,单位为秒(s).

指定/etc/hosts中的local domain域名项的生命周期TTL=300s
dnsmasq -T 300

启用--address 选项 实现特定域名解析到指定IP Address


dnsmaq.2.48支持使用'--address=/domain/[domain/]<ipaddr>' 选项,实现对指定‘Domain Space’域名空间的域名解析请求Domain Query都回复指定的 ipaddr 地址。特殊的'/#/'域名'#'表示匹配所有的域名。
例子:

网关通过TR069认证之前,使得所有DNS解析的URL都重庆向到192.168.101.1 (URL重定向其中一种实现方法,网页重定向也可以使用Iptables masque 规则实现)
dnsmas --address=/#/192.168.101.1
/# ping sina.com
PING sina.com (192.168.101.1): 56 data bytes
64 bytes from 192.168.101.1: seq=0 ttl=64 time=0.253 ms
64 bytes from 192.168.101.1: seq=1 ttl=64 time=1.591 ms
--- sina.com ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.000/0.212/0.000 ms
/# ping baidu.com
PING baidu.com (192.168.101.1): 56 data bytes
64 bytes from 192.168.101.1: seq=0 ttl=64 time=0.287 ms
64 bytes from 192.168.101.1: seq=1 ttl=64 time=0.292 ms
--- baidu.com ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 0.000/0.187/0.000 ms
/#
访问所有的'*.dimon.com'域名的DNS Query请求,都解析为IP地址192.168.101.100
dnsmasq --address=/dimon.com/192.168.101.100
/# ping a.dimon.com
PING a.dimon.com (192.168.101.100): 56 data bytes
64 bytes from 192.168.101.100: seq=0 ttl=64 time=0.509 ms
64 bytes from 192.168.101.100: seq=1 ttl=64 time=0.399 ms
64 bytes from 192.168.101.100: seq=2 ttl=64 time=0.446 ms
64 bytes from 192.168.101.100: seq=3 ttl=64 time=1.836 ms
64 bytes from 192.168.101.100: seq=4 ttl=64 time=0.333 ms
^C
--- a.dimon.com ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 0.000/0.333/0.000 ms
/# 


启用--server 选项 实现某个域名空间的解析请求转发给指定上级DNS Server


请参考MAN手册‘man dnsmasq’获取该命令行选型的更详细使用信息
例子:
把请求'xxx.internal.thekelleys.org.uk'域名解析的包都准发给‘10.10.68.100’ DNS Server进行解析。
dnsmasq  /internal.thekelleys.org.uk/10.10.68.100
其它的域名解析包,继续走'/etc/dnsmasq/resolv.cfg'配置的DNS Server进行解析.
进一步的,Dnasmasq MAN手册说明'--server'选项还支持设置向上级DNS Server转发Query请求时使用的源IP地址或上行的Interface接口。(详见'man dnsmasq'手册)
例子:
指定到'xxx.internal.thekelleys.org.uk'域名空间的域名请求都转发到上级DNS Server 10.10.68.100,并且走上行Interface pon0.3001 接口出去。
dnsmasq /internal.thekelleys.org.uk/10.10.68.100@pon0.3001

启用 -p x 指定监听的DNS请求端口port


dnsmasq-2.48的选项'-p x'可以指定监听的dns query包的端口port。
特别的通过选型 '-p 0’指定监听的dns port为0,表示dnsquery-2.48不监听DNS Query请求。
查看dnsmasq的Cache缓存
向Dnsmasq发送 SUSR1 信号,可以查看dnsmasq的dns cache缓存

/# ps | grep dnsmasq 
  800 root     ./dnsmasq -d -q
 1901 root     grep dnsmasq
/# 
/# kill -10 800
dnsmasq: time 2709
dnsmasq: /# cache size 150, 0/33 cache insertions re-used unexpired cache entries.
dnsmasq: queries forwarded 9, queries answered locally 1
dnsmasq: queries for authoritative zones 0
dnsmasq: server 218.2.135.1#53: queries sent 9, retried or failed 0
dnsmasq: Host                                     Address                        Flags      Expires
dnsmasq: ipv6-aserver-heyi.m.taobao.com 106.11.43.158                            4F         Thu Jan  1 00:42:16 1970
dnsmasq: baidu.com                      220.181.38.148                           4F         Thu Jan  1 00:41:52 1970
dnsmasq: baidu.com                      39.156.69.79                             4F         Thu Jan  1 00:41:52 1970
dnsmasq: www.youku.com                  ipv6-aserver-heyi.m.taobao.com           CF         Thu Jan  1 00:45:41 1970
dnsmasq: ipv6-aserver-heyi.m.taobao.com                                          CF         Thu Jan  1 00:41:41 1970

/#

  • 5
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值