Seeing the changing IP address of a headless Pi through Hermetry
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?
Laboratuvardaki Pi’ye monitör bağlamadan çalışıyorum, ağda DHCP ile IP alıyor ve her hafta değişiyor. Ağın yönetim paneline erişimim yok, dolayısıyla SSH için IP’yi bulmak her seferinde dert. Bir arkadaşın laptopunu ödünç alıp ekran kablosu takıyorum, saçma bir durum.
Pi zaten paho-mqtt ile dakikada bir sıcaklık gönderiyor Hermetry’e. IP’yi görmenin en kolay yolu nedir?
Translated from Türkçe by AI ·
Have you tried pinging raspberrypi.local? If mDNS is enabled, you’ll find it directly.
raspberrypi.local ile ping atmayı denedin mi? mDNS açıksa direkt bulursun.
Translated from Türkçe by AI ·
I tried it, but mDNS seems to be disabled on this network, no response comes back.
Denedim, bu ağda mDNS kapalı galiba, cevap gelmiyor.
Translated from Türkçe by AI ·
Scan the subnet with nmap -sn, and you’ll find the device with the Raspberry Pi MAC.
nmap -sn ile alt ağı tara, Raspberry Pi MAC’li cihazı bulursun.
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.
Kurumsal ağda nmap çalıştırmak başını ağrıtabilir, BT ekibi pek sevmez bunu.
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
Zaten Hermetry’e bağlıysa IP’yi oraya client attribute olarak yolla. Ben ilaç tesisindeki test cihazlarında hep böyle yapıyorum.
Bağlandıktan hemen sonra, bir de IP değişirse, v1/attributes’a yayınla:
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)
Cihaz sayfasında Attributes sekmesinde Client kapsamını seçince lan.ip orada, son güncellenme zamanıyla görünüyor. Dokümandaki örnekte de lan.ip anahtarı kullanılıyor zaten.
Overview’daki IP address alanına güvenme, o en son bağlantının geldiği adres, yani çıkışta NAT varsa okulun dış IP’si olur, SSH için işe yaramaz.
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.
Her mesajda gönderme, sadece değişince. Attribute mesajlarının cihaz başına ayrı bir limiti var, telemetriden düşük.
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 🙏
Yaptım, Attributes > Client altında lan.ip duruyor. Overview’daki adresle karıştırıyordum, Furkan haklı, orada dış IP yazıyordu. Hakan’ın dediği gibi sadece değişince gönderiyorum. Laptop ödünç alma devri bitti 🙏
- 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.

