سؤال

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