网络应用程序抛出“ai_socktype 不支持 Servname”

anx*_*anx 3 networking services

为什么某些网络应用程序失败并显示此错误消息?

$ whois example.com
getaddrinfo(whois.verisign-grs.com): Servname not supported for ai_socktype
Run Code Online (Sandbox Code Playgroud)

anx*_*anx 5

当由于配置错误,非特权用户没有/etc/services. 检查:

ls -l /etc/services
Run Code Online (Sandbox Code Playgroud)

它应该看起来像-rw-r--r-- 1 root root ...

该文件应从Priority: important包安装netbase,并具有这些权限。如果没有,请使用以下方法修复:

sudo chown root:root /etc/services
sudo chmod 644 /etc/services
Run Code Online (Sandbox Code Playgroud)

文件内容的任何内容都不是机密的,也不会经常更改。该文件列出了TCP、UDP、DCCP 和 SCTP 的IANA 注册或通用协议端口号关联。