Brian Dunning's FileMaker Custom Functions

CIDR2IPList_IPv4 ( cidr ; start )

Converts IPv4 CIDR notation into a list of IP addresses.

  Average rating: 4.3 (28 votes) Log in to vote

Maxwell Klein   Maxwell Klein - Show more from this author
Maxwell Klein Consulting
http://www.maxwellklein.com

Share on Facebook Share on Twitter

  Sample input:
CIDR2IPList_IPv4 ( "192.168.1.0/30" ; 0 )

CIDR2IPList_IPv4 ( "10.0.1.128/29" ; 1 )
  Sample output:
"192.168.1.0¶192.168.1.1¶192.168.1.2¶192.168.1.3¶192.168.1.4"

"10.0.1.129¶10.0.1.130¶10.0.1.131¶10.0.1.132¶10.0.1.133¶10.0.1.134¶10.0.1.135¶10.0.1.136"

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Requires FileMaker 18, plus custom functions IP2IPLong and IPLong from Dick Impens. Converts IPv4 CIDR notation into a list of IP addresses. For performance the recursion limit is set to only allow subnet masks from 32 to 16.

 

Comments

Ron Smith   Ron Smith
Nov 29, 2021
Line with 'count = 2 ^ exponent ;' should be:

count = 2 ^ exponent - 1;
 
Maxwell Klein   Maxwell Klein, Maxwell Klein Consulting
Nov 29, 2021
@Ron Smith, thanks for the correction.
 
Alan Deffenderfer   Alan Deffenderfer, ABD Enterprises
Dec 22, 2021
SetRecursion() is your friend with this great custom function from Maxwell!
 
Maxwell Klein   Maxwell Klein, Maxwell Klein Consulting
Dec 23, 2021
@Alan Deffenderfer, SetRecursion set! For performance sake I still limit subnet mask to /16, you can make multiple calls or hack the function if you really need a list with more than 65,536 addresses.

Also took the opportunity to modernize with While loop, improved preflight CIDR format and start position, plus fixed a bug that limited octets to .254.
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: