/ Linux

Saturday Snippet: Setup a local domain name

Finished
I've got two network connected Christmas decorations at home. A Neopixel tree, and a Poundland star hacked with a Wemos D1 Mini and more Neopixels.

So what is the problem?

To access these devices I need to type in their IP address. Sure they have static IP addresses, but I wanted to give these devices an identity, a URL to explain what they are. So I did.

So what did I do?

On my Linux laptop (Lenovo X220 runing Manjaro) I edited my /etc/hosts file.

By default it looked like this.

127.0.0.1       localhost
127.0.1.1       les-X220
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Here we can see an IP address and a hostname.
I wanted to give my devices a hostname, so I already knew their IP address, I just had to give them a cool name.

192.168.0.69    christmas.tree
192.168.0.75    christmas.star

Yeah, custom hostnames that explain what they are. So I added these to my hosts file.

127.0.0.1       localhost
127.0.1.1       les-X220
192.168.0.69    christmas.tree
192.168.0.75    christmas.star
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Christmas-hostname
I saved the file and then went to a browser and typed in the two hostnames, one by one
christmas.star then christmas.tree:1880/ui and I was able to control my Christmas lights!

This will only work from the device which has the IP address and hostname added to the hosts file. But it is rather handy for projects like this, or for setting up a test environment.

Happy Hacking!