免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2459 | 回复: 1
打印 上一主题 下一主题

gethostbyname()问题,高手请进 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-07-10 17:50 |只看该作者 |倒序浏览
[linux系统]:我用gethostbyname("zhxj")查找局域网中的一台机器,结果是返回NULL,并且h_error的值为1,我的
/etc/hosts文件为:
127.0.0.1       localhost.localdomain   localhost

/etc/host.conf为:
order hosts,bind
multi on

/etc/nsswitch.conf为:
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.

passwd:         files
group:          files
shadow:         files

hosts:          files dns
networks:       files

protocols:      files
services:       files
ethers:         files
rpc:            files

netgroup:       files

/etc/resolv.conf为:
nameserver 192.168.15.77


如果我在/etc/hosts中加入
"192.168.15.105 zhxj"一行,那么gethostbyname("zhxj")就能得到正确的返回值,不加的话,什么包也没有发出去,我通过抓包看的.其中192.168.15.77是内部的DNS,请问是什么原因??按照/etc/nsswitch.conf的配置来说,应该是会到DNS去查找的,不知对否??

论坛徽章:
0
2 [报告]
发表于 2007-07-11 16:28 |只看该作者

回复 #1 kimon_hxj 的帖子

没人知道?帮忙分析一下嘛
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP