给出以下配置:
auto eth0
allow-hotplug eth0
iface eth0 inet static
gateway 192.168.0.1
address 192.168.0.25
netmask 255.255.255.0
post-up /usr/sbin/avahi-autoipd --force-bind --daemonize --wait $IFACE 2> /dev/null
pre-down /usr/sbin/avahi-autoipd --kill $IFACE 2> /dev/null
我让机器获得一个链路本地地址,同时仍然具有静态配置(当该机器连接到 LAN 时)。问题是,目前,它不会连接到 LAN,我只想使用直接连接两台机器的网线来访问它,并通过给定的链路本地地址进行通信。连接正常,我可以通过 ssh 连接:
~ ❯❯❯ ssh [email protected] archlinux ✱
[email protected]'s password:
____ _ _ ____ __ __
/ ___| _| |__ _____ __ (_)___ \ ___\ \/ /
| | | | | | '_ \ / _ \ \/ / | | __) / _ \\ /
| |__| |_| | |_) | (_) > < | |/ __/ __// \
\____\__,_|_.__/ \___/_/\_\ |_|_____\___/_/\_\
Welcome to ARMBIAN Ubuntu 14.04.4 LTS 3.14.60-cubox
System load: 0.00 Up time: 35 min
Memory usage: 5 % of 3788Mb IP: 192.168.0.25
CPU temp: 47°C
Usage of /: 4% of 29G
Last login: Wed Feb 24 04:19:27 2016 from 169.254.4.29
francisco@cubox-i:~$ ip addr
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 d0:63:b4:00:88:1f brd ff:ff:ff:ff:ff:ff
inet 169.254.5.135/16 brd 169.254.255.255 scope link eth0:avahi
valid_lft forever preferred_lft forever
inet 192.168.0.25/24 brd 192.168.0.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::d263:b4ff:fe00:881f/64 scope link
valid_lft forever preferred_lft forever
3: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default
link/ether f6:4b:80:39:3e:0b brd ff:ff:ff:ff:ff:ff
4: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 6c:ad:f8:1d:4b:87 brd ff:ff:ff:ff:ff:ff
francisco@cubox-i:~$ avahi-browse -ar
+ eth0 IPv6 cubox-i [d0:63:b4:00:88:1f] Workstation local
+ eth0 IPv4 cubox-i [d0:63:b4:00:88:1f] Workstation local
= eth0 IPv6 cubox-i [d0:63:b4:00:88:1f] Workstation local
hostname = [cubox-i.local]
address = [fe80::d263:b4ff:fe00:881f]
port = [9]
txt = []
= eth0 IPv4 cubox-i [d0:63:b4:00:88:1f] Workstation local
hostname = [cubox-i.local]
address = [192.168.0.25]
port = [9]
txt = []
我的问题是我还需要让 avahi 发现工作,但可以看出,avahi-browse 没有列出链接本地地址,为什么?如何让它也列出链路本地地址,因为在这种情况下静态配置(192.168.0.25)是没有用的。
答案1
事实是我可以访问静态IP 192.168.0.25!问题是,当我的笔记本电脑连接到 192.168.0.0/24 网络内的 WiFi 时,我尝试使用直接电缆进行通信。关闭 WiFi 后我可以访问 192.168.0.25。