How to connect to your Linux machines with .local hostnames instead of IP addressessteemCreated with Sketch.

in #linux6 years ago

Raspberry Pi users might be familiar with the option to contact your Pi using something.local rather than discovering the IP address and using that.

This is very useful if your machine might get a fresh IP after reboot!

While you can add hostnames to your /etc/hosts as your IP addresses get allocated, the Pi does it automatically. Your Ubuntu or Debian machine might however not be so lucky. How do you set that up?

Avahi!

Avahi is a service that runs in the background and handles all this for you, translating example.local into the correct IP address, without needing any system like an external dynamic DNS.

It provides mDNS/DNS features compatible with the Apples Zeroconf/Rendezvous/Bonjour service.

Installing Avahi:

sudo apt-get install avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan

sudo systemctl enable avahi-daemon

Once installed, you can tweak your configuration:

sudo nano /etc/avahi/avahi-daemon.conf

You can start Avahi with

sudo /etc/init.d/avahi-daemon start

or

sudo systemctl start avahi-daemon

Sort:  

I just assign a static on first boot when changing password and hostname.

Once you get passed a handful being able to use meaningful names is handy, especially in an office or maker space :)

I've just been keeping the hosts files updated on all the machines. I did have a local DNS server set up on my old router but I abandoned the idea when I upgraded to a new one. I'll have to give this a shot. Thanks!

Coin Marketplace

STEEM 0.29
TRX 0.12
JST 0.033
BTC 63318.34
ETH 3108.17
USDT 1.00
SBD 3.97