创建用户
useradd -r -g users dnsmasq
安装DNSmasq
- yum install -y gcc
- wget http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.76.tar.gz
- tar zxvf dnsmasq-2.76.tar.gz
- cd dnsmasq-2.76
- make && make install
- cp dnsmasq.conf.example /etc/dnsmasq.conf
-
复制代码
修改配置文件
- vi /etc/dnsmasq.conf
- user=dnsmasq #启动账号
- group=users #启动组号
- interface=eth0 #绑定网络接口
- listen-address=192.168.238.135 #绑定IP
- bind-interfaces
- resolv-file=/etc/resolv.conf #域名解析文件
- addn-hosts=/etc/hosts #域名解析文件
-
复制代码
编辑域名解析文件
echo "192.168.238.135 www.examp;e.com" >> /etc/hosts
启动
/usr/local/sbin/dnsmasq
检查DNSmasq是否启动成功,如果53端口已成功启动,则说明DNSmasq已经正常工作。
- [root@localhost ~]# netstat -tnl | grep 53
- tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN
- tcp 0 0 192.168.238.135:53 0.0.0.0:* LISTEN
- tcp 0 0 ::1:53 :::* LISTEN
- tcp 0 0 fe80::20c:29ff:fe4f:fae7:53 :::* LISTEN
复制代码