Linux deployment dns server (dnsmasq method)

1. Preamble

        dnsmasq provides DNS caching and DHCP server functions. As a domain name resolution server (DNS), dnsmasq can pass

Improves connection speed to previously visited URLs by caching DNS requests. As a DHCP server, dnsmasq can be used to

LAN computers assign intranet ip addresses and provide routing. The functions of DNS and DHCP can be realized simultaneously or separately.

Note: dnsmasq is lightweight and easy to configure, suitable for individual users or networks with less than 50 hosts.

2. Installation and deployment

You need to turn off the firewall and turn off selinux

A. Install dnsmasq

yum install -y dnsmasq  #centos

apt  install -y dnsmasq  #Ubuntu

B. Edit the dnsmasq configuration file

vim /etc/dnsmasq.conf

#Configure the upstream dns server, if not enabled, use the nameserver in the default /etc/resolv.conf of the linux host

resolv-file=/etc/dns.conf

dns.conf is actually a copy of the /etc/resolv.conf file, and then change the name

#According to the dns configured by resolv-file, the assignment analysis is performed in order from top to bottom

strict-order

#Forcibly resolve the domain name, resolve yin123.com.cn to 192.168.1.100

address=/yin123.com.cn/192.168.1.100

#Listening address, you can write local ip, dhcp gateway address, you can write multiple, separated by commas

listen-address=192.168.1.1

There can be multiple addresses, even if the host is not configured, the configuration here will be parsed

#Add the path to the hosts file, and configure your own domain name and ip address in it. achieve the purpose of parsing

addn-hosts=/etc/dnsmasq.hosts

dnsmasq.hosts is actually a copy of the /etc/hosts file, and then change the name

It should be noted that this does not necessarily take effect. If it does not take effect, you can copy and analyze it again in the /etc/hosts file

#log

log-queries

log-facility=/var/log/dnsmasq/dnsmasq.log

C. Edit the upstream dns configuration file

vim /etc/dns.conf

 D. Edit the dnsmasq.hosts file

 Restart and start the dns service, and then the domain name can be resolved

Guess you like

Origin blog.csdn.net/qq_35002542/article/details/128655553