Dnsmasq安装与配置-搭建本地DNS服务器 更干净更快无广告DNS解析(dnsmasq配置详解)

Dnsmasq安装与配置-搭建本地DNS服务器 更干净更快无广告DNS解析(dnsmasq配置详解)

DNSmasq是一个轻量级的、完全开源的域名系统服务器。它可以用于负责将主机名映射到IP地址的内部或外部DNS服务器。一般情况下,默认的dnsmasq配置文件位于/etc/dnsmasq.conf目录下。//This provides resolution of all hosts in the given domain even if they don’t have explicit entries.引入DHCP未分配IP地址库及方法:dhcp-authoritative //Enables DHCP, treating it as authoritative so it will always assign IP addresses from those configured and will never forward DHCP requests to any other servers.dhcp-range 192….. ,static //Specifies an IP range within which dynamic addresses should be allocated.优化Cache效果:cache-size=5000 //Sets the size of dnsmasqs cache, default is 150 names.dnsmasq怎么设置?它能够作为 DHCP 和 TFTP 服务器运行,并可以与 DHCPv6、PXE 和 BOOTP 等协议一起工作。要想配置 DNSmasq ,你必须打开 /etc/dnsmasq.conf 文件: sudo nano /etc/dnsmasq.conf 在文件中添加如下信息: #interface to listen on interface=eth0 #IP range for dhcp leases dhcp-range=192.168

Dnsmasq安装与配置-搭建本地DNS服务器 更干净更快无广告DNS解析?

DNSmasq是一个轻量级的、完全开源的域名系统(DNS)服务器。它可以用于负责将主机名映射到IP地址的内部或外部DNS服务器。

要搭建一个更干净、更快无广告的DNS解析,首先要安装dnsmasq. 在CentOS/7上使用yum进行安装即可:

“`bash

$ yum install -y dnsmasq

“`

之后就要配置dnsmasq,修改 /etc/dnsmasq.conf文件, 内容如下:

“`bash

# 防止 ping 192.168.0.1 被当作请求 DNS 服务 #no-hosts j addn-hosts=/etc/hosts_add interface=ens33 server=8.8.8.8 domain=mydomainname local=/mydomainname/ listen-address=192.168…. bind-interfaces resolv-file=/tmp/.resolv bogus-priv no-dhcp-interface=”lo”,”eth0″, “wlan” logqueries strictorder minport 1024 maxport 65535 noquery except from all domains which match this mask confdir=/etc/dnsmasq cache size 0 “`

dnsmasq配置详解

1. 下载及安装dnsmasq:

“`shell

# 使用yum命令安装:

sudo yum install dnsmasq -y

# 或者使用apt-get命令安装:

sudo apt-get install dnsmasq -y

“`

通过上面的指令即可完成在Linux系统中的DNSMasq服务器的快速部署。一般情况下,默认的dnsmasq配置文件位于/etc/dnsmasq.conf目录下。此时,我们就开始对其进行详细配置工作吧。

2. 常用的DNSMASQ配置操作如下所列出:

(1)添加DNS服务器地址并检测是否能够正常工作: 这里通常情况可以将8.8.8.8、114.114.114或Google DNS、Open DNS作为备用DNS地址来解析站内Hosts文件中找不到IP映射信息;
           `resolv-file=/etc/resolv_ssl_bakup`
                           `server=127.0 .0 .1#5300`
                  `server= 8 . 8 . 4 .4`

                                        ` server = 8 . 8 . 8 .8#5300 `
                                    等 ;
( 2 ) 支 持 本 地 内 端 D omain N a me S ystem( D N S ) : & lt ; br / & gt ;                      domain = example com
local=/example com/ #provides hostname resolution for the given domain name.
expand –hosts// This allows you to provide hostnames that are not in the domains specified by “domain” but still be resolved locally.
address=/.example com/192……… //This provides resolution of all hosts in the given domain even if they don’t have explicit entries.

(3)引入DHCP未分配IP地址库及方法:

dhcp-authoritative             //Enables DHCP, treating it as authoritative so it will always assign IP addresses from those configured and will never forward DHCP requests to any other servers.
dhcp-range 192….. ,static           //Specifies an IP range within which dynamic addresses should be allocated.

(4)优化Cache效果:

cache-size=5000               //Sets the size of dnsmasqs cache, default is 150 names.

dnsmasq怎么设置?

DNSmasq 是一款开源的轻量级 DNS 代理服务器,由 Simon Kelley 编写。它能够作为 DHCP 和 TFTP 服务器运行,并可以与 DHCPv6、PXE 和 BOOTP 等协议一起工作。

要想配置 DNSmasq ,你必须打开 /etc/dnsmasq.conf 文件:

sudo nano /etc/dnsmasq.conf

在文件中添加如下信息:

#interface to listen on

interface=eth0

#IP range for dhcp leases

dhcp-range=192.168.1.50,192.168.1.150,12h

#dhcp dns server IPs

dhcp-option=option:dns-server,8.8.8.8, 8.8