Last active
February 7, 2017 07:22
-
-
Save der3k/96050b707472d5f894b3d4a6a7cd6015 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- https://robertomurray.co.uk/blog/2011/postgresql-find-next-available-ip-addresses/ | |
SELECT sub.ip FROM | |
(SELECT set_masklen(((generate_series(1, | |
(2 ^ (32 - masklen('10.10.100.0/24'::cidr)))::integer - 2) + | |
'10.10.100.0/24'::cidr)::inet), 32) as ip) AS sub | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment