Linux 中如何解析一个带有下划线的域名

2019-04-25 16:09:47 +08:00
 whoami9894

我知道 RFC 文档规定域名不能带下划线,是为了测试 CORS 头的绕过

我将域名这样设置:

198.1.1.1  *.cors.exp.com

在我的 Windows 主机下可以正常 ping 通,浏览器可正常访问

在 Linux 里( Centos,Ubuntu ),dns 可正常解析(都设置了 114DNS )

$ nslookup ss_.cors.iv4n.xyz
Server:         127.0.1.1
Address:        127.0.1.1#53

Non-authoritative answer:
Name:   ss_.cors.exp.com
Address: 198.1.1.1

但是 ping 指令和 http client 貌似无法解析带下划线的域名,返回unknown host ss_.cors.exp.com

1851 次点击
所在节点    问与答
7 条回复
dog
2019-04-25 16:46:06 +08:00
解析是没问题的,unknown host 是服务器那边包装的 404 响应,在 Windows 下用 Chrome 打开也是一样的结果
xcai
2019-04-25 17:01:15 +08:00
$ ping ss_.cors.exp.com
PING ss_.cors.exp.com (23.185.0.2) 56(84) bytes of data.
64 bytes from 23.185.0.2 (23.185.0.2): icmp_seq=1 ttl=53 time=87.9 ms
64 bytes from 23.185.0.2 (23.185.0.2): icmp_seq=2 ttl=53 time=95.8 ms
64 bytes from 23.185.0.2 (23.185.0.2): icmp_seq=3 ttl=53 time=85.5 ms
whoami9894
2019-04-25 17:02:22 +08:00
@dog
您说的我没理解...是 ping 返回了 unknown host,网络层协议为什么会有 404 响应。我在 Windows 下 ff, chrome, curl 都是可以的
whoami9894
2019-04-25 17:03:36 +08:00
@xcai
exp.com 是举个栗子...没想到真有这个站
ysc3839
2019-04-25 17:21:23 +08:00
@whoami9894 举例子的话建议使用 example.com
这个域名就是专门给你举例子的。
Example Domain
This domain is established to be used for illustrative examples in documents. You may use this domain in examples without prior coordination or asking for permission.
dog
2019-04-25 17:22:35 +08:00
@whoami9894 我是直接打开你贴的网址,结果你说是例子………………
whoami9894
2019-04-25 18:15:23 +08:00
@ysc3839
@dog
不好意思,已 append 修改为`ss_.cors.example.com`

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/558643

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX