Dnsmasq为小型网络提供网络基础设施:DNS,DHCP,路由器通告和网络引导。
它被设计为轻量级且占用空间小,适用于资源受限的路由器和防火墙。
它还被广泛用于智能手机和便携式热点的共享,并支持虚拟化框架中的虚拟网络。
支持的平台包括Linux,Android,* BSD和Mac OS X.
Dnsmasq包含在大多数Linux发行版以及FreeBSD,OpenBSD和NetBSD的端口系统中。
Dnsmasq提供完整的IPv6支持。

测试环境中,让 api.xlxh.net 关联到IP为 1.2.2.6 的测试服务器,
我们现在的解决方案是:
在本机的 /etc/hosts 文件 中记录相应的域名IP映射关系
本机在尝试 解析一个域名时,会先去/etc/hosts中查找该域名对应的IP,并访问相应IP的服务器。
只有当/etc/hosts中 没有该域名的记录时,本机才会去DNS服务器进行域名解析。
本机解析域名的优先级:
DNS缓存 > /etc/hosts > DNS服务。
1、ONU WEB页面配置本地 DNS Service



2、如何验证 DNS Service功能是否 生效???

  1. PC直连被测设备 访问对应的域名(或页面设置的主机名) ,通过wireshare抓包软件 ,查看 该域名 返回的IP地址 是否 与设置 域名对应的IP地址一样(/etc/hosts文件)
  2. 通过dhs客户端指令解析 查看: nslookup 域名 查看 解析出的IP地址是否 和设置的IP一致
    nslookup api.xlxh.net

    Telnet ONU命令行通过 nslookup指令解析DNS
  3. 通过 host指令查看 域名对应的IP地址:
    host api.xlxh.net

3、DNS 服务器在linux下安装配置

3.1 安装Dnsmasq
该测试服务器的系统是ubuntu,使用自带的包管理器下载并安装Dnsmasq最简洁。
sudo apt-get install dnsmasq

3.2 配置Dnsmasq
Dnsmasq所有的配置都在 /etc/dnsmasq.conf文件 中完成,按照需要简单做了以下修改。
#首先配置resolv-file,这个参数表示dnsmasq会从这个指定的文件中寻找上游DNS服务器

resolv-file=/etc/resolv.dnsmasq.conf
#单设置127.0.0.1为只能本机使用,单设置本机IP为只能内部全网使用而本机不能用,这里需要同时设置两者
listen-address=127.0.0.1,192.168.1.98
#dnsmasq缓存设置
cache-size=1024

然后根据自己设置的resolv-file=/etc/resolv.dnsmasq.conf,配置/etc/resolv.dnsmasq.conf文件,指定上游DNS服务器
nameserver 114.114.114.114

3.3 按以上配置配置好Dnsmasq并启动后,会发现Dnsmasq无法正常解析域名,
使用ps -ef | grep dnsmasq查看后发现如下信息
dnsmasq 10384 1 0 15:16 ? 00:00:00 /usr/sbin/dnsmasq -x /var/run/dnsmasq/dnsmasq.pid -u
dnsmasq -r /var/run/dnsmasq/resolv.conf -7

其中dnsmasq -r /var/run/dnsmasq/resolv.conf说明Dnsmasq是从/var/run/dnsmasq/resolv.conf文件中获取上游DNS服务器,
而非我们指定的resolv-file=/etc/resolv.dnsmasq.conf。
查阅了无数文档以后,发现在**/etc/default/dnsmasq中有一个IGNORE_RESOLVCONF属性**,说明如下

# If the resolvconf package is installed, dnsmasq will use its output
# rather than the contents of /etc/resolv.conf to find upstream
# nameservers. Uncommenting this line inhibits this behaviour.
# Note that including a "resolv-file=<filename>" line in
# /etc/dnsmasq.conf is not enough to override resolvconf if it is
# installed: the line below must be uncommented.
# IGNORE_RESOLVCONF=yes

这里必须取消IGNORE_RESOLVCONF=yes前的注释,才能让resolv-file=/etc/resolv.dnsmasq.conf生效。
3.4 启动Dnsmasq
sudo service dnsmasq start

