我想使用链接本地地址使用交叉电缆(无交换机或 DHCP 服务器)将嵌入式设备(运行 systemd-networkd)连接到 PC(Ubuntu、Win、OS X)。
当我通过提供 DHCP 的网络进行连接时,一切正常,地址*.local
链接到 DHCP IP,并且 avahi 浏览器能够在网络上检测到我的设备。
我现在只尝试了与 Ubuntu 的交叉连接,如果我使用 GUI 更改网络配置自动(DHCP)到仅链接本地我的嵌入式设备和 PC 都获得了 LL IP,并且我能够使用 LL IP(ip a
通过串行接口连接时获得)从我的 PC 对设备执行 ping 操作,但我无法使用该*.local
名称对其进行寻址,也avahi-browser
无法找到任何东西。
我无法在网上找到讨论我的用例的示例,这很奇怪,因为零配置旨在处理此类用例。
这是我的嵌入式设备(ARMhf 上的 Ubuntu 16.04.01)的 IP 设置:
root@rp-f00321:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:26:32:f0:03:21 brd ff:ff:ff:ff:ff:ff
inet 169.254.171.143/16 brd 169.254.255.255 scope link eth0
valid_lft forever preferred_lft forever
inet6 fe80::226:32ff:fef0:321/64 scope link
valid_lft forever preferred_lft forever
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default
link/sit 0.0.0.0 brd 0.0.0.0
这是我的有线网络设置:
root@rp-f00321:~# cat /etc/systemd/network/wired.network
[Match]
Name=eth0
[Network]
LinkLocalAddressing=yes
DHCP=yes
IPForward=yes
IPMasquerade=yes
我还尝试添加接下来的两个选项,但没有帮助:
MulticastDNS=yes
IPv4LLRoute=yes
Avahi 守护进程状态:
root@rp-f00321:~# systemctl status avahi-daemon -l -n 50
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/avahi-daemon.service.d
└─ad.conf
Active: active (running) since Wed 2016-10-26 10:16:04 UTC; 41min ago
Main PID: 1552 (avahi-daemon)
Status: "avahi-daemon 0.6.32-rc starting up."
CGroup: /system.slice/avahi-daemon.service
├─1552 avahi-daemon: running [rp-f00321.local
└─1553 avahi-daemon: chroot helpe
Oct 26 10:16:04 rp-f00321 systemd[1]: Starting Avahi mDNS/DNS-SD Stack...
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Process 1456 died: No such process; trying to remove PID file. (/var/run/avahi-daemon//pid)
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Found user 'avahi' (UID 107) and group 'avahi' (GID 110).
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Successfully dropped root privileges.
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: avahi-daemon 0.6.32-rc starting up.
Oct 26 10:16:04 rp-f00321 systemd[1]: Started Avahi mDNS/DNS-SD Stack.
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Successfully called chroot().
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Successfully dropped remaining capabilities.
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Loading service file /services/bazaar.service.
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Loading service file /services/ssh.service.
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Joining mDNS multicast group on interface eth0.IPv6 with address fe80::226:32ff:fef0:321.
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: New relevant interface eth0.IPv6 for mDNS.
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Joining mDNS multicast group on interface eth0.IPv4 with address 169.254.171.143.
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: New relevant interface eth0.IPv4 for mDNS.
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Network interface enumeration completed.
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Registering new address record for fe80::226:32ff:fef0:321 on eth0.*.
Oct 26 10:16:04 rp-f00321 avahi-daemon[1552]: Registering new address record for 169.254.171.143 on eth0.IPv4.
Oct 26 10:16:05 rp-f00321 avahi-daemon[1552]: Server startup complete. Host name is rp-f00321.local. Local service cookie is 1486970882.
Oct 26 10:16:06 rp-f00321 avahi-daemon[1552]: Service "rp-f00321 SSH" (/services/ssh.service) successfully established.
Oct 26 10:16:06 rp-f00321 avahi-daemon[1552]: Service "rp-f00321 HTTP" (/services/bazaar.service) successfully established.
我可以使用该名称 ping 我的电脑.local
,但它现在停止工作:
# ping dent.local
PING dent.local (169.254.100.55) 56(84) bytes of data.
64 bytes from Dent.local (169.254.100.55): icmp_seq=1 ttl=64 time=0.776 ms
64 bytes from Dent.local (169.254.100.55): icmp_seq=2 ttl=64 time=0.634 ms
这是我的主机 PC (Ubuntu 16.04) 的 IP 设置:
$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
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
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
link/ether c4:8e:8f:f5:a3:93 brd ff:ff:ff:ff:ff:ff
5: enx00e04c534458: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:e0:4c:53:44:58 brd ff:ff:ff:ff:ff:ff
inet 169.254.100.55/16 brd 169.254.255.255 scope link enx00e04c534458
valid_lft forever preferred_lft forever
inet6 fe80::e07d:b734:e921:e87/64 scope link
valid_lft forever preferred_lft forever
这是我的 ping 尝试:
$ ping 169.254.171.143
PING 169.254.171.143 (169.254.171.143) 56(84) bytes of data.
64 bytes from 169.254.171.143: icmp_seq=1 ttl=64 time=0.679 ms
64 bytes from 169.254.171.143: icmp_seq=2 ttl=64 time=0.706 ms
^C
--- 169.254.171.143 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.679/0.692/0.706/0.029 ms
$ ping rp-f00321.local
ping: unknown host rp-f00321.local