Linux:更快速的搭建一个DNS服务
就像你前面看到的那样,要在Linux或者MS Windows中搭建一个DNS其实都是挺麻烦的一件事情。
Linux:http://d-prototype.com/archives/467
MS Windows:http://d-prototype.com/archives/2939
本文接下来将呈现的方式可以让DNS的配置比起上述两个实现要简单得多。
它主要靠两个东西实现:
1. /etc/hosts
2. dnsmasq
下面开始:
一、确认是否安装了dnsmasq软件包:
1 2 3 4 5 6 7 |
[root@CenterServer src]# rpm -qa | grep dns dnsmasq-2.48-14.el6.x86_64 mod_dnssd-0.6-2.el6.x86_64 [root@CenterServer src]# [root@CenterServer src]# service dnsmasq status dnsmasq is stopped [root@CenterServer src]# |
当前环境已安装了:dnsmasq,并且状态是关闭的。
如果没有安装dnsmasq,那么可以通过YUM简单的完成安装:yum install dnsmasq
启动dnsmasq服务,并开机生效:
1 2 3 4 5 6 7 |
[root@CenterServer src]# service dnsmasq start Starting dnsmasq: [ OK ] [root@CenterServer src]# [root@CenterServer src]# chkconfig dnsmasq on [root@CenterServer src]# chkconfig dnsmasq --list dnsmasq 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@CenterServer src]# |
配置/etc/hosts:
1 2 3 4 5 6 7 8 |
[root@CenterServer src]# cat /etc/hosts # Localhost 127.0.0.1 localhost # Pub 192.168.136.131 CenterServer [root@CenterServer src]# |
测试:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
[root@CenterServer src]# nslookup > server Default server: 192.168.136.2 Address: 192.168.136.2#53 > > server 192.168.136.131 Default server: 192.168.136.131 Address: 192.168.136.131#53 > > 192.168.136.131 Server: 192.168.136.131 Address: 192.168.136.131#53 131.136.168.192.in-addr.arpa name = CenterServer. > > CenterServer. Server: 192.168.136.131 Address: 192.168.136.131#53 Name: CenterServer Address: 192.168.136.131 > > exit [root@CenterServer src]# |
————————————————————————
Done。