---
title: Networking [Tab]
slug: networking-tab
createdAt: 2025-08-20T06:15:23.785Z
---

# 1) Network Adapters (grid)



**UI columns:** Adapter Name • Status • MAC Address • IP Assignment (DHCP/Static) • IPv4 Address • IPv6 Address • VLAN ID • Connected To



## 1.1 Data model (where to store)

- Primary table: device\_network\_adapter for adapters and IP config (arrays), DHCP metadata, link state, speed/duplex, type, VLAN, etc.   &#x20;
- To show **“Connected To”** (switch/port), use network\_connection. When a switch is the discovery vantage point, its physical network\_device\_port (local) can point to a remote endpoint NIC (your adapter) via remote\_network\_adapter\_id. UI can then display the switch name/port. &#x20;
- If you also manage switch ports, the local side lives in network\_device\_port. Joins flow: endpoint NIC → network\_connection.remote\_network\_adapter\_id → network\_device\_port (local) → switch device. &#x20;



## 1.2 Collection (how to gather)



### A) Endpoint agent (Windows / Linux / macOS)

- **Adapter inventory & link state**
  - Windows: Get-NetAdapter, Get-NetAdapterAdvancedProperty, Get-NetIPAddress, Get-DnsClientServerAddress, Get-NetIPConfiguration.
  - Linux: ip link show, ip -j addr, ethtool \<iface> (speed/duplex), /proc/net/wireless (wifi), NetworkManager (nmcli -g), or systemd-networkd files.
  - macOS: networksetup -listallhardwareports, ifconfig -a, ipconfig getpacket \<iface> (DHCP), route -n get default (gateway), scutil --dns (DNS).
- **DHCP vs Static** (for “IP Assignment”):
  - Windows: Win32\_NetworkAdapterConfiguration.DHCPEnabled or Get-NetIPInterface and Dhcp state.
  - Linux: detect via NM/systemd config (e.g., /etc/NetworkManager/system-connections/\*.nmconnection, /etc/systemd/network/\*.network) or presence of active dhclient lease in /var/lib/dhcp\*/.
  - macOS: networksetup -getinfo \<service> shows “DHCP Configuration” vs “Manual”.
- **VLAN ID**:
  - Windows: Get-NetAdapterAdvancedProperty -DisplayName "VLAN ID" or \*PriorityVLANTag (varies by NIC driver).
  - Linux: /proc/net/vlan/config, ip -d link show (look for vlan id \<n>).
  - macOS: VLANs are configured as separate services; list via networksetup -listVLANs.
- **IPv6**: ensure you collect both global and link-local; store all in ip\_address\_v6\[].



**Normalize into device\_network\_adapter:**

- name, description, mac\_address, status (Up/Down/Disabled), interface\_type (Ethernet/Wi-Fi/Loopback/Tunnel), speed\_mbps, duplex\_mode, physical\_adapter flags; arrays for ip\_address\_v4, ip\_address\_v6, subnet\_mask\_v4, subnet\_mask\_v6, default\_gateway\_v4, default\_gateway\_v6, dns\_server\[], wins\_server\[]; plus DHCP fields and vlan\_id. &#x20;
- Record source precedence in last\_seen\_source (Agent vs Intune) for merge logic. &#x20;



### B) Network probe (LLDP/CDP/MAC tables) for “Connected To”

- Poll access switches/edges over SNMP and collect:
  - LLDP/Cisco CDP neighbor tables (remote sysName, portId, platform, management IP, VLAN).
  - MAC address tables (bridge FDB) to map endpoint MAC → switch port when LLDP isn’t present.
- Build/refresh network\_device\_port for each physical port discovered. Then write network\_connection rows linking **local** network\_device\_port.id to **remote** endpoint (remote\_device\_id and/or remote\_network\_adapter\_id) by MAC/IP correlation. &#x20;



## 1.3 Delta / retention

- For adapters: upsert by (device\_id, mac\_address, name) heuristic; mark unchanged ones as active; hide stale when not observed for N days; keep updated\_at current on change.
- For connections: update last\_seen\_at per discovery; if not seen after X cycles, set status='Inactive' but retain first\_seen\_at for audit. &#x20;



