Step 1:
Make sure you have a hostname set in the /etc/hostname on your Pi:nano /etc/hostname
# /etc/hostname
my-pi
Make sure a hostname is set on your laptop also. If using systemd:
nano /etc/hostname
# /etc/hostname
my-laptop
or if your laptop uses systemv:
nano /etc/conf.d/hostname
# Set to the hostname of this machine
hostname="my-laptop"
Step 2:
Install Avahi on your Pi:
pacman -Sy avahi nss-mdns
Install on your laptop per your distro's package manager.
On both the Pi and the laptop, setup mDNS in your nsswitch.conf file. This will tell your OS to do a lookup with Avahi along with other name resolution methods:
nano /etc/nsswitch.conf
find the hosts line and edit it as such:
hosts: files myhostname mdns4_minimal [NOTFOUND=return] dns mdns4
Step 3:
Start the daemon on your Pi:systemctl enable avahi-daemon
systemctl start avahi-daemon.service
Start the daemon on your laptop the same way if you use systemd.
If you use rc-update do:
rc-update add avahi-daemon default
and start the daemon:
/etc/init.d/avahi-daemon start
Step 4:
See if it all works as expected.Try:
avahi-browse --all
on each box to see what is shown on your network. You will need Zero Config software on every client in your network you would like to interact by name.local.
Now try to ping from your laptop:
ping my-pi.local
and from the Pi:
ping my-laptop.local
To see if your ping is working.
Step 5
If all works as expected, reboot and retest with Step 4.
Troubleshooting
If you still have an old IP assigned to the name for some reason (e.g. and earlier yet removed entry in /etc/hosts) try:
avahi-resolve -n my-pi.local
to fix.
No comments:
Post a Comment