문제

I am trying to do a get via netcat to this address:

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

I get the error:

nc: getaddrinfo: nodename nor servname provided, or not known

What am I doing wrong?

도움이 되었습니까?

해결책

The path should be in the request line (the first line) after the method name (GET in this case). Currently you tell nc to look up the hostname www.iana.org/domains/reserved which will fail. Also the "Host" header should not include the path, only the hostname.

This should work:

printf 'GET /domains/reserved HTTP/1.1\r\nHost: www.iana.org\r\nConnection: close\r\n\r\n' | nc www.iana.org 80
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top