<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
# Network Discovery Tools — API Reference

## ICMP / Ping

```bash
# Single host ping
ping -c 1 -W 1 192.168.1.1

# Sweep with fping
fping -a -g 192.168.1.0/24 2>/dev/null

# Nmap ping scan
nmap -sn 192.168.1.0/24
```

## DNS (dnspython)

```python
import dns.resolver

# A records
answers = dns.resolver.resolve("example.com", "A")

# MX records
answers = dns.resolver.resolve("example.com", "MX")
for r in answers:
    print(r.exchange, r.preference)

# Reverse DNS
import dns.reversename
rev = dns.reversename.from_address("8.8.8.8")
dns.resolver.resolve(rev, "PTR")

# Zone transfer attempt
import dns.zone, dns.query
z = dns.zone.from_xfr(dns.query.xfr("ns1.example.com", "example.com"))
```

## SNMP (pysnmp)

```python
from pysnmp.hlapi import *

# GET sysDescr
iterator = getCmd(
    SnmpEngine(),
    CommunityData("public"),
    UdpTransportTarget(("192.168.1.1", 161)),
    ContextData(),
    ObjectType(ObjectIdentity("SNMPv2-MIB", "sysDescr", 0)),
)
errorIndication, errorStatus, errorIndex, varBinds = next(iterator)
```

## Common SNMP OIDs

| OID | Description |
|-----|-------------|
| 1.3.6.1.2.1.1.1.0 | sysDescr |
| 1.3.6.1.2.1.1.5.0 | sysName |
| 1.3.6.1.2.1.2.2.1.2 | ifDescr (interfaces) |
| 1.3.6.1.2.1.4.20.1.1 | ipAdEntAddr (IP addresses) |

## Exit Codes

| Code | Meaning |
|------|---------|
| 0 | Discovery completed successfully |
| 1 | Partial results (some hosts unreachable) |
| 2 | Fatal error or missing dependency |
