首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cisco traceroute的python脚本-看不到整个跳数

cisco traceroute的python脚本-看不到整个跳数
EN

Stack Overflow用户
提问于 2020-05-12 17:20:48
回答 1查看 258关注 0票数 0

尝试运行python traceroute脚本跟踪在5-7跳之后卡住(而不是应该的30跳)。附上我的脚本

代码语言:javascript
复制
#!/usr/bin/env python

from netmiko import ConnectHandler
from auto_encrypter_new import *

ios = {
        'device_type': 'cisco_ios',
        'ip': 'my_ip_device',
        'username': user_encrypt,
        'password': passwd_encrypt,
}

net_connect = ConnectHandler(**ios)
output = net_connect.send_command_timing('trace dest_ip')
print (output)

只有6跳,而通过我们的路由器这样做,我得到了更多的跳数,有什么建议吗?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2020-05-26 19:33:25

这可能是由于超时问题造成的。尝试:

代码语言:javascript
复制
output = net_connect.send_command_timing(f'trace {dest_ip}', delay_factor=4)

here解释了延迟因素

如果它仍然不起作用,请尝试:

代码语言:javascript
复制
import time
from netmiko import ConnectHandler
from auto_encrypter_new import *

ios = {
        'device_type': 'cisco_ios',
        'ip': 'my_ip_device',
        'username': user_encrypt,
        'password': passwd_encrypt,
}

net_connect = ConnectHandler(**ios)
dest_ip = '8.8.8.8'


net_connect.write_channel(f'trace {dest_ip}')
time.sleep(10) # this is needed for the device to send a response. Test it and try to adjust timing if needed
output = net_connect.read_channel()
print(output)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61748088

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档