mikrotik node stratup-config not working

Before posting something, READ the changelog, WATCH the videos, howto and provide following:
Your install is: Bare metal, ESXi, what CPU model, RAM, HD, what EVE version you have, output of the uname -a and any other info that might help us faster.

Moderator: mike

Post Reply
dakobg
Posts: 13
Joined: Thu May 26, 2022 7:46 am

mikrotik node stratup-config not working

Post by dakobg » Thu May 26, 2022 9:50 pm

Hi,

eve-ng community edition: Current API version: 5.0.1-10
tests with mikrotik CHR routeros 7.2.3 and 6.49.6 eve-ng nodes

Mikrotik routeros recently introduce "force new password" for initial boot

stratup-config no working since stuck on boot with "new password> " prompt (after license agreement)

I found a solution to send control+c on "new password> " prompt but is not fully working

config_mikrotik.py

Code: Select all

def node_login(handler):
...
        try:
            _license = handler.expect([MTK_PROMPT, r"\[Y/n\]"], timeout=EXPTIMEOUT)
            if _license == 1:
                handler.send('n\r\n')
            # skip new password prompt wiht ctl+c
            _pwd_prompt = handler.expect([MTK_PROMPT, r"password> "], timeout=EXPTIMEOUT)
            if _pwd_prompt == 1:
                handler.sendcontrol('c')
            handler.expect(MTK_PROMPT, timeout=EXPTIMEOUT)
        except pexpect.exceptions.TIMEOUT:
...

The problem is

modified node_login(): work with config_put(): aka ros config is reset to default and node is restarted
however after restart look like with config_import(): stuck again on "new password> " prompt

No idea for now why node_login(): not working with config_import(): after config_put(): reboot

I will continue to investigate it when I have a time but I guess for you folks will be more easy to find a fix !!

note: is there a github/gitlab for community edition where I can open issue or eventually PR for fix (if I find such ?)

dakobg
Posts: 13
Joined: Thu May 26, 2022 7:46 am

Re: mikrotik node stratup-config not working

Post by dakobg » Sun May 29, 2022 10:52 pm

So, added several checks

Tested with 7.2.3 and 6.39 (get,put)

However with 6.49.6 I have some issues with export config (get)
Probably is something in my lab or routeros bug

I think for 7.2.3 and 6.49.6 some timeouts must be increased

Still testing the code
If someone have better ideas-solutions , let me know !

note: Other thinks can be fixed, for example after the startup-config is applied, "/quit" is pass after actual "/quit" .. aka on login prompt as user name!

I can provide code comments, as general ..

1. check the prompt for mk_prompt, license and new password
2. if mk_promot - do nothing .. no need for future checks
3. if license prompt
- send "n"
- check if prompt is for new password
-- if is, send ctl+c
-- if not, do nothing wait for mk_prompt
4. if new password
- send ctl+c
- wait for mk_prompt

note: final "else" probably should do some exception as final check (for now work with "pass" )

Code: Select all

def node_login(handler):
...
        handler.send(USER_PASS)
        handler.send('\r\n')
        try:
            _prompt_check = handler.expect([MTK_PROMPT, r"\[Y/n\]", r"password> "], timeout=EXPTIMEOUT)
            if _prompt_check == 0:
                pass
            elif _prompt_check == 1:
                handler.send('n\r\n')
                _prompt_check_pwd = handler.expect([MTK_PROMPT, r"password> "], timeout=EXPTIMEOUT)
                if _prompt_check_pwd == 0:
                    pass
                elif  _prompt_check_pwd == 1:
                    handler.sendcontrol('c')
                    handler.expect(MTK_PROMPT, timeout=EXPTIMEOUT)
                else:
                    pass
            elif  _prompt_check == 2:
                handler.sendcontrol('c')
                handler.expect(MTK_PROMPT, timeout=EXPTIMEOUT)
            else:
                pass
        except pexpect.exceptions.TIMEOUT:
            print('ERROR: error waiting for "%s" prompt.' % (MTK_PROMPT))
            node_quit(handler)
            return False
        time.sleep(1)
...

dakobg
Posts: 13
Joined: Thu May 26, 2022 7:46 am

Re: mikrotik node stratup-config not working

Post by dakobg » Wed Jun 01, 2022 10:08 am

Still checking the problem with 6.49* all others look ok

dakobg
Posts: 13
Joined: Thu May 26, 2022 7:46 am

Re: mikrotik node stratup-config not working

Post by dakobg » Mon Jun 06, 2022 9:43 pm

I create a completely new script

https://github.com/NikolayDachev/eve-ng ... ikrotik.py

still in testing / development

For now I don't see some serios issues, probably not aways work if couple of nodes are just started and ''Export all CFG' is used immediately, also I'm not sure why multiprocess is needed ?!

Overall work with 6.39*,6.48*,4.69*, 7.* routeros versions.

Still I'm not sure if this post here is appropriated or not, let me know if I should move it in other section.
Also I want to contribute this script to eve-ng community .. not sure how to do that

I see all scripts are almost identical, however they look somehow outdated, not sure if is mandatory mikrotik_config.py to be similar to all others in order to be included in eve-ng community !?

Let me know if more info is needed.

Regards,

dakobg
Posts: 13
Joined: Thu May 26, 2022 7:46 am

Re: mikrotik node stratup-config not working

Post by dakobg » Sun Jun 12, 2022 10:45 am

I can say the new script is tested and ready.

https://github.com/NikolayDachev/eve-ng

How can be contributed to eve-ng community ?

dakobg
Posts: 13
Joined: Thu May 26, 2022 7:46 am

Re: mikrotik node stratup-config not working

Post by dakobg » Mon Jun 13, 2022 6:46 am


dakobg
Posts: 13
Joined: Thu May 26, 2022 7:46 am

Re: mikrotik node stratup-config not working

Post by dakobg » Fri Sep 02, 2022 2:05 pm

Look like https://gitlab.com/eve-ng-dev is not the right place .. or I recv 0 response for 2+ months

Can someone give me advice how something can be contributed to EVE-NG community ?!?!

Post Reply