简单的配置dnsmasq作为本地dns缓存层

配置dnsmasq

一、安装

yum search dnsmasq

二、配置

vim /etc/dnsmasq.conf

listen-address=127.0.0.1

strict-order

cache-size=2048

#其实dnsmasq的配置有很多项,这里选择这几项只保证了最基本的。listen-address监听地址;strict-order按照/etc/resolv.conf中nameserver的顺序依次使用,默认时dnsmasq会随机的调用/etc/resolv.conf中的nameserver;cache-size缓存解析条数,默认是150

/bin/sed -i '1i\nameserver 127.0.0.1' /etc/resolv.conf

三、部署脚本

#!/bin/bash

init_dnsmasq(){

/bin/sed -i ’1i\nameserver 127.0.0.1′ /etc/resolv.conf

yum install -y dnsmasq

cat << shanks > /etc/dnsmasq.conf

listen-address=127.0.0.1

strict-order

cache-size=2048

shanks

chkconfig dnsmasq on

/etc/init.d/dnsmasq start

}

init_dnsmasq


你可能感兴趣的:(dns,dnsmasq,缓存层)