Netcat throws a "getnameinfo: Temporary failure in name resolution" error
Asked Answered
H

2

6

When I run the following command: nc -luvp 9090, I get the error: getnameinfo: Temporary failure in name resolution

I've scanned the internet in search of an answer, but none of them were valid:

I found this link: https://unix.stackexchange.com/questions/504963/how-to-solve-a-temporary-failure-in-name-resolution-error And tried the most upvoted answer. My results:

netcat_name_resolution_error

I'm using NordVPN, which uses its own DNS servers. But I tried disabling it completely, and I get the same exact result. I'm afraid it messed up with my DNS config file and/or firewall rules.

I'm kinda new to Linux and feel a bit lost.

Hootman answered 6/5, 2020 at 23:9 Comment(0)
E
11

The problem could be with the DNS resolver. Try updating the namespace in /etc/resolv.conf as follows.

nameserver 8.8.8.8
Eventuate answered 6/7, 2020 at 15:52 Comment(2)
To implement this: Open the command line and type sudo nano /etc/resolv.conf. At the editor, after doing what's above, use CTRL + O to save and CTRL + X to exit. Reboot at the endApollyon
@VascoCansadoCarvalho I feel we can simply do sudo gedit instead of nano, it's GUI so I feel it's betterPanaggio
V
8

You seem to be using systemd-resolved for your DNS resolver, which seems unable to resolve 0.0.0.0:

$ resolvectl query 0.0.0.0
0.0.0.0: resolve call failed: No appropriate name servers or networks for name found

$ host 0.0.0.0 127.0.0.53
Using domain server:
Name: 127.0.0.53
Address: 127.0.0.53#53
Aliases:

Host 0.0.0.0.in-addr.arpa not found: 2(SERVFAIL)

This is the address netcat is trying to resolve and fails (in my tests at least). One solution is to add a static association by adding the following line in /etc/hosts:

0.0.0.0    localhost

netcat should not abort for such a harmless DNS failure (it works when using the -n switch or removing the -v switch) and systemd-resolved should probably not send SERVFAIL when resolving 0.0.0.0.

Velvavelvet answered 22/3, 2021 at 15:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.