Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试通过 netcat 获取此地址:
printf 'GET / HTTP/1.1\r\nHost: www.iana.org/domains/reserved\r\nConnection: close\r\n\r\n' | nc www.iana.org/domains/reserved 80
我得到错误:
nc: getaddrinfo: nodename nor servname provided, or not known
我究竟做错了什么?
路径应位于方法名称(在本例中为 GET)之后的请求行(第一行)中。目前,您告诉nc查找www.iana.org/domains/reserved将失败的主机名。此外,“主机”标头不应包含路径,仅包含主机名。
nc
www.iana.org/domains/reserved
这应该有效:
printf 'GET /domains/reserved HTTP/1.1\r\nHost: www.iana.org\r\nConnection: close\r\n\r\n' | nc www.iana.org 80