Basic binary conversion for IPv4 Mask

Given an IP network address and it’s netmask represented under integer format, the bellow search will create a CIDR representation from the lookup without using built-in tools.   |inputlookup geoip | head 100 | eval mask_int=end_ip_int-start_ip_int | eval mask_bin=replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(substr(tostring(mask_int, “hex”), 3), “0”, “0000”), “1”, “0001”), “2”, “0010”), “3”, “0011”), “4”, “0100”), “5”, “0101”), “6”, “0110”), […]

Continue Reading →