Skip to content

Bitmask

Transform IP addresses using bitwise binary operations. Useful for changing subnets (especially for IPv6 addresses).

Operation The bitwise binary operation to perform (and or or)
Masks A function that returns the binary masks to apply
Addresses A function that returns IP addresses that the binary masks will be applied to

IP addresses (results from Addresses that have been transformed by the masks in Masks)

Assuming a constant Addresses function with an IP address 2001:db8:cafe::dead:beef

An and bitmask can effectively remove bits from an IP address:

Given a mask of ::ffff:ffff and an address of 2001:db8:cafe::dead:beef, returns ::dead:beef.

An or bitmask can effectively add bits to an IP address:

Given a mask of 2001:db8:cafe:: and an address of ::dead:beef, returns 2001:db8:cafe::dead:beef.