尝试运行python traceroute脚本跟踪在5-7跳之后卡住(而不是应该的30跳)。附上我的脚本
#!/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跳,而通过我们的路由器这样做,我得到了更多的跳数,有什么建议吗?
谢谢
发布于 2020-05-26 19:33:25
这可能是由于超时问题造成的。尝试:
output = net_connect.send_command_timing(f'trace {dest_ip}', delay_factor=4)here解释了延迟因素
如果它仍然不起作用,请尝试:
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)https://stackoverflow.com/questions/61748088
复制相似问题