The configuration method of DNS cache server with DNSMASQ under Linux _linux

Source: Internet
Author: User
Tags mkdir nameserver

Currently the latest version is 2.7.1, can go to its FTP download: http://www.thekelleys.org.uk/dnsmasq/

The installation process is relatively simple

Yum-y Install dnsmasq* 
wget http://www.keepalived.org/software/keepalived-1.2.9.tar.gz
tar zxvf keepalived-1.2.9.tar.gz
cd keepalived-1.2.9
./configure--prefix=/usr/local/keepalived make
& & make install
mkdir/etc/keepalived
cp/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 keepalived
chkconfig--level-keepalived on

Keepalived configuration is very simple, only need to configure a VIP can float between the two servers can be achieved by the main standby

! 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 router_id
}
 
Vrrp_instance DnsCache {
  state MASTER         //Another configuration backup
  interface eth1        //Server status detection
  on which interface virtual_router_id
  Priority 180         //backup machine is configured with the
  advert_int 1/         check interval, in seconds
  Authentication {
    Auth_type pass
    auth_pass 1234
  }
 
  virtual_ipaddress {       //VIP settings, designated to intranet NIC 
    192.168.100.99/24 dev eth1
  }
}

DNSMASQ's configuration is simple, too.

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


Write DNS address to/etc/resolv.dnsmasq.conf file

echo "NameServer 8.8.8.8" >/etc/resolv.dnsmasq.conf

Native and LAN all other server DNS resolution uses it

echo "NameServer 192.168.100.99" >/etc/resolv.conf

Finally find a LAN server verification, if you can explain the normal.

Nslookup www.google.cn 192.168.100.99

This scheme is only suitable for small enterprises, in the case of small-scale use, when the resolution is large or with the best bind.

The following are additional users:

Copy Code code 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 contrast, the DNSMASQ configuration is much simpler:
Copy Code code as follows:

Resolv-file=/etc/dnsmasq.resolv.conf
Addn-hosts=/etc/dnsmasq.hosts
local=/localnet/
No-dhcp-interface=eth0
Conf-dir=/etc/dnsmasq.d

Copy Code code 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 pay attention to the network behind.

DNSMASQ can read entries from an additional Hosts file, such as adding forward resolution:

echo "IP address domain name" >/etc/dnsmasq.hosts

In addition, restart DNSMASQ can be used Sighup (you can modify the Hosts file, let the configuration take effect)

Killall-s Sighup DNSMASQ

To view service status:

Netstat-tunl
TCP 0 0 0.0.0.0:53 0.0.0.0:* LISTEN
UDP 0 0 0.0.0.0:53 0.0.0.0:*

Again dig, found stable at 4ms, I halo, the same configuration, I am in an Ubuntu server 10.04 above dig is 1ms, in my native incredibly in 4ms, embarrassed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.