Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nc command: inverse host lookup failed: Unknown host

Tags:

unix

netcat

nc works fine when i execute it on a VM.

Connection to 10.0.0.10 22 port [tcp/ssh] succeeded!

But when I execute the same command inside my docker container, it gives the below UNKNOWN error/exception.

10.0.0.10: inverse host lookup failed: Unknown host 
(UNKNOWN) [10.0.0.10] 22 (ssh) open

Below is the nc command that I am using:

nc -vz 10.0.0.10 22 -w 4
like image 217
Rohith Avatar asked Feb 14 '18 04:02

Rohith


2 Answers

"Inverse host lookup failed" simply means that nc wanted to print which host name 10.0.0.10 corresponds to, but couldn't.

UNKNOWN is simply what it then prints as the host name.

This is distinct from "I looked it up, but it doesn't seem to correspond to anything" which is what happens outside the container.

To be perfectly explicit, connecting to the host succeeded, but looking up its name from the IP address failed. This is just an informational warning message, not a hard error; the lookup is entirely optional, anyway, and can be disabled with -n.

If you really want to avoid this warning and not switch to -n, you need to set up working DNS inside the container.

like image 101
tripleee Avatar answered Oct 30 '22 01:10

tripleee


simply put -n on both sides of listener and client to remove this error as it will neglect the DNS look up by using it.

like image 9
siddharth Avatar answered Oct 30 '22 01:10

siddharth