What should be done to ensure a client machine uses the recursive nameserver running on the IP address 192.168.0.1? (Choose TWO correct answers.)

A. Add nameserver 192.168.0.1 to /etc/resolv.conf.
B. Run route add nameserver 192.168.0.1.
C. Run ifconfig eth0 nameserver 192.168.0.1.
D. Ensure that the dns service is listed in the hosts entry in the /etc/nsswitch.conf file.
E. Run bind add nameserver 192.168.0.1.

题解

选项 A,GNU C 语言的函数库会根据「/etc/resolv.conf」设置档所定义的网域名称服务器来查找网域名称实际对应的 IP 地址。此为正确答案。

选项 B,不正确。

选项 C,不正确。

部份 GNU C 语言的函数库会根据本地端系统的设置不同而有不同的运作方式,像是 getaliasent、gethostbyname、getnetent 等等的函数。GNU C 语言的函数库会使用 NSS (Name Service Switch)来读取系统的数据库,数据库名称列表如下:

  • aliases
  • ethers
  • group
  • hosts
  • initgroups
  • netgroup
  • networks
  • passwd
  • protocols
  • publickey
  • rpc
  • services
  • shadow

NSS 的设置档「/etc/nsswitch.conf」决定了该数据库名称的数据取得的来源和顺序。如「files」表示来源为文件(设置档)、「db」表示来源为数据库、「dns」表示来源为网域名称服务器,而「compat」则有点像是「files」但同时能使用文件来过滤 NIS 来的数据。

所以选项 D,正确。

选项 E,不正确,「bind」指令用来显示或设置键盘按键与其相关的功能。