New: the AI firewall watches the whole platform and explains each incident in plain words. See how it works

Seeing the changing IP address of a headless Pi through Hermetry

Seeing the changing IP address of a headless Pi through Hermetry

Solved 7 6

Translated from Türkçe by AI ·

I’m working with the Pi in the lab without a monitor attached. It gets its IP via DHCP on the network and it changes every week. I don’t have access to the network’s management panel, so finding the IP for SSH is a hassle every time. I borrow a friend’s laptop and plug in a screen cable, which is a ridiculous situation.The Pi already sends the temperature to Hermetry every minute with paho-mqtt. What’s the easiest way to see the IP?

♥ 0

Translated from Türkçe by AI ·

Have you tried pinging raspberrypi.local? If mDNS is enabled, you’ll find it directly.

♥ 1

Translated from Türkçe by AI ·

I tried it, but mDNS seems to be disabled on this network, no response comes back.

♥ 0

Translated from Türkçe by AI ·

Scan the subnet with nmap -sn, and you’ll find the device with the Raspberry Pi MAC.

Sahadan selamlar.
♥ 0

Translated from Türkçe by AI ·

Running nmap on the corporate network can give you headaches, the IT team doesn’t really like it.

♥ 0

Translated from Türkçe by AI ·

If it is already connected to Hermetry, send the IP there as a client attribute. I always do it this way on the test devices at the pharmaceutical plant.Right after connecting, and again if the IP changes, publish to v1/attributes:

import socket, json
def lan_ip():
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(("10.255.255.255", 1))
ip = s.getsockname()[0]; s.close(); return ip
def on_connect(c, u, f, rc):
c.publish("v1/attributes", json.dumps({"lan.ip": lan_ip(), "host": socket.gethostname()}), qos=1)

On the device page, in the Attributes tab, when you select the Client scope, lan.ip appears there with its last update time. The example in the documentation also uses the lan.ip key anyway.Don’t rely on the IP address field in Overview: it holds the address the latest connection came from, so if there is NAT on the way out it will be the school’s external IP, which is useless for SSH.Öznitelikler

Accepted solution♥ 5

Translated from Türkçe by AI ·

Sends on every message, only when it changes. Attribute messages have a separate per-device limit, lower than telemetry.

♥ 0

Translated from Türkçe by AI ·

Done, under Attributes > Client the lan.ip is there. I was mixing it up with the address on Overview, Furkan was right, that one showed the external IP. Like Hakan said, I’m only sending it when it changes. The laptop loan period is over 🙏

♥ 0
Viewing 8 posts – 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.

Join the conversation

Sign in to ask and answer, like helpful posts and mark the reply that solved your problem. Every contribution earns points and levels.

Share