[20161221]快速建立dns服务器.txt

[20161221]快速建立dns服务器.txt

--建立dns对我来讲如同噩梦,我记得以前当开始学linux时就配置过一次,里面参数我根本不熟悉,而且是看这一本书做的,那本书存在印刷
--错误,导致自己调式遇到许多问题.所以我对dns的配置一直有点心理上害怕。

--而11Grac需要一个dns,学习一些配置dns非常必要,昨天我重新看了文档,先学习一个简单的配置就是使用dnsmasq软件包.感觉它很简单.

1.环境:

# cat /etc/issue
Oracle Linux Server release 5.9
Kernel \r on an \m

# rpm -qil dnsmasq
Name        : dnsmasq                      Relocations: (not relocatable)
Version     : 2.45                              Vendor: Oracle USA
Release     : 1.1.el5_3                     Build Date: Tue 01 Sep 2009 09:27:24 AM CST
Install Date: Fri 29 Aug 2014 09:30:39 PM CST      Build Host: ca-build9.us.oracle.com
Group       : System Environment/Daemons    Source RPM: dnsmasq-2.45-1.1.el5_3.src.rpm
Size        : 358490                           License: GPL
Signature   : DSA/SHA1, Tue 01 Sep 2009 09:27:36 AM CST, Key ID 66ced3de1e5e0159
URL         : http://www.thekelleys.org.uk/dnsmasq/
Summary     : A lightweight DHCP/caching DNS server
Description :
Dnsmasq is lightweight, easy to configure DNS forwarder and DHCP server.
It is designed to provide DNS and, optionally, DHCP, to a small network.
It can serve the names of local machines which are not in the global
DNS. The DHCP server integrates with the DNS server and allows machines
with DHCP-allocated addresses to appear in the DNS with names configured
either in each host or in a central configuration file. Dnsmasq supports
static and dynamic DHCP leases and BOOTP for network booting of diskless
machines.
/etc/dnsmasq.conf
/etc/dnsmasq.d
/etc/rc.d/init.d/dnsmasq
/usr/sbin/dnsmasq
/usr/share/doc/dnsmasq-2.45
/usr/share/doc/dnsmasq-2.45/CHANGELOG
/usr/share/doc/dnsmasq-2.45/COPYING
/usr/share/doc/dnsmasq-2.45/DBus-interface
/usr/share/doc/dnsmasq-2.45/FAQ
/usr/share/doc/dnsmasq-2.45/doc.html
/usr/share/doc/dnsmasq-2.45/setup.html
/usr/share/man/man8/dnsmasq.8.gz

-- 感觉这个就足够了.很明显配置文件/etc/dnsmasq.conf与目录/etc/dnsmasq.d。
# rpm -qc dnsmasq
/etc/dnsmasq.conf

2.我需要配置的IP如下:
#SCAN IP
#192.168.200.101 xxxscan
#192.168.200.102 xxxscan
#192.168.200.103 xxxscan

--//仅仅3个scan-ip.

3.修改/etc/resolv.conf,加入名字服务器:
# cat /etc/resolv.conf
search localdomain
nameserver 192.168.100.78
nameserver 192.168.101.7

--也就是本机(192.168.100.78,这行要写在前面,我不知道为什么??),如果你存在别的dns服务器,可以在这里加入:

4.配置/etc/dnsmasq.conf文件:
# grep -v "^#" /etc/dnsmasq.conf | grep '^[a-zA-Z]'
conf-dir=/etc/dnsmasq.d

--仅仅1行,其他全是注解,注:如果改动建立做1个备份.
--我修改如下注解上面那行,加入:
# cat /etc/dnsmasq.conf
# conf-dir=/etc/dnsmasq.d
addn-hosts=/etc/dnsmasq.d/rachosts

5.建立/etc/dnsmasq.d/rachosts文件,包括全部需要解析的主机名.
# cat   /etc/dnsmasq.d/rachosts
192.168.200.101  xxxscan
192.168.200.102  xxxscan
192.168.200.103  xxxscan

--实际上步骤很简单就是包括1个全部机器的文本文件,加入addn-hosts=/etc/dnsmasq.d/rachosts这行在配置文件中.

6.启动dbsmasq:
# service dnsmasq start
Starting dnsmasq:          [  OK  ]

6.测试:
# nslookup xxxscan
Server:         192.168.100.78
Address:        192.168.100.78#53

Name:   xxxscan
Address: 192.168.200.103
Name:   xxxscan
Address: 192.168.200.101
Name:   xxxscan
Address: 192.168.200.102

# nslookup 192.168.200.101
Server:         192.168.100.78
Address:        192.168.100.78#53

101.200.168.192.in-addr.arpa    name = xxxscan.

# nslookup 192.168.200.102
Server:         192.168.100.78
Address:        192.168.100.78#53

102.200.168.192.in-addr.arpa    name = xxxscan.

# nslookup 192.168.200.103
Server:         192.168.100.78
Address:        192.168.100.78#53

103.200.168.192.in-addr.arpa    name = xxxscan.

# nslookup 127.0.0.1
Server:         192.168.100.78
Address:        192.168.100.78#53

1.0.0.127.in-addr.arpa  name = localhost.localdomain.

# nslookup localhost
Server:         192.168.100.78
Address:        192.168.100.78#53

Name:   localhost.localdomain
Address: 127.0.0.1

--//这样配置小型的dns简单多了,快捷简单实用。

7.其他机器仅仅需要配置:
# cat   /etc/resolv.conf
nameserver 192.168.100.78

--我参考了链接:http://www.oracle-base.com/articles/linux/dnsmasq-for-simple-dns-configurations.php
--按照他的说明,你什么都不要做,仅仅将主机列表写入/etc/hosts文件就ok了.我自己也测试1次确实这样.剩下仅仅启动dnsmasq服务.
--我觉得这个太合适小网络的配置了.根本无需了解dns细节.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-2131095/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/267265/viewspace-2131095/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值