已知mac或ip远程H3C三层交换机查询ip或mac-创新互联

#已知ip查mac
import telnetlib
import re

host = b'172.21.0.254'
user = b'admin\n'
password = b'password\n'
command = bytes((input('enter your ip:')),encoding = "utf8")

tn = telnetlib.Telnet(host)
tn.read_until(b'name:')
tn.write(user)
tn.read_until(b'ssword:')
tn.write(password)

tn.write(b'dis arp ' + command + b'\n')
tn.write(b'quit\n')

content = tn.read_all().decode('ascii')
match_mac = r'\w{4}-\w{4}-\w{4}'
mac = re.search(match_mac,content)
#print(content)
print('mac = ' + mac.group())
#已知mac查ip
import telnetlib
import re

host = b'172.21.0.254'
user = b'admin\n'
password = b'c$de6ase\n'
command = bytes((input('enter your mac:')),encoding = "utf8")

tn = telnetlib.Telnet(host)
tn.read_until(b'name:')
tn.write(user)
tn.read_until(b'ssword:')
tn.write(password)

tn.write(b'dis arp | inc  ' + command + b'\n')
tn.write(b'quit\n')

content = tn.read_all().decode('ascii')
match_ip = r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}'
ip = re.search(match_ip,content)
#print(content)
print('ip = ' + ip.group())

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。

创新互联建站服务项目包括临河网站建设、临河网站制作、临河网页制作以及临河网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,临河网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到临河省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
网站标题:已知mac或ip远程H3C三层交换机查询ip或mac-创新互联
URL分享:http://pwwzsj.com/article/dcisgo.html