实战solaris之域名系统文件配置

CWeeYii 2007-07-21

一、摘要
实战solaris之域名系统文件配置,配置/etc/ nsswitch.conf 、resolv.conf 、hosts

使服务器能够访问(ping)域名。

二、正文
#ping www.163.com
no answer from www.163.com

1.配置nsswitch.conf文件,主要是hosts项,如下所示:

#vi /etc/nsswitch.conf
#
# /etc/nsswitch.files:
#
# An example file that could be copied over to /etc/nsswitch.conf; it
# does not use any naming service.
#
# "hosts:" and "services:" in this file are used only if the
# /etc/netconfig file has a "-" for nametoaddr_libs of "inet" transports.

passwd: files
group: files
hosts: files dns
ipnodes: files
networks: files
protocols: files
rpc: files
ethers: files
netmasks: files
bootparams: files
publickey: files

# At present there isn't a 'files' backend for netgroup; the system will
# figure it out pretty quickly, and won't use netgroups at all.

netgroup: files
automount: files
aliases: files
services: files
sendmailvars: files
printers: user files

auth_attr: files
prof_attr: files
project: files

hosts: files dns

/*此处配置说明先用files后用dns;files配置见/etc/hosts;dns配置见/etc/resolv.conf*/

2.配置hosts文件
hosts配置本地域名解析。

#vi /etc/hosts
#
# Internet host table
#

127.0.0.1 localhost
218.25.254.24 loghost
192.168.4.102 ora-vp

3.配置resolv.conf文件
/etc/resolv.conf配置远程域名解析服务器,如下202.96.64.68为域名服务器。

#vi /etc/resolv.conf
nameserver 202.96.64.68

如上配置当ping loghost时,系统首先在/etc/hosts查找,由于nsswitch.conf文件中hosts项已配置,找到对应地址218.25.254.24;当ping www.163.com时,由于本地hosts没有找到匹配项,所以系统会访问resolv.conf中配置的域名服务器解析。

相关推荐

oLeiShen / 0评论 2020-05-26