You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to establish a connection to a mikrotik router from a juniper router using netmiko
Netmiko version
netmiko==4.2.0
Netmiko device_type (if relevant to the issue)
juniper_junos
mikrotik_routeros
If I make the connection manually (connecting to the Juniper router and from there sending the connection via ssh) it works for me (the conection works with the interface: ssh [email protected] interface et-0/3/2.5363, if i try without it it doesn't work) and after the welcome message I can see the prompt ready to receive commands. But with netmiko it doesn''t work.
with the Manual conection through the router Juniper, this is the prompt that i get after the initial message in the mikrotik: [user@CID_XXXXX_PPAL] >
if i send a read_channel, i can see the prompt at the end (i paste the complete output) which allows me to conclude that the connection was successful:
>>> net_connect.read_channel()
'\n\n\n\n\n\n\n\n\n\n MMM MMM KKK TTTTTTTTTTT KKK\n\n MMMM MMMM KKK TTTT
TTTTTTT KKK\n\n MMM MMMM MMM III KKK KKK RRRRRR OOOOOO TTT III KKK KKK\n\n MMM MM MMM III KKKKK RRR RRR OOO OOO
TTT III KKKKK\n\n MMM MMM III KKK KKK RRRRRR OOO OOO TTT III KKK KKK\n\n MMM MMM III KKK KKK RRR RRR OOO
OOO TTT III KKK KKK\n\n\n MikroTik RouterOS 6.47.10 (c) 1999-2021 http://www.mikrotik.com/\n\n[?] Gives the list of ava
ilable commands\n\ncommand [?] Gives help on the command and list of arguments\n\n\n[Tab] Completes the command/word. If the input is a
mbiguous,\n\n a second [Tab] gives possible options\n\n\n/ Move up to base level\n\n.. Move up one level\n\
n/command Use command at the base level\n\n\x1b[9999B\n\x1b[9999B**************************************************************\n*
*\n* ATENCION: Este equipo es propiedad de xxxxxxxxx *\n* El uso no autorizado esta es
trictamente prohibido. *\n* Todos los usuarios son legalmente responsables de sus *\n* acciones sobre el sistema y toda actividad sera regis
trada *\n* *\n**************************************************************\n\x1bZ \x1b[
6n\n\n\n\n<CID_XXXXX_PPAL] > \n<CID_XXXXX_PPAL] > '
redispatch(net_connect, device_type='mikrotik_routeros')
#this last command throw this exception:
netmiko.exceptions.ReadTimeout:
Pattern not detected: '(>|>)' in output.
Things you might try to fix this:
1. Adjust the regex pattern to better identify the terminating string. Note, in
many situations the pattern is automatically based on the network device's prompt.
2. Increase the read_timeout to a larger value.
Alternatively, after confirming connection to the device, I have tried to send commands to the mikrotik through a write channel after to send the password but in the output I see that it simply writes the command and does not return anything.
if '>' in output or '#' in output:
# i'm connected to the mikrotik (theoricaly)
mikrotik_command = 'system resource print\n'
net_connect.write_channel(mikrotik_command)
time.sleep(2)
# read comand output
output = net_connect.read_channel()
print("Output of 'system resource print':", output)
else:
print("No se pudo conectar correctamente al MikroTik.")
This is what i Get in the console:
Output of 'system resource print': system resource print
If i try send_command throw this exception:
>>> net_connect.send_command('system resource print')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.9/site-packages/netmiko/utilities.py", line 592, in wrapper_decorator
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/netmiko/base_connection.py", line 1790, in send_command
raise ReadTimeout(msg)
netmiko.exceptions.ReadTimeout:
Pattern not detected: {JUNIPER_PROMPT} in output.
Things you might try to fix this:
1. Explicitly set your pattern using the expect_string argument.
2. Increase the read_timeout to a larger value.
As you see, I've tried the solution there redispatch feature, but doesn't work for me (apparently because of the device pattern). And alternatively using the write channel method.
The text was updated successfully, but these errors were encountered:
I want to establish a connection to a mikrotik router from a juniper router using netmiko
Netmiko version
Netmiko device_type (if relevant to the issue)
If I make the connection manually (connecting to the Juniper router and from there sending the connection via ssh) it works for me (the conection works with the interface:
ssh [email protected] interface et-0/3/2.5363
, if i try without it it doesn't work) and after the welcome message I can see the prompt ready to receive commands. But with netmiko it doesn''t work.with the Manual conection through the router Juniper, this is the prompt that i get after the initial message in the mikrotik:
[user@CID_XXXXX_PPAL] >
This i s what i've tried:
if i send a read_channel, i can see the prompt at the end (i paste the complete output) which allows me to conclude that the connection was successful:
Alternatively, after confirming connection to the device, I have tried to send commands to the mikrotik through a write channel after to send the password but in the output I see that it simply writes the command and does not return anything.
If i try send_command throw this exception:
As you see, I've tried the solution there redispatch feature, but doesn't work for me (apparently because of the device pattern). And alternatively using the write channel method.
The text was updated successfully, but these errors were encountered: