Swacblooms🦋

Making the Moves
Menu
  • Home
  • Motivation
  • Education
  • Programming
  • About
  • Contact
  • Privacy Policy
Home
Programming
Easy SSH Via Local DNS
Programming

Easy SSH Via Local DNS

Sammy March 23, 2021

Hola 🖐…..

Sometimes you might find it hard to keep track of the IP address of your devices in your local network. Imagine having three Raspberry pi’s and keeping track of their IP when you want to SSH into them in a local network.

Most Debian OS’s if not all come installed with the Avahi mDNS. The Avahi mDNS serves as a local DNS and it makes use of the .local extension which is used as a specially used domain and reserved for personal use and local networks.

So instead of sshing into your Raspberrypi by doing ssh pi@xx.xx.xx.xx you can ssh into your Raspberrypi using its hostname with the .local extension e.g

ssh pi@raspberrypi.local

To view the hostname of your Raspberrypi, run this command:

hostname

And to change the hostname of your Raspberrypi, run this command:

hostnamectl set-hostname [custom-name]

So in a scenario where you have three Raspberrypis, you can run these commands:

# Run this in your first Raspberrypi
hostnamectl set-hostname mypi-1
# Run this in your second Raspberrypi
hostnamectl set-hostname mypi-2
# Run this in your third Raspberrypi
hostnamectl set-hostname mypi-3

After running these commands you would need to reboot your router so that it can have the updated list of hostnames 😁

To ssh into your first Raspberrypi, you can simply run

ssh pi@mypi-1.local

This is easier than using its IP address.

Another good thing about the Avahi mDNS is that it binds your device’s IP address to its local domain so even when the IP address of your device changes, you don’t need to worry about that because sshing using your device’s hostname with the .local extension would still work.

Also, note that this setup isn’t only restricted to Raspberrypi, you can as well change the hostname of your Debian computer using the same commands above 😜

Thanks and I hope you enjoyed learning a little bit about the Avahi mDNS.😅

Prev Article
Next Article

Related Articles

Corona
Hello, you are welcome to read this post. I’m sure …

Making a Corona Data Fetcher (API)

hacking your life
Have you read lots of books that revolve around motivational, …

Creating positive fallbacks by hacking your life

About The Author

Sammy

I am Samson Amaugo. I am a full-stack web developer and I specialize in MERN stack development

Leave a Reply

Cancel reply

Search Site

Recent Posts

  • Serving A VueJs App from DotNet
  • Dynamic Subscriptions in Hot Chocolate 🔥🍫
  • Deploying a DotNet API To Railway 🚂
  • GitHub OAuth Device Flow in DotNet
  • Resumable Download in DotNet

Categories

  • EDUCATION
  • Motivation
  • Programming
  • Uncategorized

Get more stuff

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.

we respect your privacy and take protecting it seriously

RSS Swacblooms

Swacblooms🦋

Making the Moves
Copyright © 2023 Swacblooms🦋
Swacblooms - Making the Moves