Question: How can I set up two machines, so that when I directly connect them together with an ethernet cable, one machine can connect to the other? I'm looking for a solution that does not involve setting static IP addresses.
Motivation: I have a Raspberry Pi that is taking measurements with sensors attached to it in a location without ethernet access to the internet. I'd like to be able to plug a laptop into the Pi and transfer the data off of it without having to turn off the Pi. I'd like to avoid static IP's so that I don't have to change the configuration of the laptop each time it needs to plug into the Pi. Also, I want to occasionally bring the Pi back to a wired ethernet connection, plug it in, and run software updates on it without having to change the set up on the Pi.
What I tried: I followed the steps listed on the Arch wiki and this blog post for setting up Avahi to use the
.local TLD. Currently, the laptop is using Arch Linux and the Pi is using Ubuntu Mate. I have
avahi-daemon running on both systems with the
nss-mdns library installed. On the laptop, I edited the hosts line in
/etc/nsswitch.conf to read
hosts: files mdns_minimal [NOTFOUND=return] dns myhostname
What I see: When the ethernet cable is first plugged in,
avahi-browse -alr shows
+ enp1s0 IPv6 rpi2b0 [b8:27:eb:65:2e:43] Workstation local = enp1s0 IPv6 rpi2b0 [b8:27:eb:65:2e:43] Workstation local hostname = [rpi2b0.local] address = [fe80::ba27:ebff:fe65:2e43] port =  txt = 
After a few minutes,
avahi-browse -alr does not find the Pi when it is rerun. While the Pi is found by
avahi-browse, it also can be found by
avahi-resolve, but once it is not found by
avahi-browse it no longer is found by
ping rpi2b0.local shows that
rpi2b0.local to the IPv6 address listed by
avahi-browse but results in
ssh gives the error:
debug1: connect to address fe80::ba27:ebff:fe65:2e43 port 22: Invalid argument.