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

Having issues with your DietPi installation or found a bug? Post it here.
Post Reply
bennoheld
Posts: 8
Joined: Thu May 06, 2021 4:49 pm

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

Post by bennoheld »

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?
User avatar
Joulinar
Posts: 4783
Joined: Sat Nov 16, 2019 12:49 am

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

Post by Joulinar »

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
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
bennoheld
Posts: 8
Joined: Thu May 06, 2021 4:49 pm

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

Post by bennoheld »

This is the output of ip a:

Code: Select all

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?
User avatar
Joulinar
Posts: 4783
Joined: Sat Nov 16, 2019 12:49 am

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

Post by Joulinar »

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 ;)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
bennoheld
Posts: 8
Joined: Thu May 06, 2021 4:49 pm

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

Post by bennoheld »

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:
User avatar
Joulinar
Posts: 4783
Joined: Sat Nov 16, 2019 12:49 am

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

Post by Joulinar »

good it is working that way for you 8)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply