Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Lightweight DNS Server-- DNSmasq

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Brief introduction:

Dnsmasq is a lightweight DNS server, but also an open source project, simple and quick configuration, Dnsmasq provides DNS caching and DHCP services. As a domain name resolution server (DNS), dnsmasq can improve the connection speed to visited URLs by caching DNS requests. As a DHCP server, dnsmasq can provide intranet ip address and routing for LAN computers, and DNS and DHCP functions can be realized at the same time or separately. Dnsmasq is lightweight and easy to configure. In addition, it comes with a PXE server and support for mail server mx records, jabber srv records, and so on.

Deployment environment:

Centos 6.5x86x64 operating system

Dnsmasq is a package in the Basebase source, which can be installed and deployed directly:

# yum list | grep dnsmasqdnsmasq.x86_64 2.48-17.el6 @ base dnsmasq-utils.x86_64 2.48-17.el6 base

Install the dnsmasq package:

# yum-y install dnsmasq

Make a backup before operation:

# cp / etc/dnsmasq.conf / etc/dnsmasq.conf.bak

# View the installation file path of dnsmasq:

# rpm-ql dnsmasq/etc/dbus-1/system.d/dnsmasq.conf/etc/dnsmasq.conf # main configuration file / etc/dnsmasq.d/etc/rc.d/init.d/dnsmasq/usr/sbin/dnsmasq/usr/share/doc/dnsmasq-2.48/usr/share/doc/dnsmasq-2.48/CHANGELOG/usr/share/doc/dnsmasq-2.48/COPYING/usr/share/doc/dnsmasq-2.48/DBus-interface/usr/ Share/doc/dnsmasq-2.48/FAQ/usr/share/doc/dnsmasq-2.48/doc.html/usr/share/doc/dnsmasq-2.48/setup.html/usr/share/man/man8/dnsmasq.8.gz/var/lib/dnsmasq

Point the local resolv parsing file configuration to the local machine:

# echo 'nameserver 127.0.0.1' > / etc/resolv.conf

Copy a parsed configuration file as dnsmasq:

Cp / etc/resolv.conf / etc/resolv.dnsmasq.confecho 'nameserver 8.8.8.8' > / etc/resolv.dnsmasq.conf

The configuration files used by dnsmasq are as follows:

# cat / etc/dnsmasq.conf | grep-v'^ #'| grep-v'^ $'resolv-file=/etc/resolv.dnsmasq.confstrict-orderinterface=eth0listen-address=192.168.30.131127.0.0.1bind-interfacesaddn-hosts=/etc/hosts # Domain name Mapping text

The contents of the other two configuration files:

[root@sh-puppet-node2 etc] # cat / etc/resolv.confnameserver 127.0.0.1 [root@sh-puppet-node2 etc] # cat / etc/resolv.dnsmasq.confnameserver 8.8.8.8 # 4 Google dns servers, which may be slower than nameserver 114.114.114.114

Add domain name mapping

# cat / etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.30.128 sh-puppet-master.com192.168.30.130 sh-puppet-node1.com192.168.30.131 sh-puppet-node2.com

Start the dnsmasq service:

# / etc/init.d/dnsmasq restartShutting down dnsmasq: [OK] Starting dnsmasq: [OK]

Point the reslove.conf file address of node2 to the ip of dns server, and test and view the ip of domain name resolution:

# dig sh-puppet-node2.com

In order to prevent the local domain name from duplicating some domain names on the public network, it is changed to 127.0.0.1.

[root@sh-puppet-node2 ~] # cat / etc/resolv.conf; generated by / sbin/dhclient-scriptsearch shjygw com#nameserver 202.96.209.5nameserver 127.0.0.1 [root@sh-puppet-node2 ~] # cat / etc/resolv.dnsmasq.confnameserver 127.0.0.1

Testing ping Baidu found that it does not ok, but does not affect private network domain name resolution:

[root@sh-puppet-node2 ~] # ping www.baidu.com

Ping: unknown host

Www.baidu.com

Description: if the picture is damaged, it will not be displayed. There is room to make up.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report