Access to MQTT broker via WIFI hotspot with DNS/DHCP entry for fixed address

My DietPi is running a Mosquitto MQTT broker and a WIFI hotspot, among other things. I can connect an external device to the access point provided by the Dietpi without problems and can access my MQTT Broker via the eth0 LAN IP. However, now the IP of my DietPi is constantly changing and I don’t want to assign a fixed IP address for the DietPi per se.

Could it instead be possible to put a DHCP or DNS entry on the Wifi hotspot that always points to the Dietpi’s localhost address, so that I can use this entry to reach the Mosquitto broker from within the Wifi hotspot network. I imagine I create the entry mosquitto-broker in the DNS of the WIFI hotspot, which then points to the localhost address of the Dietpi. All devices connected to the Wifi hotspot could then always reach the Mosquitto Broker via this fixed entry, without having to know the IP address of the Dietpi itself.

Is this somehow possible?

Hi,

usually the HotSpot interface IP should not change and your system should always be reachable on WiFi on same IP. Can you share ip a pls

This is the output of ip a:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether e4:5f:01:01:b9:0b brd ff:ff:ff:ff:ff:ff
    inet 192.168.178.70/24 brd 192.168.178.255 scope global dynamic eth0
       valid_lft 863982sec preferred_lft 863982sec
    inet6 fe80::e65f:1ff:fe01:b90b/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether e4:5f:01:01:b9:0d brd ff:ff:ff:ff:ff:ff
    inet 192.168.42.1/24 brd 192.168.42.255 scope global wlan0
       valid_lft forever preferred_lft forever
    inet6 fe80::e65f:1ff:fe01:b90d/64 scope link 
       valid_lft forever preferred_lft forever

When connecting any other device to the WIFI Access point network of the RPI, which IP address can I use to reach the Mosquitto MQTT Broker on the RPI from that device?

Your Wifi interface has an own IP 192.168.42.1 and it should be reachable for all Wifi devices connected. But it’s reachable on Wifi only on that IP :wink:

Thank you very much, it worked with this IP. A careless mistake on my part was the problem, so I used a wrong IP… :cry:

good it is working that way for you :sunglasses: