一、安装
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
原文地址:简单的配置dnsmasq作为本地dns缓存层, 感谢原作者分享。 其实只要你愿意,一切都可以变得很容易。