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 configure dns cache server with dnsmasq under Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces "how to configure dns cache server with dnsmasq under Linux". In the daily operation, I believe that many people have doubts about how to configure dns cache server with dnsmasq under Linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubt of "how to use dnsmasq to configure dns cache server under Linux". Next, please follow the editor to study!

The installation process is relatively simple

Yum-y install dnsmasq* wget http://www.keepalived.org/software/keepalived-1.2.9.tar.gztar zxvf keepalived-1.2.9.tar.gzcd keepalived-1.2.9./configure-- prefix=/usr/local/keepalivedmake & & make installmkdir / etc/keepalivedcp / usr/local/keepalived/etc/keepalived/keepalived.conf / etc/keepalived/ln-s / usr/local/keepalived/etc/sysconfig/keepalived / etc/sysconfig/ln-s / usr/local/keepalived/etc/ Rc.d/init.d/keepalived / etc/init.d/ln-s / usr/local/keepalived/sbin/keepalived / usr/sbin/chkconfig-- add keepalivedchkconfig-- level 35 keepalived on

The configuration of keepalived is very simple. You only need to configure a vip to float back and forth between two server to realize the active / standby system.

! Configuration file for keepalived global_defs {notification_email {xxx@xxx.com} notification_email_from xxx@xxx.com smtp_server 127.0.0.1 smtp_connect_timeout 30 router_id lvs_devel} vrrp_instance dnscache {state master / / another configuration backup interface eth1 / / on which interface to perform server state detection virtual_router_id 51 priority 180 / / backup machine configuration Set 100advert_int 1 / / check interval Unit: authentication {auth_type pass auth_pass 1234} virtual_ipaddress {/ / vip setting, assigned to the intranet Nic 192.168.100.99bp 24 dev eth1}}

The configuration of dnsmasq is also simple.

Resolv-file=/etc/resolv.dnsmasq.confcache-size=1000conf-dir=/etc/dnsmasq.d

Write the dns address to the / etc/resolv.dnsmasq.conf file

Echo "nameserver 8.8.8.8" > / etc/resolv.dnsmasq.conf

It is used for dns parsing on this machine and all other servers in the LAN.

Echo "nameserver 192.168.100.99" > / etc/resolv.conf

Finally, find a local area network server to verify, if it can be parsed, it is normal.

Nslookup www.google.cn 192.168.100.99

This solution is only suitable for small enterprises, and it is best to use bind when there is a large amount of resolution.

Here are some additions from other netizens:

The copy code is as follows:

Sudo pacman-s-needed dnsmasq

Cd / etc

[admin@huangye etc] $sudo cp-v dnsmasq.conf {, .orig}

`dnsmasq.conf'-> `dnsmasq.conf.orig'

[admin@huangye etc] $sudo vim dnsmasq.conf

In comparison, the configuration of dnsmasq is much simpler:

The copy code is as follows:

Resolv-file=/etc/dnsmasq.resolv.conf

Addn-hosts=/etc/dnsmasq.hosts

Local=/localnet/

No-dhcp-interface=eth0

Conf-dir=/etc/dnsmasq.d

The copy code is as follows:

[admin@huangye etc] $sudo cp-v resolv.conf dnsmasq.resolv.conf

Password:

`resolv.conf'-> `dnsmasq.resolv.conf'

Sudo mkdir / etc/dnsmasq.d

Sudo touch / etc/dnsmasq.hosts

Sudo / etc/rc.d/dnsmasq start

Finally, don't forget to join rc.conf daemons and be careful to follow network.

Dnsmasq can read entries from additional hosts files, such as adding forward parsing:

Echo "ip address Domain name" > / etc/dnsmasq.hosts

In addition, you can restart dnsmasq using sighup (you can make the configuration take effect after modifying the hosts file)

Killall-s sighup dnsmasq

View service status:

Netstat-tunl

Tcp 0 0 0.0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0

Udp 0 0 0.0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0

After another dig, I found that it was stable in 4ms.

At this point, the study on "how to use dnsmasq to configure dns cache server under Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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