0

How can I access my IoT peripheral device (raspberry pi B3+) on my local network in a reliable way? I want to use WiFi not BLE. I want to protect against the device getting a different IP when it is powered off and on again.

Is there a way to set a domain name for my device that only works locally? Otherwise, is setting a static IP the best option?

hardillb
  • 12,813
  • 1
  • 21
  • 34
errolflynn
  • 103
  • 3

1 Answers1

3

There are quite a few ways to achieve this.

First, many DHCP servers will hand out the same IP to the same device, even if it has been switched off for a while (and most certainly if the current DHCP lease has not expired).

You may want to make sure in the settings of your DHCP server (usually your router) that you have enough addresses in your pool, and possibly increase lease duration if it’s something you can change.

Of your current DHCP server does not cooperate, you may want to switch to another device (though it needs to be permanently on and connected to the network).

Of course, you could do static DHCP assignments if the DHCP server allows it.

Otherwise you can use static IP addresses (make sure you take those addresses out of the DHCP pool of course).

All this would help having the same IP.

Alternatively, you could use names which resolve to the dynamic IP. There are several methods to do that, depending on the combination of devices.

One option is to use mDNS / DNS-SD. You can advertise a name like rpi.local from the Pi and then use that name from other computers. You could use the dns-sd tool on the Pi to do so. Some distributions may actually already advertise the host name that way.

There are also alternatives based on uPnP/SSDP, Windows/SMB, and probably a few others.

jcaron
  • 2,408
  • 5
  • 10