3.5 设置ONU或路由器,将DNS服务指向本地DNS服务器
-------参考上述步骤1和2
3.6 查看端口和进程
1)查看进程
ps -ef |grep dnsmasq

2)查看监听端口
netstat -tupnl |grep dnsmasq

4、 dnsmasq 命令参数详解:
如下指令分析:

 dnsmasq -r /var/default_resolv.conf -M 0 -T 6 -P 0 -U 0 --r:-r, --resolv-file=<file>
Read the IP addresses of the upstream nameservers from <file>, instead of /etc/resolv.conf. For the format of this file see resolv.conf(5). The only lines relevant to dnsmasq are nameserver ones. Dnsmasq can be told to poll more than one resolv.conf file, the first file name specified overrides the default, subsequent ones add to the list. This is only allowed when polling; the file with the currently latest modification time is the one used.-M 0:-M, --dhcp-boot=[tag:<tag>,]<filename>,[<servername>[,<server address>|<tftp_servername>]]
(IPv4 only) Set BOOTP options to be returned by the DHCP server. Server name and address are optional: if not provided, the name is left empty, and the address set to the address of the machine running dnsmasq. If dnsmasq is providing a TFTP service (see --enable-tftp ) then only the filename is required here to enable network booting. If the optional tag(s) are given, they must match for this configuration to be sent. Instead of an IP address, the TFTP server address can be given as a domain name which is looked up in /etc/hosts. This name can be associated in /etc/hosts with multiple IP addresses, which are used round-robin. This facility can be used to load balance the tftp load among a set of servers.-T 6:-T, --local-ttl=<time>
When replying with information from /etc/hosts or configuration or the DHCP leases file dnsmasq by default sets the time-to-live field to zero, meaning that the requester should not itself cache the information. This is the correct thing to do in almost all situations. This option allows a time-to-live (in seconds) to be given for these replies. This will reduce the load on the server at the expense of clients using stale data under some circumstances.-P 0:-P, --edns-packet-max=<size>
Specify the largest EDNS.0 UDP packet which is supported by the DNS forwarder. Defaults to 4096, which is the RFC5625-recommended size.-U 0:
-U, --dhcp-vendorclass=set:<tag>,[enterprise:<IANA-enterprise number>,]<vendor-class>
Map from a vendor-class string to a tag. Most DHCP clients provide a "vendor class" which represents, in some sense, the type of host. This option maps vendor classes to tags, so that DHCP options may be selectively delivered to different classes of hosts. For example --dhcp-vendorclass=set:printers,Hewlett-Packard JetDirect will allow options to be set only for HP printers like so: --dhcp-option=tag:printers,3,192.168.4.4 The vendor-class string is substring matched against the vendor-class supplied by the client, to allow fuzzy matching. The set: prefix is optional but allowed for consistency.
Note that in IPv6 only, vendorclasses are namespaced with an IANA-allocated enterprise number. This is given with enterprise: keyword and specifies that only vendorclasses matching the specified number should be searched.
-x:
-x, --pid-file=<path>
Specify an alternate path for dnsmasq to record its process-id in. Normally /var/run/dnsmasq.pid.详细参数见:http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html#lbAE

