Project: map your IoT network with nmap, avahi and snmp, then add ping and SNMPv3 monitoring in Home Assistant

Discus Various IP Network Discovery Protocols such as SNMP, ICMP and WS-Disovery
Post Reply
User avatar
ZerOne
Site Admin
Posts: 216
Joined: Sun Dec 13, 2020 8:21 am

A hands-on project to find out what is actually on your network, then keep an eye on the important bits. It uses standard command-line tools (nmap, avahi-utils, net-snmp) and Home Assistant's Ping and SNMP integrations, following the HA and Nmap docs as at October 2026. The commands are standard, but I have not run every example here on every platform, so treat them as a starting point and post corrections. Only scan your own network.

Step 1: Take stock with ICMP/ARP (host discovery)

From a Linux box in the same VLAN as the devices (replace the range with yours):

Code: Select all

sudo nmap -sn 192.168.20.0/24
-sn does host discovery only (no port scan). Run it as root on a local network so nmap can use ARP, which also shows MAC addresses and vendors. Save the result in a spreadsheet: IP, MAC, name, what it is, which VLAN it should be in. Anything you cannot identify is a project for later.

Step 2: See what announces itself

mDNS (install avahi-utils on Debian/Ubuntu):

Code: Select all

avahi-browse -art
This browses all service types and resolves them, then terminates. For SSDP/UPnP and WS-Discovery, Nmap's broadcast scripts send multicast queries:

Code: Select all

sudo nmap --script broadcast-dns-service-discovery
sudo nmap -sV --script broadcast-upnp-info
sudo nmap --script broadcast-wsdd-discover
The first uses a multicast DNS-SD query, the second a UPnP multicast query, and the third WS-Discovery. ONVIF cameras typically show in WS-Discovery. Cross-check against Home Assistant's Zeroconf Browser and SSDP/UPnP Browser (Settings > System > Network). If something is visible from your laptop but not from HA, you have a multicast or VLAN issue. If it is visible from neither, check the device's own network settings.

Step 3: Test SNMP (read-only)

Install the net-snmp tools (snmp package on Debian/Ubuntu). On the device or router, create a read-only SNMPv3 user with authentication and privacy, and restrict access to your monitoring host's IP. Then, for example:

Code: Select all

snmpget -v3 -l authPriv -u ha_monitor -a SHA -A 'AUTHPASS' -x AES -X 'PRIVPASS' 192.168.10.1 1.3.6.1.2.1.1.3.0
OID 1.3.6.1.2.1.1.3.0 is sysUpTime (in hundredths of a second). A response means SNMPv3 is working. The HA docs say each vendor's OIDs vary and suggest checking the vendor documentation or MIB file, and prefer numeric OIDs. Avoid putting real passwords in a shared shell history or script. For a quick test on an isolated lab device with v2c: snmpget -v2c -c public HOST 1.3.6.1.2.1.1.3.0, but do not leave v2c enabled on anything important.

Step 4: Ping monitoring in Home Assistant

1. Give each device a DHCP reservation or static IP (the HA docs say to do this, otherwise HA keeps pinging the old address).
2. Go to Settings > Devices & services > Add integration > Ping (ICMP), enter the host and submit.
3. You get a binary sensor (up/down). Default polling is every 30 seconds; the docs explain how to turn off the polling and drive it from your own automation if you want another interval.

Use it for the router, switches, access points, NAS, cameras and the internet (a stable address you choose) and alert when something is down for more than a few minutes, not on a single missed ping.

Step 5: SNMP sensor in Home Assistant

HA's SNMP integration is configured in YAML (platform-style entries as documented on the integration page; check the page for any changes). The docs list "version" as 1 by default and note SNMPv3 settings, so set it explicitly:

Code: Select all

sensor:
  - platform: snmp
    name: "Router uptime"
    host: 192.168.10.1
    version: "3"
    username: ha_monitor
    auth_key: !secret snmp_auth
    auth_protocol: hmac-sha
    priv_key: !secret snmp_priv
    priv_protocol: aes-cfb-128
    baseoid: 1.3.6.1.2.1.1.3.0
    value_template: "{{ (value | int / 360000) | round(1) }}"
    unit_of_measurement: "h"
Valid values for auth_protocol and priv_protocol are listed in the docs (for example hmac-sha and aes-cfb-128). Keep keys in secrets.yaml. The docs also note SNMP version 2c or higher is needed for 64-bit counters. Useful OIDs for routers and switches include interface in/out octet counters; look them up in the device's MIB.

Step 6: Optional presence with Nmap Tracker

The Nmap Tracker integration scans address ranges (CIDR or range notation), lets you exclude addresses and set the minimum minutes between scans. Remember the docs' warning that phones often sleep their Wi-Fi, so combine it with the HA Companion app or router-based presence. Do not set the scan interval very low on a large range.

Hardening checklist
  • SNMP: v3 only, read-only, source-restricted, with strong unique keys. Disable v1/v2c and the default "public" community.
  • Turn off UPnP on the router if you do not use it.
  • Put cameras and cheap IoT devices on their own VLAN with no internet access unless needed, and allow only Home Assistant to reach them. Discovery that stops working is a good sign the segmentation is doing its job. Add devices by IP, or use a limited mDNS reflector.
  • Document your device list, and review it every few months.
Links
Question for the group: what is the most surprising thing you found on your network when you scanned it? Which SNMP OIDs or Ping sensors do you actually alert on?
Post Reply

Return to “IP Network Discovery Protocols”