通过NetConf获取CSR设备路由表返回空RPC回复问题求助
解决CSR设备NETCONF获取路由表返回空回复的问题
可能原因及对应解决方法
设备未启用目标YANG模型支持
CSR默认可能未加载ietf-ip模型或启用相关功能,先在设备上执行以下命令开启:netconf-yang feature enable ietf-ip再确认模型加载状态:
show netconf-yang modules | include ietf-ip确保输出中存在
ietf-ip条目。请求XML路径与CSR实际实现不匹配
ietf-ip模型的路由节点路径可能和CSR的实际实现有差异,CSR的路由信息常存在私有YANG模型中。可尝试使用Cisco-IOS-XE-native私有模型构造请求,对应show ip route的示例请求如下:<rpc message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <get> <filter> <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native"> <ip> <route/> </ip> </native> </filter> </get> </rpc>若设备支持
ietf-routing模型,也可使用该模型(更贴合路由表场景):<rpc message-id="102" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <get> <filter> <routing xmlns="urn:ietf:params:xml:ns:yang:ietf-routing"> <routing-instance> <name>default</name> <routes> <ipv4-routes/> </routes> </routing-instance> </routing> </filter> </get> </rpc>NETCONF会话权限不足
检查NETCONF连接用户的权限,需配置足够权限读取路由表:username netconfuser privilege 15 secret <your-password>设备路由表为空(排除性检查)
先在设备上执行show ip route确认路由表确实存在条目,避免因设备本身路由表为空导致空回复。
验证步骤
- 发送请求前,用
get-schemaRPC获取设备上的目标YANG模型,确认节点结构:<rpc message-id="103" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> <get-schema> <identifier>ietf-routing</identifier> </get-schema> </rpc> - 根据获取的模型结构调整请求XML的节点层级,确保路径正确。
内容的提问来源于stack exchange,提问作者user3603644
相关产品推荐
相关产品推荐

