我在 Raspbian 上,我尝试通过以下方式接收数据:
nc -4 -l -v -k -p 5004
这导致:
Listening on [0.0.0.0] (family 2, port 5004)
nc: getnameinfo: Temporary failure in name resolution
路线命令返回这个:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.11.10.1 0.0.0.0 UG 0 0 0 00c0caaaeb87
10.11.10.0 0.0.0.0 255.255.255.0 U 0 0 0 00c0caaaeb87
网关可达:
PING 10.11.10.1 (10.11.10.1) 56(84) bytes of data.
64 bytes from 10.11.10.1: icmp_seq=1 ttl=64 time=4.03 ms
这是ip:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether b8:27:eb:4b:46:37 brd ff:ff:ff:ff:ff:ff
3: intwifi0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether b8:27:eb:1e:13:62 brd ff:ff:ff:ff:ff:ff
4: 00c0caaaeb87: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 2304 qdisc mq state UP group default qlen 1000
link/ether 00:c0:ca:aa:eb:87 brd ff:ff:ff:ff:ff:ff
inet 10.11.10.10/24 brd 10.11.10.255 scope global 00c0caaaeb87
valid_lft forever preferred_lft forever
相反,如果我连接 eth0 并执行:dhclient eth0。数控启动工作正常。我缺少什么?
这是两种状态的 /etc/resolv.conf 的内容是相同的:
# Generated by resolvconf
nameserver 10.11.10.1
这是 nc 进程的 strace 输出:
strace: Process 1780 attached
accept(3, {sa_family=AF_INET, sin_port=htons(41250), sin_addr=inet_addr("10.11.10.11")}, [128->16]) = 4
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 5
connect(5, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(5) = 0
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 5
connect(5, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)
close(5) = 0
open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 5
fstat64(5, {st_mode=S_IFREG|0644, st_size=497, ...}) = 0
read(5, "# /etc/nsswitch.conf\n#\n# Example"..., 4096) = 497
read(5, "", 4096) = 0
close(5) = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 5
fstat64(5, {st_mode=S_IFREG|0644, st_size=104908, ...}) = 0
mmap2(NULL, 104908, PROT_READ, MAP_PRIVATE, 5, 0) = 0x76f45000
close(5) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 5
read(5, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\240\31\0\0004\0\0\0"..., 512) = 512
lseek(5, 37440, SEEK_SET) = 37440
read(5, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1120) = 1120
lseek(5, 37088, SEEK_SET) = 37088
read(5, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\23\1\24"..., 47) = 47
fstat64(5, {st_mode=S_IFREG|0644, st_size=38560, ...}) = 0
mmap2(NULL, 127744, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 5, 0) = 0x76d98000
mprotect(0x76da1000, 61440, PROT_NONE) = 0
mmap2(0x76db0000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 5, 0x8000) = 0x76db0000
mmap2(0x76db2000, 21248, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x76db2000
close(5) = 0
mprotect(0x76db0000, 4096, PROT_READ) = 0
munmap(0x76f45000, 104908) = 0
getpid() = 1780
open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 5
fstat64(5, {st_mode=S_IFREG|0644, st_size=48, ...}) = 0
read(5, "# Generated by resolvconf\nnamese"..., 4096) = 48
read(5, "", 4096) = 0
close(5) = 0
uname({sysname="Linux", nodename="rx", ...}) = 0
open("/etc/host.conf", O_RDONLY|O_CLOEXEC) = 5
fstat64(5, {st_mode=S_IFREG|0644, st_size=9, ...}) = 0
read(5, "multi on\n", 4096) = 9
read(5, "", 4096) = 0
close(5) = 0
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 5
fstat64(5, {st_mode=S_IFREG|0644, st_size=119958, ...}) = 0
read(5, "127.0.0.1\tlocalhost\n::1\t\tlocalho"..., 4096) = 4096
close(5) = 0
open("/etc/hosts", O_RDONLY|O_CLOEXEC) = 5
fstat64(5, {st_mode=S_IFREG|0644, st_size=119958, ...}) = 0
read(5, "127.0.0.1\tlocalhost\n::1\t\tlocalho"..., 4096) = 4096
read(5, "0.1 wbc\n127.0.0.1 wbc\n127.0.0.1 "..., 4096) = 4096
read(5, "1 wbc\n127.0.0.1 wbc\n127.0.0.1 wb"..., 4096) = 4096
read(5, "1 wbc\n127.0.0.1 wbc\n127.0.0.1 wb"..., 4096) = 4096
read(5, "\n127.0.0.1 groundpi\n127.0.0.1 wb"..., 4096) = 4096
read(5, "\n127.0.0.1 wbc\n127.0.0.1 wbc\n127"..., 4096) = 4096
read(5, "127.0.0.1 wbc\n127.0.0.1 wbc\n127."..., 4096) = 4096
read(5, "127.0.0.1 wbc\n127.0.0.1 wbc\n127."..., 4096) = 4096
read(5, "bc\n127.0.0.1 wbc\n127.0.0.1 wbc\n1"..., 4096) = 4096
read(5, "0.1 wbc\n127.0.0.1 wbc\n127.0.0.1 "..., 4096) = 4096
read(5, "bc\n127.0.0.1 wbc\n127.0.0.1 groun"..., 4096) = 4096
read(5, ".1 wbc\n127.0.0.1 wbc\n127.0.0.1 w"..., 4096) = 4096
read(5, ".0.0.1 wbc\n127.0.0.1 wbc\n127.0.0"..., 4096) = 4096
read(5, ".0.0.1 wbc\n127.0.0.1 wbc\n127.0.0"..., 4096) = 4096
read(5, "0.0.1 groundpi\n127.0.0.1 wbc\n127"..., 4096) = 4096
read(5, ".0.0.1 wbc\n127.0.0.1 wbc\n127.0.0"..., 4096) = 4096
read(5, "7.0.0.1 wbc\n127.0.0.1 wbc\n127.0."..., 4096) = 4096
read(5, "127.0.0.1 wbc\n127.0.0.1 wbc\n127."..., 4096) = 4096
read(5, "0.1 wbc\n127.0.0.1 wbc\n127.0.0.1 "..., 4096) = 4096
read(5, "0.1 wbc\n127.0.0.1 wbc\n127.0.0.1 "..., 4096) = 4096
read(5, ".0.1 wbc\n127.0.0.1 wbc\n127.0.0.1"..., 4096) = 4096
read(5, "1 wbc\n127.0.0.1 groundpi\n127.0.0"..., 4096) = 4096
read(5, "c\n127.0.0.1 wbc\n127.0.0.1 ground"..., 4096) = 4096
read(5, "1 wbc\n127.0.0.1 wbc\n127.0.0.1 wb"..., 4096) = 4096
read(5, "\n127.0.0.1 wbc\n127.0.0.1 wbc\n127"..., 4096) = 4096
read(5, ".0.0.1 wbc\n127.0.0.1 wbc\n127.0.0"..., 4096) = 4096
read(5, "127.0.0.1 wbc\n127.0.0.1 wbc\n127."..., 4096) = 4096
read(5, "\n127.0.0.1 rx\n127.0.0.1 wbc\n127."..., 4096) = 4096
read(5, "0.0.1 wbc\n127.0.0.1 wbc\n127.0.0."..., 4096) = 4096
read(5, "1 rx\n127.0.0.1 wbc\n127.0.0.1 wbc"..., 4096) = 1174
read(5, "", 4096) = 0
close(5) = 0
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 5
fstat64(5, {st_mode=S_IFREG|0644, st_size=104908, ...}) = 0
mmap2(NULL, 104908, PROT_READ, MAP_PRIVATE, 5, 0) = 0x76f45000
close(5) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/arm-linux-gnueabihf/libnss_dns.so.2", O_RDONLY|O_CLOEXEC) = 5
read(5, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\220\n\0\0004\0\0\0"..., 512) = 512
lseek(5, 16892, SEEK_SET) = 16892
read(5, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1120) = 1120
lseek(5, 16540, SEEK_SET) = 16540
read(5, "A.\0\0\0aeabi\0\1$\0\0\0\0056\0\6\6\10\1\t\1\n\2\22\4\23\1\24"..., 47) = 47
fstat64(5, {st_mode=S_IFREG|0644, st_size=18012, ...}) = 0
mmap2(NULL, 82080, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 5, 0) = 0x76d83000
mprotect(0x76d87000, 61440, PROT_NONE) = 0
mmap2(0x76d96000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 5, 0x3000) = 0x76d96000
close(5) = 0
mprotect(0x76d96000, 4096, PROT_READ) = 0
munmap(0x76f45000, 104908) = 0
stat64("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=48, ...}) = 0
open("/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 5
fstat64(5, {st_mode=S_IFREG|0644, st_size=48, ...}) = 0
read(5, "# Generated by resolvconf\nnamese"..., 4096) = 48
read(5, "", 4096) = 0
close(5) = 0
uname({sysname="Linux", nodename="rx", ...}) = 0
socket(AF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 5
connect(5, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.7.208.3")}, 16) = 0
poll([{fd=5, events=POLLOUT}], 1, 0) = 1 ([{fd=5, revents=POLLOUT}])
send(5, ".\242\1\0\0\1\0\0\0\0\0\0\00211\00210\00211\00210\7in-addr"..., 42, MSG_NOSIGNAL) = 42
poll([{fd=5, events=POLLIN}], 1, 5000) = 0 (Timeout)
poll([{fd=5, events=POLLOUT}], 1, 0) = 1 ([{fd=5, revents=POLLOUT}])
send(5, ".\242\1\0\0\1\0\0\0\0\0\0\00211\00210\00211\00210\7in-addr"..., 42, MSG_NOSIGNAL) = 42
poll([{fd=5, events=POLLIN}], 1, 5000) = 0 (Timeout)
close(5) = 0
write(2, "nc: ", 4) = 4
write(2, "getnameinfo: Temporary failure i"..., 49) = 49
write(2, "\n", 1) = 1
exit_group(1) = ?
+++ exited with 1 +++
答案1
nc -n
-n 仅数字 IP 地址,无 DNS
有了这个我已经解决了