What forms of IPv4 addresses does Mikrotik accept?

http://wiki.mikrotik.com/wiki/Manual:IP/Address doesn’t detail what forms of IPv4 addresses are being accepted.

For instance inet_addr accepts a much wide range of input (like leading zero for octal and many other forms) than the often used human readable quad-dotted decimal form a.b.c.d.e where a can be in the decimal range 0..255.

So: what forms of IPv4 addresses does Mikrotik support in both the UI and scripts?

–jeroen

It accepts human readable 4 decimal octets.

Some playing around from a terminal tells me that all of those are allowed indeed, and behave as described in inet_addr(3).

[admin@MikroTik] > :local val 0.32.16.8;:put $val;:put [:typeof $val];        
0.32.16.8
ip
[admin@MikroTik] > :local val 32.16.8;:put $val;:put [:typeof $val];  
32.16.0.8
ip
[admin@MikroTik] > :local val 0.16.8;:put $val;:put [:typeof $val];  
0.16.0.8
ip
[admin@MikroTik] > :local val 16.8;:put $val;:put [:typeof $val];  
16.0.0.8
ip
[admin@MikroTik] > :local val 0.8;:put $val;:put [:typeof $val];  
0.0.0.8
ip

The edge case is an IP with a single octet… You can’t really do that, as it is treated as a value of type “num” (which, in RouterOS is actually an integer, not a float, as “num” might have you believe). You can only use “0.” as in the example above.

Some further tests also show that (as expected), only decimal notation is allowed. No octal or, as the example on the man page suggests, hex. Hex is outright invalid unless in the “<hex>” form, within quotes that ultimately produce a string. A string you could manually cast to an IP with “:toip” if the hex forms a valid decimal notated value, but still:

[admin@MikroTik] > :local val 008.008.008.008;:put $val;:put [:typeof $val];        
008.008.008.008
str
[admin@MikroTik] > :local val 8.008.008.008;:put $val;:put [:typeof $val];  
8.008.008.008
str
[admin@MikroTik] > :local val 0.008.008.008;:put $val;:put [:typeof $val];  
0.008.008.008
str
[admin@MikroTik] > :local val 0.8.8.008;:put $val;:put [:typeof $val];    
0.8.8.008
str
[admin@MikroTik] > :local val 0.008;:put $val;:put [:typeof $val];    
00:00:00.008
time