Several hostnames for same device

Hi Team

I would like to hear if any of you have an good idear on how to use several ‘hostnames’ on same device, without having to add the hostnames in local host files :wink: .

Example - I have a Raspberry pi with hostname ‘raspbox3’, running both OpenHab and MQTT. My external devices which pass info to the MQTT are using ‘raspbox3’, and the devices accessing openhab are using ‘raspbox3’. But if I at some time need to separate these two functions, I will have to do changes to a lot of clients/devices. I would rather have that I could use hostname ‘MQTT01’ and ‘OPENHAB01’, which would both point at the same physical box.

I guess this could be solved by using hostfiles at all clients… but, then I still would have to go to all clients to make changes to the hosts file…

Guess the solution is some DNS function.

I have an ASUS (RT-AC68U) router which is handling all the DNS stuff with hostnames. But here it is only possible to have one hostname pr devices… no alias.
Then I have a Synology box (DS212j with DSM 6.1.2) - which can run DNS service… but doesn’t look like it will be different then the ASUS.
Then I have several raspberry pi’s… can run some services here ?

How do I move forward ?

Thanks.

/Joern

You could install bind in one of the rPis and create a zone for your LAN.
Set this DNS in your DHCP so that all devices resolve hostnames (and aliases) there and you are all set…
For a more advanced config, you could also setup a DHCP server on the rPi and enable DDNS :slight_smile:

Hi team…
Yes- forgot that DHCP and DNS is not the same service. So I can run DHCP at the router, and then run DNS at my synology (it that does not work, then move this to a rasp)…

But the below setup is not working… someone that can give a hint ? I do think that I from the workstation is connecting to my new DNS, but how do I verify ?

my setup and test:

Network: 192.168.2.x

Router: 192.168.2.1
-DNS1: 208.67.222.123
-DNS2: 208.67.220.123
-DHCP server
-WAN IP: 10.0.0.2
-DISKSTATION static IP:192.168.2.201
-raspbox3 static IP:192.168.2.202

Diskstation
-IP: 192.168.2.201
-DNS server:
–New Zone: Master zone – Forward zone (Zone id: local, Domain name: local, Type: Master, Status:Enabled)
–Enable resolution services – Enable forwarder: 192.168.2.1
–In the ‘local’ zone, I have created
–A record (Name: raspbox3 (.local added), TTL:86400, IP: 192.168.2.202)
–CNAME record (Name: test (.local added), Canonical name: raspbox3.local)
–CNAME record (Name: www.test2 (.local added), Canonical name: raspbox3.local)

From workstation where I have added 192.168.2.201 as DNS server, and rebooted:
(with dhcp ip:192.168.2.135 (this time))

nmcli device show wlp3s0 | grep IP4.DNS
IP4.DNS[1]: 192.168.2.201

Ping: raspbox3.local – success.
Ping: test or test.local – fail, ‘unknown host’
ping: www.test2.local – fail, ‘unknown host’
ping: google.com – success
Ping: raspbox3 – fail, ‘unknown host’

(I do understand, that when we are moving from ‘test’ to prod ;-)… I will change the DNS at the dhcp/router to point at the synology DNS, and the synology fowards to internet DNS server)

/Joern

I don’t know why name resolution is not working properly on your Fedora (?) workstation… you are pointing it to the correct name server… check your /etc/resolv.conf to see if you have a domain local entry

If I was you… I would strip all existing DHCP and DNS services from my LAN, install ISC DHCP and ISC DNS (apt-get install isc-dhcp-server bind9) on the rPi that is always on and have full control of the settings.
Every host would have dynamic IP and you would release specific IPs to specific MAC addresses from the DHCP config.

For web based administration of DNS & DHCP, you could also use Webmin (if you don’t want to mess with flat config files)