20

I'm setting up a Raspberry Pi for the first time, and have been SSHing into it on a Mac on the same network like so:

ssh pi@raspberrypi.local

However on my Windows 10 box (also on the same network) this hostname does not resolve. I've tried ipconfig /flushdns, nslookup raspberrypi.local and similar commands to get my Windows machine to see the Raspberry Pi but to no avail. Since it's working on my Mac it doesn't seem like a router issue.

What can I do to connect to my Pi by hostname on Windows?

dimo414
  • 772
  • 1
  • 6
  • 22

2 Answers2

25

How To Geek has a good article that covers this issue. In a nutshell .local domains are self-reported by each host (via Multicast DNS), and other machines on the network have to listen for them. Windows comes with such a service (LLMNR) however it's non-standard and therefore doesn't work terribly well. Instead you should install Apple's Bonjour service (install link). Once Bonjour is installed you'll be able to connect to your Pi on Windows via .local hostnames.


Modern Raspbian versions should come with Avahi to provide mDNS. If it's not working make sure avahi-daemon is installed and running on your Pi; if it's not run the following to install it:

sudo apt-get install avahi-daemon
dimo414
  • 772
  • 1
  • 6
  • 22
-1

I should confess and tell you that I use git for windows to access my pi, so git-bash gives me a minimal bash environment on Windows. You may prefer Putty or WSL etc. This method will work with Mac, Linux and WSL, and it answers the OPs question of "How do I".

  1. Assign the pi a static ip address
  2. use ~/.ssh/config to create your ssh "address book"
nano ~/.ssh/config

Host raspberrypi.local User pi Hostname 192.168.0.22 Port 22

Host rpi User pi Hostname pi.duckdns.org Port 22222 IdentityFile /home/ron/.ssh/id_ed25519.pub

Default settings for all Hosts if not declared above

Host * ForwardAgent yes ForwardX11 yes ForwardX11Trusted yes User ron Port 22 Protocol 2 ServerAliveInterval 60

ServerAliveCountMax 30

Now save the file. From the command line you can easily ssh onto your target server:

 ssh raspberrypi.local

But you could just as easily change the Host field to something very convenient such as "pi" so you could use:

 ssh pi

See also: https://linuxize.com/post/using-the-ssh-config-file/

Ron K.
  • 320
  • 1
  • 8