## 1.4 Rendering (example query plan)

- Base: SELECT \* FROM device\_network\_adapter WHERE device\_id = \:id ORDER BY name; &#x20;
- Connected To: for each adapter, SELECT nd.device\_id AS switch\_id, d.name AS switch\_name, nd.port\_name FROM network\_connection nc JOIN network\_device\_port nd ON nd.id = nc.local\_port\_id JOIN device d ON d.id = nd.device\_id WHERE nc.remote\_network\_adapter\_id = \:adapter\_id AND nc.status='Active' ORDER BY nc.last\_seen\_at DESC LIMIT 1; &#x20;

# 2) Open Ports (grid)



**UI columns:** Port • Protocol • Local Address • Process Name • Status



## 2.1 Data model

- Use device\_open\_port for listeners **and** active connections (store local/remote, state, owning PID, service banner/version). Index by device\_id and (optionally) process\_id.   &#x20;
- Link to running processes via device\_process (per-snapshot process metadata). &#x20;



## 2.2 Collection



### A) Endpoint agent

- **Windows:**&#x47;et-NetTCPConnection -State Listen,Established -OwningProcess, Get-NetUDPEndpoint, fall back to netstat -abno; map OwningProcess → process snapshot.
- **Linux:** ss -tunlp (listeners) and ss -tuno (connections); optionally lsof -nPi.
- **macOS:**&#x6C;sof -nPiTCP -sTCP\:LISTEN, lsof -nPiUDP, or netstat -vanp tcp/udp.
- **Service banner (optional):** short, safe banner grabs for common ports (e.g., tcp/22, tcp/80/443) with low timeouts.



**Normalize into device\_open\_port:**

- local\_address, port, protocol, state (TCP only), optional remote\_address/remote\_port for established connections, process\_id, service\_name, service\_version, and timestamps first\_seen\_at, last\_seen\_at. Use active\_in\_scan as a working flag during each run; set active=false for ports not seen after grace. &#x20;



### B) Process table to show “Process Name”

- Take a process snapshot right before or after the port scan. Insert/update device\_process with (device\_id, pid, start\_time) uniqueness to avoid dupes. &#x20;



## 2.3 Delta / retention

- If a port was previously seen, update last\_seen\_at; if missing in a new scan, do not immediately delete—flip active after N missed scans. Indexes already support fast lookups. &#x20;



## 2.4 Rendering

- Show only active rows sorted by (protocol, port). Join (optional) to most recent process snapshot by device\_id+pid.

# 3) Static Routes (grid)



**UI columns:** Destination • Netmask (prefix) • Gateway • Interface • Metric



## 3.1 Data model

- Use device\_static\_route with destination\_cidr, gateway\_ip, optional interface\_name/index, metric, persistent, and last\_seen\_at. Unique key defends against dupes per interface.   &#x20;



## 3.2 Collection

- **Windows:**&#x47;et-NetRoute -PolicyStore ActiveStore | Where-Object \{$\_.RouteMetric -ne $null}; filter RouteMetric, DestinationPrefix, InterfaceAlias/Index, NextHop.
- **Linux:** ip route show + ip -j route for JSON; capture metric, dev, proto static.
- **macOS:**&#x6E;etstat -nr (or route -n get) and parse; persistent routes stored in /Library/Preferences/SystemConfiguration/preferences.plist or MDM profiles.
- Map device interface name/index to your adapter record when possible.



## 3.3 Delta / retention

- Upsert by (device\_id, destination\_cidr, gateway\_ip, interface\_index); refresh last\_seen\_at; mark active=false when not observed. Index on device\_id supports tab load. &#x20;

# 4) Directory & Cloud Identity (right rail)



**UI fields:**

AD Domain • AD Joined • AD Last Contact • Entra ID Tenant • Entra ID Joined • Intune Managed • Intune Last Sync



## 4.1 Data model & mapping

- **AD Domain / AD Joined / AD Last Contact:**
  - Link the device to an ad\_computer row (DN, last\_logon\_timestamp, etc.) and its ad\_domain (domain\_name). “AD Joined = Yes” if an ad\_computer exists for the device; “AD Last Contact” = ad\_computer.last\_logon\_timestamp (safest replicated timestamp).   &#x20;
