=Binary and numerical operations on IP addresses= Copyright (c) 2008-2012, David P. D. Moss. All rights reserved. {{{ >>> from netaddr import * }}} ==Addition and Subtraction with integers == {{{ >>> IPAddress('192.0.2.0') + 1 IPAddress('192.0.2.1') >>> 1 + IPAddress('192.0.2.0') IPAddress('192.0.2.1') >>> IPAddress('192.0.2.1') - 1 IPAddress('192.0.2.0') >>> 1 - IPAddress('192.0.2.1') Traceback (most recent call last): ... IndexError: result outside valid IP address boundary! }}} ==Binary operations== {{{ >>> IPAddress('192.0.2.15') & IPAddress('255.255.255.0') IPAddress('192.0.2.0') >>> IPAddress('255.255.0.0') | IPAddress('0.0.255.255') IPAddress('255.255.255.255') >>> IPAddress('255.255.0.0') ^ IPAddress('255.0.0.0') IPAddress('0.255.0.0') }}}