TExcelTAD
Home › Network Security: Discovery, Segmentation, Firewalls, VPN & IDS › Asset Inventory from DHCP, ARP and DNS Data

Asset Inventory from DHCP, ARP and DNS Data

You can't protect, patch or monitor a machine you don't know exists. That is why the first control in almost every security framework (the CIS Critical Security Controls start with "Inventory and Control of Enterprise Assets") is an inventory: every device, who owns it, where it is, what it runs. Most real inventories are wrong, because spreadsheets are updated by people and networks are changed by people who forget the spreadsheet. The assessor's job is to build the inventory from what the network itself records and compare it with the official list.

Three passive sources the network already has

Before a single probe is sent, three data sources describe the network. Using them first is quieter, safer and often more complete than scanning (a laptop that is switched off during your scan still has a DHCP lease from yesterday).

Source Where it comes from What it tells you Blind spots
DHCP leases the DHCP server (dnsmasq.leases, ISC/Kea lease files, Windows DHCP export) MAC, IP, the host name the client asked for, lease time devices with static addresses
ARP / neighbour tables routers, layer-3 switches, the firewall (ip neigh, show arp) which MAC really used which IP recently, including static hosts only hosts that talked through that device; entries age out (seconds to minutes on Linux hosts, hours on many routers)
DNS records the internal zone (A, PTR) the names the organisation intended stale records for machines long gone; nothing for undocumented devices

