On windows:
_.github.com
in the browser works nslookup _.github.com
works ping _.github.com
works On linux (tested on two separate networks):
_.github.com
in the browser works host _.github.com
works ping _.github.com
does not python -c "import requests; requests.get('_.github.com')"
does not What is going on here?
Because Linux (more specifically, some component of it such as libresolv or even ping itself) is honoring the RFCs. Underscores are not allowed in hostnames, and a hostname is what you are looking up when using ping. (Underscores are allowed in other types of DNS records, for example SRV records, TXT records such as those used for DKIM...)
See RFC 1123 section 2.1, and RFC 952 . Here are some other links to discussion of this topic:
Stack Overflow - Can (hostname) subdomains have an underscore “_” in it?
Domainkey - Underscores in DNS
Quora - Why are underscores not allowed in DNS host names?
Update : As a couple of people pointed out in comments, Linux ping is happy with a_a.github.com
. Doing a few more tests (CentOS 7 in this case):
ping: unknown host _.github.com
ping: unknown host a_.github.com
ping: unknown host _a.github.com
$ ping a_a.github.com
PING github.map.fastly.net (23.235.40.133) 56(84) bytes of data.
64 bytes from 23.235.40.133: icmp_seq=1 ttl=59 time=29.7 ms
So it seems Linux ping does not reject the underscore completely, but it does appear it disallows it being the first or last character (or, as a consequence, the only character) in an atom of the hostname.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.