- **Entra ID Tenant:**
  - Use your Microsoft 365/Entra integration instance tenant\_id and primary\_domain for display (e.g., example.onmicrosoft.com). &#x20;
- **Entra ID Joined (join type):**
  - If you already added a table/column for device join state (e.g., azure\_ad\_device.join\_type or device.azure\_ad\_join\_type), populate from Graph/Intune (Hybrid/AzureADJoined/AzureADRegistered). If not present, add one (recommended).
- **Intune Managed / Intune Last Sync:**
  - A device is “Intune Managed = Yes” if device.intune\_device\_id is set; “Intune Last Sync” comes from device.intune\_last\_checkin\_at.   &#x20;



## 4.2 Collection



### A) AD (on-prem)

- Windows agents can report AD join (domain membership) via Win32\_ComputerSystem.Domain, dsregcmd /status (hybrid hints), plus computer DN. Backfill and keep authoritative directory attributes via LDAP reads on your directory connector.



### B) Entra ID / Intune (cloud)

- Use Microsoft Graph:
  - **Intune device** properties (check-in time, compliance, join type).
  - **Directory** tenant info (primary domain). Store tenant metadata in integration\_instance (already modeled). &#x20;

# 5) Internet Connectivity (right rail)



**UI fields:** External IP Address • Last Public IP Check



## 5.1 Data model

- Use device.external\_ip\_address for the current external IP. Add device.external\_ip\_last\_check\_at TIMESTAMPTZ (if not already present) to drive the “Last Public IP Check” timestamp. (You already have device.external\_ip\_address.) &#x20;



## 5.2 Collection

- From each agent, hit a tiny, redundant set of endpoints (e.g., anycast STUN or a simple HTTPS “what is my IP” behind your domain).
- Record the detected IP and the timestamp as the check time; **debounce** updates (only write when value changes or after a long interval) to avoid churn for NAT-shared IPs.
- For multi-NIC servers, this is **outbound NAT IP**—document that the value is site-level in many environments. Optionally also compute a **location/site level** external IP rollup.

# 6) Source-of-truth, merge rules & schedules

- **Per-field precedence:** In general: Agent > Intune > Directory > Probes for adapter details; Probes are authoritative for “Connected To” (switch port) and VLAN on the **switch** side; AD is authoritative for AD presence/last logon; Intune is authoritative for MDM/Entra join. Persist most-recent last\_seen\_source for adapters. &#x20;
- **Frequencies (defaults):**
  - Adapters & routes: every 4–8 hours on servers; 8–24 hours on workstations; on boot and NIC change via event hooks.
  - Open ports quick scan: every 2–4 hours (servers) / 8–24 hours (workstations). Banner grabs are opt-in and low-rate.
  - Switch discovery via probes: every 1–4 hours (or trap-driven).
  - Cloud (Graph/Intune): every 2–6 hours for device & tenant metadata; AD LDAP every 4 hours.

# 7) Data validation & normalization

- **MAC canonicalization:** store lowercase, colon-less or colon-normalized consistently in device\_network\_adapter.mac\_address; index exists for lookups. &#x20;
- **IP lists:** always store all addresses in arrays; pick the “primary” for display as the first routable non-link-local entry. &#x20;
- **VLAN:** prefer switch-reported access VLAN; if endpoint reports trunk/VLANs, show adapter’s configured VLAN in the grid and (optionally) show the switch-port VLAN on hover (“Connected To”).
- **Routes:** compute human “Netmask” column from destination\_cidr prefix when rendering. &#x20;

# 8) Security & performance

- **Least privilege:**
  - Windows agent queries use standard WMI/PowerShell; no admin required for most reads (except some NIC advanced props).
  - Linux/macOS stick to read-only commands; avoid sudo where possible.
  - SNMP read-only for probes; rate-limit walks; use LLDP/CDP tables directly to minimize load.
