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

How to use Dnsmasq to build DNS Server

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the relevant knowledge of "how to use Dnsmasq to build DNS server". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to use Dnsmasq to build DNS server" can help you solve the problem.

1. Dnsmasq installation

Install and start Dnsmasq

Yum install-y dnsmasqservice dnsmasq start II, Dnsmasq configuration

1. The configuration file path of Dnsmasq is: / etc/dnsmasq.conf

# ll-d / etc/dnsmasq.conf-rw-r--r-- 1 root root 21237 Feb 23 00:17 / etc/dnsmasq.conf

2. Edit / etc/dnsmasq.conf

Resolv-file=/etc/resolv.dnsmasq.conf / / dnsmasq will look for the upstream dns server strict-order / / remove the previous # addn-hosts=/etc/dnsmasq.hosts / / add the record listen-address=127.0.0.1192.168.1.123 / / listener address to this file

3. Modify / etc/resolv.conf

Echo 'nameserver 127.0.0.1' > / etc/resolv.conf

Create the resolv.dnsmasq.conf file and add the address of the upstream dns server

Touch / etc/resolv.dnsmasq.confecho 'nameserver 119.29.29.29' > / etc/resolv.dnsmasq.conf

5. Create a dnsmasq.hosts file

Cp / etc/hosts / etc/dnsmasq.hostsecho 'addn-hosts=/etc/dnsmasq.hosts' > > / etc/dnsmasq.conf

Tip: what is set up in resolv.dnsmasq.conf is the real Nameserver, which can be used by telecom, Unicom and other public DNS.

III. Dnsmasq start

1. Set Dnsmasq to boot and start the Dnsmasq service:

Chkconfig dnsmasq on/etc/init.d/dnsmasq restart

2. Netstat-tunlp | grep 53 to check whether Dnsmasq starts normally:

# netstat-tlunp | grep 53tcp 0 0 0.0 0 grep 53tcp 53 0 0 0 LISTEN 2491/dnsmasq tcp 0: 53:: * LISTEN 2491/dnsmasq udp 0 0 0.0.0.0: 53 0.0.0.0 2491/dnsmasq udp 0: 53:: * 2491/dnsmasq

3. Dig www.freehao123.com, there is no cache for the first time, so the time is more than 200.

4. The second test shows that the query time has been changed to 0. 0 because there is already a cache.

This is the end of the introduction on "how to use Dnsmasq to build a DNS server". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

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

Development

Wechat

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

12
Report