中兴微方案ONU之 DNS Service (dnsmasq)功能测试指导相关推荐

  1. 9.DNS和DNSmasq服务

    文章目录 DNS简介 域名解析过程 递归查询和迭代查询 递归查询 迭代查询 dnsmasq dnsmasq介绍 利用host文件安全加固 dnsmasq安装 dnsmasq的配置文件 dnsmasq. ...

  2. 微服务平台(Micro Service Platform : MSP)旨在提供一个集开发、测试、运维于一体的开发者专属平台,让开发者能快速构建或使用微服务,让开发更简单,让运维更高效。...

    微服务平台(Micro Service Platform : MSP)旨在提供一个集开发.测试.运维于一体的开发者专属平台,让开发者能快速构建或使用微服务,让开发更简单,让运维更高效. MSP采用业界 ...

  3. 微服务框架之微软Service Fabric

    常见的微服务架构用到的软件&组件: docker(成熟应用) spring boot % spring cloud(技术趋势) Service Fabric(属于后起之秀 背后是微软云的驱动) ...

  4. 本地DNS服务器-Dnsmasq安装与配置

    1.Dnsmasq安装 Dnsmasq安装:yum install dnsmasq -y Dnsmasq版本:dnsmasq -v Dnsmasq启动:service dnsmasq start 查看 ...

  5. DNS劫持DNSmasq详细解析及详细配置

    2019独角兽企业重金招聘Python工程师标准>>> 常用于测试使用,安装环境为MacOS 一.Dnsmasq介绍 Dnsmasq 提供 DNS 缓存和 DHCP 服务功能.作为域 ...

  6. ZTE方案ONU PPPoE | FTP | Samba等服务配置分析

    问题1:ZTE方案 ONU PPPoE拨号成功后,再断开PPPoE Server,观察ONU WAN连接状态页面显示的PPPoE WAN IP地址多长时间会释放掉,重新去拨号??? 假设:设置 3mi ...

  7. 12V5A 12V6A反激开关电源、氮化镓方案 OB2269 M5576 CR6842启辰微方案 方案包括原理图,PCB,变压器规格书

    12V5A 12V6A反激开关电源.氮化镓方案 OB2269 M5576 CR6842启辰微方案 方案包括原理图,PCB,变压器规格书 只是设计方案,不是实物,不是实物,不是实物 ID:4596730 ...

  8. 辅助DNS SERVICE 配置工作任务-winserver2

    赛题               2.2.4.辅助DNS SERVICE 配置工作任务 1.辅助DNS配置区域        正向区域        反向区域 2.主DNS权限设置 赛题 2.2.4. ...

  9. DNS SERVICE配置-winserver1

    赛题               2.1.4.DNS SERVICE 配置工作任务 1.配置正反向记录 2.配置TXT记录 赛题 2.1.4.DNS SERVICE 配置工作任务 安装及配置 DNS ...

最新文章

  1. vue中把props中的值赋值给data
  2. AI算法工程师之路 梯度下降百度总结 练习机器学习的网站
  3. 判断一个显示对象是否移除
  4. 关于zendframework中的Zend_Db_Expr(不自动加引号)
  5. 【中级软考】UML图(Unified Modeling Language统一建模语言、标准建模语言)
  6. 4、mysql数据库的权限管理
  7. Codeforces 478B 6thweek contest_B
  8. java中如何分隔字符串_Java中分割字符串
  9. 04-AIO通讯模型
  10. 计算机房的英语怎么读音,机房位置,Host equipment room,音标,读音,翻译,英文例句,英语词典...
  11. LANP环境编译设置
  12. 使用opennlp进行词性标注
  13. feign.codec.DecodeException: Error while extracting response for type
  14. 光猫、路由器、交换机、中继器、网桥是什么?
  15. 欧盟 GDPR 通用数据保护条例正式生效后,各行业影响分析
  16. 机器人驻场富士康,流水线青年的自救
  17. 从魔兽看四种设计模式(转载)
  18. 台达伺服b3设置_雷赛BAC332E运动控制器控制台达B3伺服电机的使用入门介绍(精)...
  19. 今天,你薅支付宝羊毛了么?
  20. TM4C123-TivaWare中函数名与函数指针在ROM中的映射

热门文章

  1. Java中double转long方法
  2. 意念控制四旋翼 学习笔记
  3. java处理word插入数据转PDF及下载PDF
  4. ubuntu 16.04下安装pytorch配置caffe2(cuda 9.0+cudnn 7.6)
  5. ArrayList 源码分析
  6. 解析锂电池的充电的整个过程!
  7. Packet Tracer - 配置 IPv6 的 EIGRP 基本设置
  8. 笔记本电脑计算机无法启动怎么办,联想笔记本开不了机怎么办 电脑开机进不了系统怎么办...
  9. svn 提交 认证失败 170001 已解决
  10. 贪吃的大嘴java_Java实现 蓝桥杯VIP 算法提高 贪吃的大嘴