Community discussions

MUM Europe 2020
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

How to get first address from subnet ?

Thu Dec 22, 2016 11:37 pm

Hello All

Please advise me how can mikrotik script can calculate first address in subnet if he knows any IP from this subnet in dotted notification ?
I mean if address is ex. 10.255.192.227/28 then script showld return 10.255.192.224.

Thanx.
 
User avatar
mousa1983
Frequent Visitor
Frequent Visitor
Posts: 79
Joined: Mon Apr 21, 2014 2:36 pm
Location: ilam-iran

Re: How to get first address from subnet ?

Thu Dec 22, 2016 11:51 pm

Hi
go to this address
http://jodies.de/ipcalc
import address and Netmask, it calculate every thing
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: How to get first address from subnet ?

Fri Dec 23, 2016 12:00 pm

I need script to do this, not online calculator.
 
User avatar
cdiedrich
Forum Veteran
Forum Veteran
Posts: 929
Joined: Thu Feb 13, 2014 2:03 pm
Location: Basel, Switzerland // Bremen, Germany
Contact:

Re: How to get first address from subnet ?

Fri Dec 23, 2016 12:48 pm

A quick one:

{
:local IP 10.255.192.227;
:local mask 255.255.255.240;
:put ($IP&$mask)
}

I'm sure there's a way to simply convert a CIDR notation to a dotted notation for the mask.
-Chris
Christopher Diedrich
MTCNA, MTCUME, MTCWE
Basel, Switzerland
Bremen, Germany

There are 10 types of people: Those who understand binary and those who don't.
There are two types of people: Those who can extrapolate from incomplete data

Who is online

Users browsing this forum: No registered users and 19 guests