散尽浮华 2023

過去心不可得,現在心不可得,未來心不可得。
安寻安放,不卑不亢;重剑无锋,大巧不工!
  1. 首页
  2. network
  3. 正文

Python:获取华为交换机的ARP地址表

2020年11月19日 3194点热度 0人点赞 0条评论
from napalm import get_network_driver
from netaddr import IPNetwork, IPAddress
import re
import pandas as pd


driver = get_network_driver('huawei_vrp')
device = driver(hostname='10.20.0.250', username='fsad', password='SWxcf123d~@')
device.open()

# arp = device.get_arp_table()
# mac = device.get_mac_address_table()

cli = 'disp arp interface Vlanif 1020'
send_command = device.cli([cli])
device.close()

arp = send_command[cli]
arp_new = arp.split('\n')
arp_get = []
for i in arp_new:
    if (i.find('10.20') == 0 and i.find('I - ') == -1):
        item =  re.split(r"[ ]+", i)
        arp_get.append(item)

columns = ['IP', 'MAC', 'Expired', 'Type', 'Interface', 'VPN-INSTANCE']
df = pd.DataFrame(arp_get, columns=columns, )
df

输出结果:

标签: 暂无
最后更新:2020年11月19日

admin

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复

COPYRIGHT © 2023 散尽浮华 2023. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang