Recently, the local DNS of foreign servers is always faulty. Transient disconnections will affect services. So I found two servers in the data center and installed keepalived and dnsmasq on the local DNS cache.
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 35 keepalived on
The configuration of keepalived is very simple. You only need to configure a VIP to move between two servers to implement the master and slave nodes.
! ConfigurationFilefor 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 // configure BACKUP for another instance
Interface eth1 // interface on which server status detection is performed
Virtual_router_id 51
Priority 180 // configure 100 on the BACKUP machine
Advert_int 1 // check interval, in seconds
Authentication {
Auth_type PASS
Auth_pass 1234
}
Virtual_ipaddress {// VIP settings, specified to the Intranet Nic
192.168.100.99/24 dev eth1
}
}
The configuration of dnsmasq is also very simple.
resolv-file=/etc/resolv.dnsmasq.conf
cache-size=1000
conf-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
Use dns resolution for all servers on the local machine and LAN
echo "nameserver 192.168.100.99">/etc/resolv.conf
Finally, find a local area network Server to verify that it is normal if it can be resolved.
nslookup www.google.cn 192.168.100.99
This solution is only suitable for small enterprises. It is best to use bind when there is a small amount of resolution.