Centos6.5-dnsmasq安装

 

 

1、使用yum install dnsmasq -y 安装dns(含dns server和dns代理功能)

2、查询dnsmasq已经安装成功

[root@localhost ~]# rpm -q dnsmasq

dnsmasq-2.48-18.el6_9.x86_64

[root@localhost ~]#

3、配置/etc/dnsmasq.conf文件

对于/etc/dnsmasq.conf文件的行太多的话,我们只需要添加我们需要的行,先把所有行都注释掉,然后echo追加进去我们所需要的行。

  3.1、修改/etc/dnsmasq.conf的快速方法:在每行的头添加字符,比如"#",注释掉文件的所有行,命令如下:
sed -i 's/^/#&/g' /etc/dnsmasq.conf    //注释掉/etc/dnsmasq.conf文件中的所有的行
cat /etc/dnsmasq.conf |grep -v "#"  //查看注释是否OK

  3.2、然后把需要的行echo追加进去

echo resolv-file=/etc/resolv.dnsmasq.conf >>/etc/dnsmasq.conf    #此/etc/resolv.dnsmasq.conf文件还需后续编辑
echo strict-order >>/etc/dnsmasq.conf
echo interface=eth0  >>/etc/dnsmasq.conf               #对特定接口提供dns服务
echo addn-hosts=/etc/dnsmasq.hosts >>/etc/dnsmasq.conf  #此/etc/dnsmasq.hosts文件还需后续编辑

[root@localhost ~]# cat /etc/dnsmasq.conf |grep -v "#"            //查看echo是否追加ok
resolv-file=/etc/resolv.dnsmasq.conf
strict-order
interface=eth0  #对特定接口提供dns服务
addn-hosts=/etc/dnsmasq.hosts
[root@localhost ~]#

sed -i 's/^#//' 123.txt      //删除文件的行首字符#  注意 要加-i才能修改文件生效

sed -i 's/^/#&/g' 123.txt    //每行添加行首字符# 注意 要加-i才能修改文件生效

4、编辑配置文件

  4.1编辑/etc/resolv.dnsmasq.conf配置文件

cp /etc/resolv.conf /etc/resolv.dnsmasq.conf
[root@localhost ~]# vim /etc/resolv.dnsmasq.conf 
nameserver 8.8.8.8  
[root@localhost ~]#

  4.2编辑 /etc/dnsmasq.hosts配置文件

cp /etc/hosts /etc/dnsmasq.hosts                
[root@localhost ~]# vim /etc/dnsmasq.hosts
127.0.0.1  localhost.localdomain localhost
::1  localhost6.localdomain6 localhost6
135.251.214.2 RMS.chinamobile.com *.chinamobile.com   #劫持域名映射到135.251.214.2

5、service dnsmasq restart  启动服务

[root@Apache zfp]# service dnsmasq start
Starting dnsmasq:                                          [确定]
[root@Apache zfp]#

[root@Apache zfp]# service dnsmasq status
dnsmasq (pid  1139) 正在运行...
[root@Apache zfp]#

6、查看53端口监听状态

[root@localhost ~]# netstat -tunlp |grep 53
tcp        0      0 0.0.0.0:53                  0.0.0.0:*                   LISTEN      2465/dnsmasq        
tcp        0      0 :::53                       :::*                        LISTEN      2465/dnsmasq        
udp        0      0 0.0.0.0:53                  0.0.0.0:*                               2465/dnsmasq        
udp        0      0 :::53                       :::*                                    2465/dnsmasq        
[root@localhost ~]#

7、设置随系统启动dnsmasq服务

[root@localhost ~]#chkconfig dnsmasq on   //随linux系统启动dnsmasq服务

[root@localhost ~]# chkconfig --list |grep dnsmasq    //查看是否设置成功
dnsmasq         0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@localhost ~]#

--------End Of Text-------

 

运维不懂开发,开发不懂运维,怎么办? 那就相互学习。 开发对于很多人来说是不是很难呢? C/JAVA/C++学起来难吗? 其实难吗?如果觉得难那就python吧, python大行其道,我们就学起来吧,她不用去通过代码去管理系统的资源,只让我们专心写代码就好,当然任何代码的学习都是要熟悉其API的(至少了解她有相关API功能,具体去用的时候,可以去查,那么多API你不可能都了如指掌),拿python来说,她的API也是多次封装(基于C/Java等等等,取决你使用的解释器)给python开发者使用的。 好吧,学习起来吧!

转载于:https://www.cnblogs.com/djoker/p/8317744.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值