uname -a
Linux XXXX 3.10.0-123.9.3.el7.x86_64 #1 SMP Thu Nov 6 15:06:03 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
修改了/etc/host.con文件
order hosts,bind
multi on
也修改了/etc/hosts文件
192.168.0.1 a
192.168.0.2 a
192.168.0.3 a
3个ip都是a主机的ip
为什么ping a的时候就只能是第一条(192.168.0.1 a)生效了???
Researched it: Check the manual of host.conf and you can see the instructions:
The resolver library is not ping, ping will only take the first one of get, you can pass:
To get the effective configuration in the hosts configuration, the getent command is used to get the contents of important configuration files.
getnet hosts is actually ultimately parsed by calling the gethostbyname system api function, so you can get the server by calling gethostbyname in the code The IP corresponding to the name is as follows:
Execution result: