LINUX HPUX AIX 配置DNS域名解析
转载请注明出处:http://blog.csdn.net/xiaofan23z
Linux 配置DNS服务器
参数文件:
/etc/ nsswitch.conf
/etc/resolv.conf
1.配置 /etc/nsswitch.conf
[root@ldbrac1 etc]# cat nsswitch.conf
#
# /etc/nsswitch.conf
#
# An example Name Service Switch config file. This file should be
# sorted with the most-used services at the beginning.
#
# The entry '[NOTFOUND=return]' means that the search for an
# entry should stop if the search in the previous entry turned
# up nothing. Note that if the search failed due to some other reason
# (like no NIS server responding) then the search continues with the
# next entry.
#
# Legal entries are:
#
# nisplus or nis+ Use NIS+ (NIS version 3)
# nis or yp Use NIS (NIS version 2), also called YP
# dns Use DNS (Domain Name Service)
# files Use the local files
# db Use the local database (.db) files
# compat Use NIS on compat mode
# hesiod Use Hesiod for user lookups
# [NOTFOUND=return] Stop searching if not found so far
#
# To use db, put the "db" in front of "files" for entries you want to be
# looked up first in the databases
#
# Example:
#passwd: db files nisplus nis
#shadow: db files nisplus nis
#group: db files nisplus nis
passwd: files
shadow: files
group: files
#hosts: db files nisplus nis dns
hosts: files dns #默认首选本机hosts 备选DNS
# Example - obey only what nisplus tells us...
#services: nisplus [NOTFOUND=return] files
#networks: nisplus [NOTFOUND=return] files
#protocols: nisplus [NOTFOUND=return] files
#rpc: nisplus [NOTFOUND=return] files
#ethers: nisplus [NOTFOUND=return] files
#netmasks: nisplus [NOTFOUND=return] files
bootparams: nisplus [NOTFOUND=return] files
ethers: files
netmasks: files
networks: files
protocols: files
rpc: files
services: files
netgroup: files
publickey: nisplus
automount: files
aliases: files nisplus
[root@ldbrac1 etc]#
2. 配置/etc/resolv.conf
[root@ldbrac1 etc]# cat resolv.conf
; generated by /sbin/dhclient-script
search askey.com.tw #网域
nameserver 10.7.46.9 #首选DNS服务器
nameserver 10.7.22.1 #备选DNS服务器
AIX配置DNS服务器
参数文件
/etc/resolv.conf ##如没有可以手动创建
1.配置 / etc/netsvc.conf
jupiter:/etc# cat /etc/netsvc.conf
####
##文件最后加上如下语句
hosts = local,bind
# bind Uses BIND/DNS services for resolving names
# local Searches the local /etc/hosts file for resolving names
# nis Uses NIS services for resolving names. NIS must be running if you specify this option
当前的搜索顺序是 先本地/etc/hosts文件 之后NIS 然后DNS
2.配置/etc/resolv.conf
jupiter:/etc# cat resolv.conf
; generated by /sbin/dhclient-script
search askey.com.tw ##域名
nameserver 10.7.46.9 ##首选DNS服务器
nameserver 10.7.22.1 ##备选DNS服务器
3.测试
#test rac ldbrac ---xiaofan
#172.16.50.205 ldbrac1.l.com ldbrac1 ####屏蔽掉hosts文件中映射关系
#172.16.50.206 ldbrac2.l.com ldbrac2
172.16.50.225 ldbrac1-vip.l.com ldbrac1-vip
172.16.50.226 ldbrac2-vip.l.com ldbrac2-vip
"hosts" 115 lines, 4110 characters
jupiter:/etc# ping ldbrac1 #因为DNS中没有ldbrac1主机信息hosts文件也被注释掉 故无法到达
0821-062 ping: host name ldbrac1 NOT FOUND
jupiter:/etc# vi hosts
#test rac ldbrac ---xiaofan
172.16.50.205 ldbrac1.l.com ldbrac1 #### hosts文件中加入映射关系
172.16.50.206 ldbrac2.l.com ldbrac2
172.16.50.225 ldbrac1-vip.l.com ldbrac1-vip
172.16.50.226 ldbrac2-vip.l.com ldbrac2-vip
jupiter:/etc# ping ldbrac1
PING ldbrac1.l.com: (172.16.50.205): 56 data bytes ##通过hosts文件解析 可达
64 bytes from 172.16.50.205: icmp_seq=0 ttl=58 time=0 ms
64 bytes from 172.16.50.205: icmp_seq=1 ttl=58 time=1 ms
64 bytes from 172.16.50.205: icmp_seq=2 ttl=58 time=5 ms
###################################
# wms&webdb cluster ip
#10.7.46.13 wmsrac1 wmsrac1.askey.com.tw ##屏蔽掉该主机映射关系
10.7.46.15 wmsrac2 wmsrac2.askey.com.tw
10.7.46.113 wmsrac1-vip wmsrac1-vip.askey.com.tw
10.7.46.115 wmsrac2-vip wmsrac2-vip.askey.com.tw
jupiter:/etc# ping wmsrac1 ##依然可以通过DNS服务器解析
PING wmsrac1.askey.com.tw: (10.7.46.13): 56 data bytes
64 bytes from 10.7.46.13: icmp_seq=0 ttl=255 time=0 ms
64 bytes from 10.7.46.13: icmp_seq=1 ttl=255 time=0 ms
64 bytes from 10.7.46.13: icmp_seq=2 ttl=255 time=0 ms
jupiter:/etc# nslookup wmsrac1
Server: 10.7.46.9
Address: 10.7.46.9#53
Non-authoritative answer:
Name: wmsrac1.askey.com.tw
Address: 10.7.46.13
####################################
jupiter:/etc# nslookup MIS041.paskey.corpnet.asus
###网域内任意主机名 都可以通过DNS服务器解析到
Server: 10.7.46.9
Address: 10.7.46.9#53
Name: MIS041.paskey.corpnet.asus
Address: 10.7.68.147
jupiter:/etc# ping MIS041.paskey.corpnet.asus
PING MIS041.paskey.corpnet.asus: (10.7.68.147): 56 data bytes
64 bytes from 10.7.68.147: icmp_seq=0 ttl=125 time=0 ms
64 bytes from 10.7.68.147: icmp_seq=1 ttl=125 time=0 ms
64 bytes from 10.7.68.147: icmp_seq=2 ttl=125 time=0 ms
HP-UX 配置DNS服务器
参数文件:
/etc/ nsswitch.conf
/etc/resolv.conf
1. 配置nsswitch.conf文件(如不存在可手动创建内容参照nsswitch.hp_defaults)
sfcstb1:/etc$ cat nsswitch.conf
# example file that could be copied over to /etc/nsswitch.conf; it
# uses NIS (YP) in conjunction with files.
#
passwd: compat
group: compat
#hosts: dns [NOTFOUND=return] files [NOTFOUND=return] nis
#hosts: dns [NOTFOUND=return] nis [NOTFOUND=return] files ###default
hosts: dns [NOTFOUND=continue] files [NOTFOUND=return] nis
ipnodes: dns [NOTFOUND=return] nis [NOTFOUND=return] files
networks: nis [NOTFOUND=return] files
protocols: nis [NOTFOUND=return] files
rpc: nis [NOTFOUND=return] files
publickey: nis [NOTFOUND=return] files
netgroup: nis [NOTFOUND=return] files
automount: files nis
aliases: files nis
services: nis [NOTFOUND=return] files
sfcstb1:/etc$
首选域名解析为DNS 其次选择本地 hosts文件 最后为NIS服务
2. 配置resolv.conf文件(如果没有 则手动创建)
sfcstb1:/etc$ cat resolv.conf
; generated by /sbin/dhclient-script
search askey.com.tw ##域名
nameserver 10.7.46.9 ##本地首选DNS服务器
nameserver 10.7.22.1 ##本地备选DNS服务器
sfcstb1:/etc$
3. 测试
sfcstb1:/etc$ nslookup wmsrac1
Name Server: paskeywj-dc2-10.paskey.corpnet.asus
Address: 10.7.46.9
Trying DNS
Non-authoritative answer: ###通过DNS服务器解析到主机名
Name: wmsrac1.askey.com.tw
Address: 10.7.46.13
sfcstb1:/etc$ nslookup ldbrac2
Name Server: paskeywj-dc2-10.paskey.corpnet.asus
Address: 10.7.46.9
Trying DNS
looking up FILES ###DNS无法解析 查找到本机hosts文件解析到
Name: ldbrac2.l.com
Address: 172.16.50.206
Aliases: ldbrac2
#############################
将/etc/hosts 中ldbrac1 注释掉
#test rac ldbrac ---xiaofan
#172.16.50.205 ldbrac1.l.com ldbrac1
172.16.50.206 ldbrac2.l.com ldbrac2
172.16.50.225 ldbrac1-vip.l.com ldbrac1-vip
172.16.50.226 ldbrac2-vip.l.com ldbrac2-vip
"hosts" 76 lines, 1908 characters
sfcstb1:/etc# nslookup ldbrac1
Name Server: paskeywj-dc2-10.paskey.corpnet.asus
Address: 10.7.46.9
Trying DNS
looking up FILES ###DNS,本机hosts文件也无法找到 则无法解析
*** No address information is available for "ldbrac1"
sfcstb1:/etc#
#######################################
sfcstb1:/etc# nslookup MIS041.paskey.corpnet.asus
Name Server: paskeywj-dc2-10.paskey.corpnet.asus
Address: 10.7.46.9
Trying DNS ###########通过DNS服务器解析网域中任意主机名
Name: MIS041.paskey.corpnet.asus
Address: 10.7.68.147
#####################################
sfcstb1:/etc# nslookup 9X7EQIJU6688
Name Server: paskeywj-dc2-10.paskey.corpnet.asus
Address: 10.7.46.9
Trying DNS ###nslookup 任意未加入网域主机名 无法解析
looking up FILES
*** No address information is available for "9X7EQIJU6688"
####################################################################
4. 重新配置nsswitch.conf
sfcstb1:/etc# vi nsswitch.conf
"nsswitch.conf" 18 lines, 726 characters
# example file that could be copied over to /etc/nsswitch.conf; it
# uses NIS (YP) in conjunction with files.
#
passwd: compat
group: compat
#hosts: dns [NOTFOUND=return] files [NOTFOUND=return] nis
#hosts: dns [NOTFOUND=return] nis [NOTFOUND=return] files ###default
hosts: files [NOTFOUND=continue] dns [NOTFOUND=return] nis
####策略 首选本机hosts文件 如果失败则通过DNS服务器解析
ipnodes: dns [NOTFOUND=return] nis [NOTFOUND=return] files
networks: nis [NOTFOUND=return] files
protocols: nis [NOTFOUND=return] files
rpc: nis [NOTFOUND=return] files
publickey: nis [NOTFOUND=return] files
netgroup: nis [NOTFOUND=return] files
automount: files nis
aliases: files nis
services: nis [NOTFOUND=return] files
5.测试
###################### 屏蔽三台主机名在本地hosts文件的映射关系
10.7.46.4 smtp.local
#10.7.46.13 wmsrac1 ##wmsrac1该主机名存在于DNS服务器上
10.7.46.15 wmsrac2
10.7.46.113 wmsrac1-vip
10.7.46.115 wmsrac2-vip
172.16.51.141 sfc3rac1
172.16.51.142 sfc3rac2
172.16.51.143 sfc3rac1-vip
172.16.51.144 sfc3rac2-vip
10.7.46.143 bl460-esx-143.local
172.16.51.167 linuxrac2
#test rac ldbrac ---xiaofan
#172.16.50.205 ldbrac1.l.com ldbrac1 ##ldbrac1该主机名不存在于DNS服务器
#172.16.50.206 ldbrac2.l.com ldbrac2
172.16.50.225 ldbrac1-vip.l.com ldbrac1-vip
172.16.50.226 ldbrac2-vip.l.com ldbrac2-vip
#############################################
sfcstb1:/etc# nslookup wmsrac1
Using /etc/hosts on: sfcstb1
looking up FILES #########首选寻找本机hosts文件 –失败—>通过DNS服务器解析成功
Trying DNS
Non-authoritative answer:
Name: wmsrac1.askey.com.tw
Address: 10.7.46.13
sfcstb1:/etc# nslookup ldbrac1
Using /etc/hosts on: sfcstb1
looking up FILES #########首选查找本机hosts文件—失败—通过DNS服务器解析—失败
Trying DNS
*** paskeywj-dc2-10.paskey.corpnet.asus can't find ldbrac1: Non-existent domain
###########################################################
去掉hosts文件中对这三台主机的 注释
10.7.46.13 wmsrac1
10.7.46.15 wmsrac2
10.7.46.113 wmsrac1-vip
10.7.46.115 wmsrac2-vip
172.16.51.141 sfc3rac1
172.16.51.142 sfc3rac2
172.16.51.143 sfc3rac1-vip
172.16.51.144 sfc3rac2-vip
10.7.46.143 bl460-esx-143.local
172.16.51.167 linuxrac2
#sfc3rc1 sfc3rc2
10.7.46.12 sfc3rc1
10.7.46.14 sfc3rc2
#test rac ldbrac ---xiaofan
172.16.50.205 ldbrac1.l.com ldbrac1
172.16.50.206 ldbrac2.l.com ldbrac2
172.16.50.225 ldbrac1-vip.l.com ldbrac1-vip
172.16.50.226 ldbrac2-vip.l.com ldbrac2-vip
######################################################
sfcstb1:/etc# nslookup wmsrac1
Using /etc/hosts on: sfcstb1
looking up FILES #####通过首选hosts文件解析
Name: wmsrac1
Address: 10.7.46.13
sfcstb1:/etc# nslookup ldbrac1
Using /etc/hosts on: sfcstb1
looking up FILES #####通过首选hosts文件解析
Name: ldbrac1.l.com
Address: 172.16.50.205
Aliases: ldbrac1
#############################################################
解析本网域内任意主机名
sfcstb1:/etc# nslookup MIS041.paskey.corpnet.asus
Using /etc/hosts on: sfcstb1
looking up FILES ##解析我本机电脑主机名,查找本地hosts文件—失败—通过DNS解析成功
Trying DNS
Name: MIS041.paskey.corpnet.asus
Address: 10.7.68.147
转载请注明出处:http://blog.csdn.net/xiaofan23z
更多推荐
所有评论(0)