本文主要是介绍Linux中如何直接ping 主机名,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
[root@hadoop7 redis01]# vi /etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.238.20 hadoop7
vi修改/hosts文件,在最下面加上一行192.168.238.20 hadopp7(本机IP 主机名)
改完之后测试一下,ping本机IP。。。ok,ping主机名。。也通了。
"/etc/hosts" 3L, 218C written[root@hadoop7 redis01]# ping 192.168.238.20
PING 192.168.238.20 (192.168.238.20) 56(84) bytes of data.
64 bytes from 192.168.238.20: icmp_seq=1 ttl=64 time=0.013 ms
64 bytes from 192.168.238.20: icmp_seq=2 ttl=64 time=0.025 ms
--- 192.168.238.20 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1515ms
rtt min/avg/max/mdev = 0.013/0.019/0.025/0.006 ms[root@hadoop7 redis01]# ping hadoop7
PING hadoop7 (192.168.238.20) 56(84) bytes of data.
64 bytes from hadoop7 (192.168.238.20): icmp_seq=1 ttl=64 time=0.014 ms
64 bytes from hadoop7 (192.168.238.20): icmp_seq=2 ttl=64 time=0.034 ms
--- hadoop7 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1946ms
rtt min/avg/max/mdev = 0.014/0.024/0.034/0.010 ms
这篇关于Linux中如何直接ping 主机名的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!