Community discussions

MikroTik App
 
Fulmo
just joined
Topic Author
Posts: 15
Joined: Mon Feb 22, 2021 12:32 pm

Find a network for an ip address which you don't know

Tue Mar 02, 2021 3:41 pm

Hi!
I need to find a network for an ip address, but:
- I know this ip address is 192.168.1. ? or 192.168.2. ? , so i don't know the last part of the address.
If i have the full ip address i can get a network like this
:local ipnetwork [/ip address get [find address="192.168.1.1/32"] network];
but if i have a missing part, what can i do for make the problem solved?
 
Fulmo
just joined
Topic Author
Posts: 15
Joined: Mon Feb 22, 2021 12:32 pm

Re: Find a network for an ip address which you don't know

Tue Mar 02, 2021 3:52 pm

And probably in this router have a 192.168.1.1/32 and i want to found another one, so i think this ~ symbol isn't enough
like this:
:local address [/ip address get [find address~"192.168."] address];
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Find a network for an ip address which you don't know

Tue Mar 02, 2021 3:53 pm

Where do you find the partial address 192.168.1. ?
What gives this type of output?
 
Fulmo
just joined
Topic Author
Posts: 15
Joined: Mon Feb 22, 2021 12:32 pm

Re: Find a network for an ip address which you don't know

Tue Mar 02, 2021 4:03 pm

:D I thinked i solved it but :D nop
In this company where i'm a trainee have a lot of router and stuff and i don't have access for all of them, but i must to write scripts for them. My boss said they are in a /22 masked network and if 192.168.1.1 and one another 192.168.1-4.? ip address have the router than the script need to run. But there is my solution:
:local address [/ip address get [find address~"192.168." and address!="192.168.1.1"] address];
but it can't be good becouse it have the "invalid internal item number" so if someone have a good idea :)
 
Fulmo
just joined
Topic Author
Posts: 15
Joined: Mon Feb 22, 2021 12:32 pm

Re: Find a network for an ip address which you don't know  [SOLVED]

Wed Mar 03, 2021 9:21 am

Oh i forgot the netmask from the end of the ip address so this can be good, if someone need this anytime :D
:local address2 [/ip address get [find (address~"192.168.1." or address~"192.168.2.") and address!="192.168.1.1/32"] address]; 

Who is online

Users browsing this forum: donkeyKong, marcelofares, rogerioqueiroz and 24 guests