Auto Discover Device + Update

Is it possible to monitor a local network for an out-of-the-box mikrotik router so when it is connected to the network for the first time, a script is sent to it to it for execution?

What I am trying to accomplish is automating the process of updating new mikrotik routers. I have a main mikrotik router on the network that can be used to monitor for new connections.

We do something similar to this with Ubiquiti access points. They are immediately recognized on the network and available for update and adoption.

It would be very cool if we could do this with Mikrotik routers!

If anyone can help I would appreciate it.

Thanks

If devices are wifi ap and capsman is used centrally, it can be done.
Otherwise I am as curious as you are.

No, I am asking if it can be done with brand new out of the box routers.

I want to automate the process of updating, configuring, etc.

I’m thinking something like:

  • run script to scan local network every 5 minutes
  • if the scan finds an address 192.168.88.1 then FTP a script to execute commands

I’m not sure if this is possible

I’ve noticed that as soon as you connect a new router to the network, it shows up on the main router under neighbor discovery.

If there is a way to create a script to ftp a command or file to the new router from the main router I think it would work.

Can you ftp to an IP address that is not in the local network? If not, how about to a Mac address? The neighbor discovery shows the Mac address for the new router.

You can not FTP to IP address outside local IP subnet without using gateway. Which is kind of awkward if gateway knows nothing about subnet that IP in question belongs to …

How about this: when a new device appears in neighbour discovery, add additional IP address to LAN interface (normally that’s bridge interface) … and select IP address from same IP subnet as the newly discovered device (best bet would be address that would fit into same /30 subnet as discovered device, that’s the smallest IP subnet still fully supported in ROS). Then you should be able to FTP and SSH into device using default password … which used to be blank, but I hear some models come with random string set as password … in which case you probably can’t automatize anything.

Making progress…

I was able to create a static route for 192.168.88.0/24, so now I can ping a new router from the lan.

I ran a quick ftp test and it worked!

Now I just need to figure the rest of it out.

If they start putting randomized passwords, that would ruin it!

Please don’t put randomized passwords on brand new devices!

Do you know about the auto import feature?
https://wiki.mikrotik.com/wiki/Manual:Configuration_Management#Automatic_Import

European legislation.
It will come.

Yes, I know about auto import, and plan to use it for this.

The legislation should NOT apply to devices like Mikrotik because they are not for end users or novices who don’t know what they are doing. I don’t think many Mikrotik users ever use the settings out of the box without some form of programming, especially the password. Mikrotik is not a ring doorbell or a device mass marketed to end users.

And there you are wrong.
These devices ARE being used in home context so the legislation DOES apply.
As a consumer I CAN buy these devices from various sources.

Mind you, I don’t like it either but I understand why it is being enforced.

Ok, then they should just put a warning on it about changing the password.

In my opinion, there is way too much government regulation on everything these days.

We don’t need a babysitter, we can do fine on our own.

That’s already the case from a certain ROS and Winbox level.

One of the biggest bot net in history was based on Mtik routers. Devices never upgraded, never protected with a real password by their customers…

So nowadays mandatory security is a must, we are not in “tele tabbies country” :slight_smile:

And anyhow if the device could be programmed remotely by you after boot, someone else might even be faster and config/lock the device before you do!
Again look through the security blog few years back, with all the problems Mtik had and which forced them to further improve/close the default firewall…

I’m in the US, and in the land of big-box stores, no home user is accidentally getting a Mikrotik - I have never seen a Mikrotik in any US retail store. IANAL but Mikrotik only sells through distributors, so they likely pawn off the responsibility to the reseller, who might face the EU rules . But Mikrotik seem pretty stubborn so they argue they do force a password change, maybe a defensible position, IANAL.

I’ll offer that some of the “paired” 60GHz kits DO already use autogenerated password, so guess that’s possibility in the future. But even on these, if you push-and-hold reset I recall you getting a default configuration without a password, so I won’t worry too much.

While default IP is 192.168.88.1. Also, you might try using “/ip neighbor” to find the Mikrotiks you want to configure

/ip neighbor print

For example, if you want the first IP of a device named the default “MikroTik”, you can do something like this:

:global namedmikrotik [/ip neighbor find identity="MikroTik"]
:put $namedmikrotik
:global firstip  [/ip neighbor get [:pick $namedmikrotik 1] address4]
:put $firstip
# then you can run /tool/fetch + :import OR you can use SSH to issue commands:
/system ssh command="/ip address print" user=admin address=$firstip

Then once setup (and given a name), you can manage that set differently using their name instead of “MikroTik”. If they didn’t show up in discovery after your changes, you can use that to flag an error in your automatic setup script, etc.

I presume OP is using a script internally first to setup them up. If not, all bets are off.

But then again, if OP has local access, why not use netinstall or flashfig is a good question here.