我在 Qualcomm 主板上安装了汽车级 Linux (Halibut 8.0.0)。我可以打开以太网。
sa8155:~# ifconfig eth0 up
sa8155:~# udhcpc
udhcpc: started, v1.29.3
udhcpc: sending discover
udhcpc: sending select for 10.0.0.112
udhcpc: lease of 10.0.0.112 obtained, lease time 604800
/etc/udhcpc.d/50default: Adding DNS 75.75.75.75
/etc/udhcpc.d/50default: Adding DNS 75.75.76.76
请注意,DHCP 报告正在正确检索名称服务器。
我可以 ping 名称服务器:
sa8155:~# ping 75.75.75.75
PING 75.75.75.75 (75.75.75.75): 56 data bytes
64 bytes from 75.75.75.75: seq=0 ttl=58 time=8.973 ms
64 bytes from 75.75.75.75: seq=1 ttl=58 time=19.634 ms
64 bytes from 75.75.75.75: seq=2 ttl=58 time=11.391 ms
但是,我无法使用 DNS 来解析任何名称。
sa8155:~# nslookup debian.org
nslookup: write to '127.0.0.1': Connection refused
;; connection timed out; no servers could be reached
我注意到 /etc/resolv.conf 除了这个注释之外是空的:
sa8155:~# cat /etc/resolv.conf
# Generated by Connection Manager
我尝试手动编辑 /etc/resolv.conf,如下所示:
sa8155:~# cat /etc/resolv.conf
# Generated by Connection Manager
search example.com local.test
nameserver 75.75.75.75
nameserver 75.75.76.76
但这似乎完全禁用了以太网接口。
sa8155:~# nslookup www.google.com
nslookup: write to '127.0.0.1': Connection refused
;; connection timed out; no servers could be reached
我尝试手动将单个主机和 IP 地址对添加到 /etc/hosts,但即使我是 root,我也无法编辑该文件。
sa8155:~# ls -alF /etc/ | grep host
-rw-r--r-- 1 root root 26 Nov 13 2019 host.conf
-rw-r--r-- 1 root root 111912 Nov 13 2019 hostapd.conf
-rw-r--r-- 1 root root 7 Nov 13 2019 hostname
-rw-r--r-- 1 root root 237 Nov 13 2019 hosts
-rw-r--r-- 1 root root 0 Nov 13 2019 hosts.allow
-rw-r--r-- 1 root root 0 Nov 13 2019 hosts.deny
sa8155:~# chmod 766 /etc/hosts
chmod: changing permissions of `/etc/hosts': Read-only file system
所以我尝试使用 ConnMan 添加 DNS 条目。
但是,connmanctl 服务不会返回预期的列表。
sa8155:~# connmanctl services
Error: The name net.connman was not provided by any .service files
sa8155:~#
更新:cat /etc/nsswitch.conf
sa8155:/etc/systemd/network# cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
hosts: localuser files myhostname mdns4_minimal [NOTFOUND=return] dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
sa8155:/etc/systemd/network#
答案1
我在 Tegra 上的 Yocto 发行版上遇到了一些类似的问题。我的问题是 connman 和 systemd-networkd 都已配置并正在争夺资源。
如果您使用 systemd,请确保没有网络配置与您想要与 connman 一起使用的接口相匹配。
networkd .network 文件位于 /etc/systemd/network 中。该文件夹现在是空的,因为我希望 connman 管理我的所有接口。