主机做不必要的dns查找localhost [英] host doing unnecessary dns lookup for localhost

查看:286
本文介绍了主机做不必要的dns查找localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个centOS系统(嵌入式和非常二进制)与以下/ etc / hosts。

I have a centOS system(embedded and has very binaries) with the following /etc/hosts.

$cat /etc/hosts
127.0.0.1 localhost localhost

主机也被分配一个DNS服务器为 localhost 的域名查找返回一些无效的IP。但我不能避免由于一些网络限制连接到这个DNS。

Also the host is assigned a DNS server which returns some invalid IP for the domain name lookup of localhost. But I cannot avoid a connection to this DNS due to some network restrictions.

我的问题是,当我已经有一个有效的/ etc / hosts文件为什么是系统查询DNS的 localhost

My question is, when I already have a valid /etc/hosts file why is the system querying the DNS for localhost? And how can I stop that?

任何帮助将非常感激。

推荐答案

检查 hosts 是否 dns c $ c>条目,位于 /etc/nsswitch.conf

Check that you have files listed before dns for the hosts entry in /etc/nsswitch.conf.

[me@home]$ grep "^hosts" /etc/nsswitch.conf 
hosts:      files dns

如果 dns ,那么您的系统将始终查询DNS以解析主机名,然后再返回 / etc / hosts

If dns comes first, then your system will always query DNS to resolve hostnames before falling back to /etc/hosts.

这篇关于主机做不必要的dns查找localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