The first three octets of a MAC (the OUI) identify the manufacturer, which helps classify a device ("this is a printer, not a laptop"). Locally administered MACs (second-lowest bit of the first byte set, as in the lab's 02:… addresses) are random or virtual: phones with MAC randomisation, VMs, containers. See Ethernet Frames and MAC Addresses and DHCP and Rogue DHCP Servers for the formats.

Merging the sources

The program below has the lab network's DHCP leases, the firewall's ARP table and the internal DNS zone as small tables (synthetic data, copied from the lab's exports), merges them on the IP address, and compares the result with the official asset list.

python · try it yourself
import pandas as pd

dhcp = pd.DataFrame([
    ("10.10.0.5",  "02:00:00:0a:0a:05", "ws05"),
    ("10.10.0.21", "02:00:00:0a:0a:15", "admin01"),
    ("10.10.0.77", "02:00:00:0a:0a:4d", "raspberrypi"),
    ("10.10.0.81", "06:3a:91:c2:10:7e", "Pixel-8"),
], columns=["ip", "mac", "dhcp_name"])

arp = pd.DataFrame([
    ("10.10.0.5",  "02:00:00:0a:0a:05"), ("10.10.0.10", "02:00:00:0a:0a:0a"),
    ("10.10.0.21", "02:00:00:0a:0a:15"), ("10.10.0.25", "02:00:00:0a:0a:19"),
    ("10.10.0.30", "02:00:00:0a:0a:1e"), ("10.10.0.40", "02:00:00:0a:0a:28"),
    ("10.10.0.53", "02:00:00:0a:0a:35"), ("10.10.0.60", "02:00:00:0a:0a:3c"),
    ("10.10.0.77", "02:00:00:0a:0a:4d"),
], columns=["ip", "arp_mac"])

dns = pd.DataFrame([
    ("10.10.0.1", "fw.lab.test"), ("10.10.0.5", "ws05.lab.test"), ("10.10.0.10", "www.lab.test"),
    ("10.10.0.21", "admin01.lab.test"), ("10.10.0.25", "mail.lab.test"), ("10.10.0.30", "db.lab.test"),
    ("10.10.0.40", "prn40.lab.test"), ("10.10.0.53", "ns.lab.test"), ("10.10.0.60", "files.lab.test"),
    ("10.10.0.70", "old-backup.lab.test"),
], columns=["ip", "dns_name"])

official = {"10.10.0.1", "10.10.0.5", "10.10.0.10", "10.10.0.21", "10.10.0.25",
            "10.10.0.30", "10.10.0.40", "10.10.0.53", "10.10.0.60"}

inv = dhcp.merge(arp, on="ip", how="outer").merge(dns, on="ip", how="outer")
inv["mac"] = inv["mac"].fillna(inv["arp_mac"])
inv["sources"] = (inv[["dhcp_name", "arp_mac", "dns_name"]].notna()
                  .apply(lambda r: "+".join(n for n, ok in zip(["dhcp", "arp", "dns"], r) if ok), axis=1))
inv["official"] = inv["ip"].isin(official)
inv["key"] = inv["ip"].map(lambda s: tuple(int(x) for x in s.split(".")))
inv = inv.sort_values("key").drop(columns=["key", "arp_mac"])
print(inv.fillna("-").to_string(index=False))
        ip               mac   dhcp_name            dns_name      sources  official
 10.10.0.1                 -           -         fw.lab.test          dns      True
 10.10.0.5 02:00:00:0a:0a:05        ws05       ws05.lab.test dhcp+arp+dns      True
10.10.0.10 02:00:00:0a:0a:0a           -        www.lab.test      arp+dns      True
10.10.0.21 02:00:00:0a:0a:15     admin01    admin01.lab.test dhcp+arp+dns      True
10.10.0.25 02:00:00:0a:0a:19           -       mail.lab.test      arp+dns      True
10.10.0.30 02:00:00:0a:0a:1e           -         db.lab.test      arp+dns      True
10.10.0.40 02:00:00:0a:0a:28           -      prn40.lab.test      arp+dns      True
10.10.0.53 02:00:00:0a:0a:35           -         ns.lab.test      arp+dns      True
10.10.0.60 02:00:00:0a:0a:3c           -      files.lab.test      arp+dns      True
10.10.0.70                 -           - old-backup.lab.test          dns     False
10.10.0.77 02:00:00:0a:0a:4d raspberrypi                   -     dhcp+arp     False
10.10.0.81 06:3a:91:c2:10:7e     Pixel-8                   -         dhcp     False

Each row is now one asset with the evidence behind it. Read it the way an assessor does:

  • In the network, not in the list: 10.10.0.77 (raspberrypi, seen in DHCP and ARP) and 10.10.0.81 (a phone with a randomised MAC, 06:… has the local bit set). Unknown devices are the classic route in: unmanaged, unpatched, often with default passwords.
  • In DNS, nowhere else: 10.10.0.70 old-backup.lab.test. Either the machine is off or it is gone and the record is stale. A stale record is a small risk of its own: if someone else later gets that address, internal clients trust the name.
  • In the list, not in ARP: 10.10.0.1 is the firewall itself (it doesn't keep an ARP entry for its own address), which is expected and shows why every gap needs an explanation rather than an automatic alarm.

Classifying what you found

A second pass adds the questions an owner must answer for every asset: is it managed, does it have an owner, is its MAC address stable?

python · try it yourself
import pandas as pd

rows = [("10.10.0.5", "02:00:00:0a:0a:05", True), ("10.10.0.77", "02:00:00:0a:0a:4d", False),
        ("10.10.0.81", "06:3a:91:c2:10:7e", False), ("10.10.0.70", None, False)]
df = pd.DataFrame(rows, columns=["ip", "mac", "official"])

def local_bit(mac):
    return mac is not None and int(mac.split(":")[0], 16) & 0x02 != 0

def finding(r):
    if r.official:
        return "known asset"
    if r.mac is None:
        return "stale DNS record? confirm and delete"
    if local_bit(r.mac) and r.mac.startswith("02:00:00:0a"):
        return "unknown device on lab MAC range: identify owner"
    return "randomised MAC, unmanaged client: guest or staff phone on the wrong network?"

df["finding"] = df.apply(finding, axis=1)
print(df.to_string(index=False))
print()
print(df["official"].value_counts().rename({True: "official", False: "not official"}).to_string())
        ip               mac  official                                                                      finding
 10.10.0.5 02:00:00:0a:0a:05      True                                                                  known asset
10.10.0.77 02:00:00:0a:0a:4d     False                              unknown device on lab MAC range: identify owner
10.10.0.81 06:3a:91:c2:10:7e     False randomised MAC, unmanaged client: guest or staff phone on the wrong network?
10.10.0.70              None     False                                         stale DNS record? confirm and delete

official
not official    3
official        1

How unknown assets are detected continuously

  • DHCP and ARP monitoring: alert on a MAC never seen before (tools such as arpwatch or the NAC/inventory features of switches and firewalls).
  • Switch port data: LLDP/CDP neighbours and the MAC table per switch port tell you where a device is plugged in.
  • Periodic discovery scans (next lessons) catch static-address devices that never use DHCP.
  • Endpoint agents (EDR, management agents) report from the inside; a host that answers on the network but has no agent is unmanaged.

How the gap is closed

  • One source of truth (a CMDB or inventory tool) fed automatically from DHCP, ARP, DNS, scans and agents; the spreadsheet becomes a report, not an input.
  • Network access control (IEEE 802.1X port authentication, or at least MAC-based admission with quarantine VLANs) so an unknown device lands in a guest network, not next to the database (VLAN and ACL Design).
  • A process: every asset has an owner, a purpose and an end-of-life date; DNS records are removed when machines are decommissioned.

Pitfalls

  • Treating MAC addresses as identity. They are trivially changed; use them to correlate, not to authenticate.
  • Merging on host names: DHCP names are whatever the client sends (raspberrypi, iPhone), DNS names are what someone typed. Merge on addresses and time.
  • Forgetting IPv6: SLAAC clients never ask DHCP for an address; the IPv6 neighbour table (ip -6 neigh) and router logs are the source.
  • Taking a single snapshot. ARP entries age out quickly; collect over days.

Practice

1. A device appears in the ARP table but not in DHCP or DNS. What kind of device is it likely to be, and how do you find out?

A host with a static address that nobody registered in DNS: often a printer, an appliance, an IoT device or a server set up by hand. Look up the OUI, find the switch port from the switch's MAC table, and run a version scan within scope to see what it offers.

2. Extend the first program: list only assets seen in exactly one source.

print(inv[~inv["sources"].str.contains(r"\+")][["ip", "sources"]]): 10.10.0.1 (dns), 10.10.0.70 (dns) and 10.10.0.81 (dhcp).

3. Why is a phone with a randomised MAC hard to inventory, and what is the right control?

Its MAC changes per network (and sometimes over time), so MAC-based tracking fails. The control is authentication at the network edge (802.1X with per-user or per-device credentials) and a separate guest or BYOD network, not MAC lists.

Test yourself

Which source shows devices with static IP addresses that never use DHCP?

  1. DHCP leases
  2. The ARP/neighbour tables of routers and firewalls
  3. DNS SOA records
  4. None

What does the MAC address 06:3a:91:c2:10:7e reveal?

  1. A Cisco device
  2. A locally administered (often randomised) address, because bit 0x02 of the first byte is set
  3. A multicast group
  4. Nothing

A DNS record exists for 10.10.0.70 but no device answers. What is the right next step?

  1. Ignore it
  2. Confirm with the owner whether the host is decommissioned, then delete the stale record
  3. Scan the whole /16 to find it
  4. Assign the address to a new server

Why start an inventory from DHCP, ARP and DNS data instead of a scan?

  1. Scans are illegal
  2. Passive sources are quiet, need no probes and include devices that are off during a scan
  3. Scans can't find hosts
  4. DNS is always correct