Network Topology Discovery
Iterative discovery skill that builds a network topology map layer by layer.
Unlike threshold-based health checks, this procedure works outward from a seed
device — discovering neighbors, correlating MAC and ARP tables, analyzing
routing boundaries, and consolidating a complete adjacency model across L2 and
L3.
Commands are labeled [Cisco], [JunOS], or [EOS] where syntax
diverges. Unlabeled statements apply to all three vendors. Detailed command
syntax is in references/cli-reference.md; the full discovery methodology
and data model are in references/discovery-workflow.md.
When to Use
- - Building or validating a network diagram for an unfamiliar environment
- Post-acquisition network inventory where documentation is missing or stale
- Pre-change impact analysis — mapping blast radius before maintenance
- Incident response — determining the L2/L3 path between two endpoints
- Auditing discovered topology against intended design documents
- Identifying rogue or undocumented devices on the network
- Capacity planning — mapping link utilization paths between sites
- Migration planning — inventorying devices and links in a domain
Prerequisites
- - SSH or console access to the seed device (read-only privilege sufficient)
- Credentials that work across devices in the discovery scope — if different
devices use different credentials, identify credential sets in advance
- - CDP and/or LLDP enabled on the network (at least one protocol required)
- Knowledge of the intended discovery scope: site boundary, VRF, management
subnet, or administrative domain to avoid unbounded expansion
- - A device inventory tracker (spreadsheet, CMDB, or text file) to record
discovered devices and avoid revisiting them
Procedure
Follow this procedure iteratively. Each step builds on prior data. The process
expands outward from a seed device, discovering neighbors layer by layer and
correlating L2 with L3 information to produce a consolidated topology.
Step 1: Seed Device Identification
Select a starting device and verify connectivity. The seed is typically a core
switch, distribution switch, or router with the broadest neighbor visibility.
Confirm access and collect the device identity:
[Cisco]
CODEBLOCK0
[JunOS]
CODEBLOCK1
[EOS]
CODEBLOCK2
Record: hostname, platform, software version, management IP, and neighbor
count. The neighbor count sets expectations for Step 2. Add this device as the
first entry in the discovery tracker with status "discovered."
Note: CDP is Cisco-proprietary and available only on Cisco and EOS devices.
JunOS supports LLDP only. Use LLDP as the primary protocol for multi-vendor
environments.
Step 2: L2 Neighbor Discovery
Collect all CDP and LLDP neighbors from the current device. This reveals
directly connected switches, routers, phones, and access points.
[Cisco]
CODEBLOCK3
[JunOS]
CODEBLOCK4
[EOS]
CODEBLOCK5
For each discovered neighbor, record: remote hostname, remote platform/model,
remote management IP, local interface, remote interface, and advertised
capabilities (Router, Switch, Phone, AP). The capabilities field identifies
device role without logging in.
Cross-reference each neighbor against the discovery tracker. New entries get
status "pending" — they become the next seeds for iterative expansion. Already
discovered devices are skipped.
Step 3: MAC Address Table Analysis
Collect the MAC address table to identify all connected endpoints and to
distinguish trunk ports (many MACs) from access ports (few MACs).
[Cisco]
CODEBLOCK6
[JunOS]
CODEBLOCK7
[EOS]
CODEBLOCK8
Analyze port-to-MAC mappings:
- - Trunk ports — multiple MACs learned, typically connecting to other
switches. These should already appear as CDP/LLDP neighbors.
- - Access ports — one or a few MACs learned, typically end hosts.
- Ports with no MACs — either unused or connected to a device that has
not sent traffic. Check interface admin/oper state.
- - Ports with excessive MACs (>100 on access port) — possible hub,
unmanaged switch, or misconfigured trunk.
Flag any MAC addresses on unexpected ports — this helps identify undocumented
devices or cabling errors.
Step 4: ARP Table Correlation
Collect the ARP table to map IP addresses to MAC addresses, establishing the
L3 identity of L2-discovered hosts.
[Cisco]
CODEBLOCK9
[JunOS]
CODEBLOCK10
[EOS]
CODEBLOCK11
For each ARP entry, record: IP address, MAC address, interface, VLAN, and
entry age. Cross-reference MACs from Step 3 to assign IP addresses to
previously discovered L2 endpoints.
Unresolved MACs — entries in the MAC table with no corresponding ARP entry —
indicate L2-only devices (switches without management IPs on that VLAN) or
devices on a different subnet reachable via a trunk. Unresolved ARPs — ARP
entries with incomplete MAC — indicate reachability issues (device offline or
ARP timeout).
Step 5: Routing Table Analysis
Collect routing table entries to discover L3 next-hops, remote subnets, and
routing domain boundaries.
[Cisco]
CODEBLOCK12
[JunOS]
CODEBLOCK13
[EOS]
CODEBLOCK14
Identify:
- - Connected subnets — directly attached networks; these define the L3
boundaries of this device.
- - Next-hop routers — IP addresses of adjacent L3 devices. Cross-reference
with ARP/MAC data to identify the physical interface and MAC of each
next-hop.
- - Routing protocol neighbors — OSPF/BGP/EIGRP peers reveal L3 adjacency
even when CDP/LLDP is disabled.
- - Default route — points to the upstream gateway; follow it to discover
the next layer.
- - VRF routes — separate routing tables indicate VRF boundaries. Repeat
discovery per VRF to map isolated routing domains.
Any next-hop IP without a corresponding ARP entry suggests an inactive or
unreachable peer — flag for investigation.
Step 6: Topology Consolidation
Merge L2 and L3 discovery data into a unified topology model.
For each discovered link, confirm it from both ends where possible. A link
reported by device A to device B should also appear in device B's neighbor
table pointing to device A. Asymmetric entries (link visible from one end
only) indicate: CDP/LLDP disabled on one end, unidirectional link, or stale
neighbor entry.
Build the adjacency model:
- 1. Deduplicate links — the same physical connection appears in both
neighbors' tables. Use the local-port/remote-port pair to match.
- 2. Resolve L2/L3 overlap — a trunk link visible in CDP/LLDP and also
carrying multiple ARP subnets represents one physical link with multiple
L3 paths.
- 3. Classify devices — use capabilities from CDP/LLDP and routing protocol
participation to tag each device: core router, distribution switch, access
switch, firewall, wireless controller, endpoint.
- 4. Identify boundaries — devices at the edge of discovery scope (no
further neighbors, or neighbors outside the target domain) define the
topology perimeter.
- 5. Flag anomalies — undocumented devices, asymmetric links, unexpected
routing peers, and MAC addresses on wrong VLANs.
Threshold Tables
Discovery completeness and data freshness metrics. Unlike health-check
thresholds, these measure how complete and current the topology data is.
Discovery Completeness:
| Metric | Complete | Partial | Incomplete |
|---|
| CDP/LLDP neighbors vs expected | 100% | 80–99% | <80% |
| MACs with ARP resolution |
>90% | 70–90% | <70% |
| Next-hops with ARP entries | 100% | 80–99% | <80% |
| Links confirmed from both ends | >95% | 80–95% | <80% |
| Devices with routing table collected | 100% | >80% | <80% |
Data Freshness:
| Data Source | Fresh | Aging | Stale |
|---|
| CDP holdtime remaining | >120s | 60–120s | <60s |
| LLDP TTL remaining |
>90s | 30–90s | <30s |
| ARP entry age | <300s (5min) | 300–1200s | >1200s (20min) |
| MAC entry age | Recent activity | >300s since last seen | >900s |
| Routing table age | Converged | Reconverging | Incomplete |
Decision Trees
Missing Expected Neighbor
CODEBLOCK15
Unresolved MAC Address
CODEBLOCK16
Asymmetric Routing View
CODEBLOCK17
Report Template
CODEBLOCK18
Troubleshooting
CDP Neighbors Missing on JunOS Devices
CDP is Cisco-proprietary and not supported on JunOS. LLDP must be used for
Juniper neighbor discovery. Ensure LLDP is enabled globally and on relevant
interfaces: set protocols lldp interface all. On the Cisco/EOS side, enable
LLDP alongside CDP so both protocols can exchange neighbor data with JunOS
devices.
LLDP Showing Stale Neighbors
LLDP entries persist for the TTL duration (default 120s) after a neighbor
disappears. If stale entries appear, check: remote device was recently powered
off or rebooted, cable was disconnected, or LLDP was disabled on the remote
interface. Wait for TTL expiry or clear LLDP table manually to refresh.
MAC Table Showing Thousands of Entries on Access Port
An access port learning hundreds of MACs suggests: a hub or unmanaged switch
behind the port, a virtualization host with many VMs bridged to one interface,
or a misconfigured trunk. Check port configuration — if it should be an access
port, investigate what is connected. Consider enabling port security to limit
MAC learning.
ARP Entries with Incomplete MAC
INLINECODE3 showing "Incomplete" for a MAC address means the device sent an
ARP request but received no reply. The target IP is configured on the local
subnet but the host is not responding. Causes: host is offline, host firewall
is blocking ARP, duplicate IP address conflict, or host is on the wrong VLAN.
Verify the host is powered on and connected to the correct VLAN.
Routing Table Shows Unexpected Default Route
A default route pointing to an unknown next-hop may indicate: a rogue DHCP
server providing gateway addresses, an unplanned static route, or route
redistribution pulling in a default from another domain. Trace the route
source — check show ip route 0.0.0.0 for the protocol and source. If OSPF
or BGP, identify which peer is advertising the default.
网络拓扑发现
逐层构建网络拓扑图的迭代发现技能。与基于阈值的健康检查不同,此过程从种子设备向外展开——发现邻居、关联MAC和ARP表、分析路由边界,并整合完整的L2和L3邻接模型。
命令在语法不同的地方标注了[Cisco]、[JunOS]或[EOS]。未标注的语句适用于所有三个厂商。详细命令语法请参见references/cli-reference.md;完整的发现方法和数据模型请参见references/discovery-workflow.md。
何时使用
- - 为不熟悉的环境构建或验证网络拓扑图
- 收购后网络资产盘点,文档缺失或过时
- 变更前影响分析——在维护前映射影响范围
- 事件响应——确定两个端点之间的L2/L3路径
- 将发现的拓扑与预期设计文档进行审计
- 识别网络上的未授权或未记录设备
- 容量规划——映射站点间的链路利用率路径
- 迁移规划——盘点域内的设备和链路
前提条件
- - 对种子设备的SSH或控制台访问权限(只读权限即可)
- 在发现范围内跨设备有效的凭据——如果不同设备使用不同凭据,请提前确定凭据集
- 网络上启用CDP和/或LLDP(至少需要一种协议)
- 了解预期的发现范围:站点边界、VRF、管理子网或管理域,以避免无限制扩展
- 设备清单追踪器(电子表格、CMDB或文本文件),用于记录已发现的设备并避免重复访问
操作步骤
按照以下步骤迭代执行。每一步都基于之前的数据。该过程从种子设备向外扩展,逐层发现邻居,并将L2与L3信息关联,生成整合的拓扑图。
步骤1:种子设备识别
选择一个起始设备并验证连接性。种子设备通常是核心交换机、汇聚交换机或路由器,具有最广泛的邻居可见性。
确认访问权限并收集设备身份信息:
[Cisco]
show version | include hostname|uptime|Software
show cdp neighbors | count
show lldp neighbors | count
[JunOS]
show version | match Hostname|Model|Junos
show lldp neighbors | count
[EOS]
show version | include hostname|uptime|model
show lldp neighbors | count
记录:主机名、平台、软件版本、管理IP和邻居数量。邻居数量为步骤2设定预期。将该设备作为发现追踪器中的第一个条目,状态设为已发现。
注意:CDP是Cisco专有协议,仅适用于Cisco和EOS设备。JunOS仅支持LLDP。在多厂商环境中,使用LLDP作为主要协议。
步骤2:L2邻居发现
从当前设备收集所有CDP和LLDP邻居。这将揭示直接连接的交换机、路由器、电话和接入点。
[Cisco]
show cdp neighbors detail
show lldp neighbors detail
[JunOS]
show lldp neighbors detail
[EOS]
show lldp neighbors detail
show lldp neighbors | include System
对于每个发现的邻居,记录:远程主机名、远程平台/型号、远程管理IP、本地接口、远程接口和通告的能力(路由器、交换机、电话、接入点)。能力字段无需登录即可识别设备角色。
将每个邻居与发现追踪器进行交叉引用。新条目状态设为待处理——它们将成为迭代扩展的下一个种子。已发现的设备将被跳过。
步骤3:MAC地址表分析
收集MAC地址表以识别所有连接的端点,并区分中继端口(多个MAC)和接入端口(少量MAC)。
[Cisco]
show mac address-table
show mac address-table count
[JunOS]
show ethernet-switching table
show ethernet-switching table summary
[EOS]
show mac address-table
show mac address-table count
分析端口到MAC的映射:
- - 中继端口——学习到多个MAC,通常连接到其他交换机。这些应该已作为CDP/LLDP邻居出现。
- 接入端口——学习到一个或少量MAC,通常是终端主机。
- 无MAC的端口——未使用或连接到未发送流量的设备。检查接口管理/运行状态。
- MAC过多的端口(接入端口上超过100个)——可能存在集线器、非管理型交换机或配置错误的中继。
标记任何出现在意外端口上的MAC地址——这有助于识别未记录设备或布线错误。
步骤4:ARP表关联
收集ARP表以将IP地址映射到MAC地址,建立L2发现主机的L3身份。
[Cisco]
show ip arp
show ip arp vrf [name]
[JunOS]
show arp no-resolve
show arp interface [intf]
[EOS]
show ip arp
show ip arp vrf [name]
对于每个ARP条目,记录:IP地址、MAC地址、接口、VLAN和条目老化时间。将步骤3中的MAC地址进行交叉引用,为之前发现的L2端点分配IP地址。
未解析的MAC——MAC表中没有对应ARP条目的条目——表示纯L2设备(在该VLAN上没有管理IP的交换机)或通过中继可达的不同子网上的设备。未解析的ARP——MAC不完整的ARP条目——表示可达性问题(设备离线或ARP超时)。
步骤5:路由表分析
收集路由表条目以发现L3下一跳、远程子网和路由域边界。
[Cisco]
show ip route summary
show ip route
show ip route vrf [name]
[JunOS]
show route summary
show route protocol [ospf|bgp|static]
show route table [routing-instance].inet.0
[EOS]
show ip route summary
show ip route
show ip route vrf [name]
识别:
- - 直连子网——直接连接的网络;这些定义了该设备的L3边界。
- 下一跳路由器——相邻L3设备的IP地址。与ARP/MAC数据交叉引用,以识别每个下一跳的物理接口和MAC。
- 路由协议邻居——OSPF/BGP/EIGRP对等体即使在CDP/LLDP禁用时也能揭示L3邻接关系。
- 默认路由——指向上游网关;跟随它发现下一层。
- VRF路由——独立的路由表表示VRF边界。按VRF重复发现以映射隔离的路由域。
任何没有对应ARP条目的下一跳IP都表示不活动或不可达的对等体——标记以供调查。
步骤6:拓扑整合
将L2和L3发现数据合并为统一的拓扑模型。
对于每个发现的链路,尽可能从两端确认。设备A报告到设备B的链路也应该出现在设备B的邻居表中指向设备A。不对称条目(仅从一端可见的链路)表示:一端禁用了CDP/LLDP、单向链路或过时的邻居条目。
构建邻接模型:
- 1. 去重链路——相同的物理连接出现在两个邻居的表中。使用本地端口/远程端口对进行匹配。
- 解析L2/L3重叠——在CDP/LLDP中可见的中继链路同时承载多个ARP子网,表示一条物理链路上有多个L3路径。
- 分类设备——使用CDP/LLDP的能力和路由协议参与来标记每个设备:核心路由器、汇聚交换机、接入交换机、防火墙、无线控制器、端点。
- 识别边界——位于发现范围边缘的设备(没有更多邻居,或邻居在目标域之外)定义了拓扑边界。
- 标记异常——未记录设备、不对称链路、意外的路由对等体和错误VLAN上的MAC地址。
阈值表
发现完整性和数据新鲜度指标。与健康检查阈值不同,这些衡量拓扑数据的完整性和时效性。
发现完整性:
| 指标 | 完整 | 部分 | 不完整 |
|---|
| CDP/LLDP邻居与预期对比 | 100% | 80–99% | <80% |
| 具有ARP解析的MAC |
>90% | 70–90% | <70% |
| 具有ARP条目的下一跳 | 100% | 80–99% | <80% |
| 从两端确认的链路 | >95% | 80–95% | <80% |
| 已收集路由表的设备 | 100% | >80% | <80% |
数据新鲜度:
| 数据源 | 新鲜 | 老化 | 过时 |
|---|
| CDP保持时间剩余 | >120秒 | 60–120秒 | <60秒 |
| LLDP TTL剩余 |
>90秒 | 30–90秒 | <30秒 |
| ARP条目老化时间 | <300秒(5分钟) | 300–1200秒 | >1200秒(20分钟) |
| MAC条目老化时间 | 最近活动 | 上次看到后>300秒 | >900秒 |
|