1

According to man nc

-n Do not do any DNS or service lookups on any specified addresses, hostnames or ports.

What I do not understand is why it needs to do any service lookup (also I do not know what services it is talking about for hostnames, addresses or ports except DNS) and if it is done, why is there a need to stop it for some specific netcat commands?

1 Answer 1

2
  • DNS resolution works both ways, i.e. it allows to convert a hostname to an IP address and vice versa. When you just want to use nc without doing any DNS resolution (which might be not working properly for you), you'll run it with -n to avoid any issues.

  • Service lookups is what is resolved via e.g. /etc/services, e.g. you may run nc this way:

nc 127.0.0.1 http

then http will be resolved to 80 via this file. You may also want to avoid using this feature.

There are many more ways to resolve (Name Service Switch), see

info libc 'NSS Basics'

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.