App->nsswitch->resolve_lib
libnss
/etc/nsswitch.conf主配置文件
# 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
# 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
nisplus返回值:
SUCCESS service ok,found name 服务正常,并且转到了值
NOTFOUND service ok,name not found 服务正常,名字没有转换到值
UNAVAAIL service not available 服务找不到,当UNACAAIL时 会找files
TRYAGAIN temporary service failure 临时性故障,再试一次
bootparams: nisplus [NOTFOUND=return] files
ethers: files
netmasks: files
networks: files
protocols: files
rpc: files
services: files
netgroup: nisplus
publickey: nisplus
automount: files nisplus
aliases: files nisplus
[[email protected] lib]# vim /etc/protocols
[[email protected] ~]# vim /etc/services
名称解析服务:
nsswitch调用/usr/lib里对应的库文件进行解析
getent获取nsswitch里某个库的所有条目
[[email protected] ~]# getent passwd
[[email protected] ~]# getent passwd root
root:x:0:0:root:/root:/bin/bash
[[email protected] ~]# getent hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1 localhost localhost.localdomain localhost6 localhost6.localdomain6
[[email protected] ~]# getent hosts www.baidu.com 先到hosts里找如果没有再通过dns找
180.97.33.107 www.a.shifen.com www.baidu.com
180.97.33.108 www.a.shifen.com www.baidu.com