- **PII & secrets:** never store DHCP options with sensitive data; banner grabs: redact tokens; don’t persist payloads beyond service\_name/service\_version.
- **Resiliency:** exponential backoff on Graph/APIs; cache tenant metadata; concurrent scans are bounded.

# 9) API & UI contracts

- **Adapters endpoint**GET /devices/\:id/network/adapters returns an array of adapters plus a nested connectedTo (if found): \{ switchDeviceId, switchName, portName, lastSeenAt }. Backed by device\_network\_adapter + network\_connection. &#x20;
- **Open ports endpoint** GET /devices/\:id/network/open-ports supports ?onlyActive=true and returns process names by best-effort join to the latest device\_process snapshot.   &#x20;
- **Static routes endpoint**GET /devices/\:id/network/static-routes lists active routes with destination, prefix, gateway, interface, metric. &#x20;
- **Identity panel endpoint**GET /devices/\:id/identity-summary composes from AD (ad\_domain.domain\_name, ad\_computer.last\_logon\_timestamp), Intune (device.intune\_device\_id, device.intune\_last\_checkin\_at), Entra tenant (integration\_instance.primary\_domain), and your Entra join field/table.     &#x20;

# 10) Ingestion/delta algorithms (pseudo)

- **Adapters:** upsert each observed adapter; after a scan, mark any rows for the device not seen as active=false (soft-delete). Keep history via updated\_at. &#x20;
- **Open ports:** during a run, set active\_in\_scan=true for each seen line; after the run, flip rows with active\_in\_scan=false to active=false. Update last\_seen\_at. &#x20;
- **Static routes:** upsert and bump last\_seen\_at; mark missing as inactive after grace. &#x20;
- **Connections:** if a probe sees the same remote NIC on a different port, update local\_port\_id and last\_seen\_at; keep first\_seen\_at for audit. &#x20;

# 11) Edge cases

- **Multiple IPs per NIC:** display first usable; expose all in details. (Your arrays already model this.) &#x20;
- **No LLDP/CDP:** fall back to MAC-table correlation; if multiple ports claim the MAC (e.g., port-security err), mark “Connected To” ambiguous.
- **Teamed/bonded NICs:** present team as a logical adapter with member MACs in details; on Linux, interpret bond0 and member slaves.
- **Virtual NICs:** set physical\_adapter=false; populate virtual\_switch\_name if known (e.g., Hyper-V/ESXi). &#x20;
- **UDP:** no connection “state”; show “Listening” if bound locally.

# 12) Testing & acceptance criteria

1. **Adapters:**
   - Unplug/plug cable or disable/enable NIC and confirm status updates within one scan cycle.
   - Assign static IP → agent reports dhcp\_enabled=false; switch to DHCP → true.
   - Create VLAN sub-interface on Linux/macOS and confirm vlan\_id mapping.
2. **Open ports:**
   - Start/stop a listener (nc -l 0.0.0.0 8888) and verify rows appear/disappear with correct state and process name.
   - Ensure active\_in\_scan flip works when port disappears. &#x20;
3. **Routes:**
   - Add/delete a static route and validate upsert + last\_seen\_at and inactive marking. &#x20;
4. **Connected To:**
   - Move patch from port A to port B and confirm network\_connection.local\_port\_id updates and UI reflects the new port with a fresh last\_seen\_at. &#x20;
5. **Identity panel:**
   - Disable AD account and confirm last\_logon\_timestamp no longer advances; Intune unenroll test shows intune\_device\_id cleared and managed flag flips.   &#x20;
6. **Internet connectivity:**
   - Rotate NAT IP (test lab) and verify device.external\_ip\_address changes and “Last Public IP Check” updates when the value changes. &#x20;

# 13) What you may still need to add (small deltas)

- **Entra join type field** (if missing): add device.azure\_ad\_join\_type VARCHAR(20) or a small azure\_ad\_device table to track device ↔ directory object & join state (Hybrid/AADJoined/AADRegistered).
- **Last public IP check** (if missing): add device.external\_ip\_last\_check\_at TIMESTAMPTZ to support the timestamp displayed in the right rail.

If you want, I can follow up with concrete agent scripts/commands per OS and a set of SQL views for the tab to make the UI wiring trivial.
