Hostname post thumbnail
Communicating from Raspberri PI host towards my main computer
Communicating from my main computer host towards my Raspberri PI

Editing the hostname is useful for you to ping and communicate with each device on your network without having to use the IP address.

Pretty useful right? Instead of knowing the whole IP address of each of your devices, you could simply configure the hostname and communicate via name alone. You must however have a functional DNS in your home.

As long as your internet service provider box is functioning well and you could search for domain names through your browser or ping them via command line ie google.ca, yahoo.com, microsoft.com — the DNS should be functioning locally too.

Sometimes you might have to enable DNS for local communication. Verify your modems instructions to see how to enable this. At my home, my Raspberry PI 4th Gen is acting as one of my primary DNS’ with the help of Pi-hole.


Configuring hostname on your Windows PC

Open your notepad as an administrator and find this location “C:\Windows\System32\drivers\etc” and open the file called “hosts”

locating the hosts file and editing it while using notepad as admin
The # represents comments

You should have a similar setup except for the “Added by Docker Desktop” portion. This is because I was using docker for containers on the system. In this example, I am manually adding with proper indentation”# 192.168.0.110 lapcraspberrypi” then erase the hashtag ” # “and saving after modification. To make sure that you have properly saved, verify there’s no” * ” by the left of the “hosts – Notepad” Window screen. If saved successfully, the ” * ” will no longer be there.


On Linux

Extremely easy. First configure the hostname of your Linux PC/server then configure the hosts file, similar to the Windows counterpart.

Configuring hostname then hosts file of the PC/server

choose the name of your PC/server

located in /etc/hosts, configure your system with proper indentation, similar to Windows

Congratulations! You should now be able to communicate with your machines on your network using their hostname.

Categories:

Leave a Reply

Your email address will not be published. Required fields are marked *