0

使用 python 脚本我很想读出设备的 MAC 地址,例如连接在“GigabitEthernet1/5”上

def get_macaddresses():
   """ GET mac access-list configuration """
   url = "https://{h}:{p}/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet=1%2F5/mac".format(h=HOST, p=PORT)
   headers = { "Accept" : "application/yang-data+json"}
   response = requests.get(url, auth=(USERNAME, PASSWORD),headers=headers, verify=False)
   return response.text

我确实使用 cli 得到了同样的结果...

switch#show int status
 
Port         Name               Status       Vlan       Duplex  Speed Type
Gi1/1                           connected    1          a-full a-1000 10/100/1000BaseTX SFP
Gi1/2                           notconnect   1            auto   auto unknown
Gi1/3                           connected    1          a-full  a-100 10/100/1000BaseTX
Gi1/4                           connected    1          a-full  a-100 10/100/1000BaseTX
Gi1/5                           connected    1          a-full  a-100 10/100/1000BaseTX
Gi1/6                           connected    1          a-half   a-10 10/100/1000BaseTX
Gi1/7                           connected    1          a-full  a-100 10/100/1000BaseTX
Gi1/8                           notconnect   1            auto   auto 10/100/1000BaseTX
Gi1/9                           notconnect   1            auto   auto 10/100/1000BaseTX
Gi1/10                          notconnect   1            auto   auto 10/100/1000BaseTX
switch#show mac address-table int Gi1/5
          Mac Address Table
-------------------------------------------
 
Vlan    Mac Address       Type        Ports
----    -----------       --------    -----
   1    40f5.207c.5b03    DYNAMIC     Gi1/5

任何想法......我做错了什么

4

0 回答 0