3

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?

1 Answer 1

4

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.