Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #109311

Breaking down network range to individual networks

Path csiph.com!weretis.net!feeder4.news.weretis.net!news.tal.de!news.wtal.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Aaron Christensen <aaron.christensen@gmail.com>
Newsgroups comp.lang.python
Subject Breaking down network range to individual networks
Date Wed, 1 Jun 2016 11:58:01 -0400
Lines 77
Message-ID <mailman.70.1464796684.1839.python-list@python.org> (permalink)
References <CAOA=+Nt9D4m=10b4KS9mXksf_zCZ=toGAY5dZ0B8Qz6ZvFBWxQ@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 2i60iL6Zaipv1G8EaHUc8AnD3RiaiPGsYQMZHvurBXQA==
Return-Path <aaron.christensen@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.048
X-Spam-Evidence '*H*': 0.91; '*S*': 0.00; '16,': 0.03; 'skip:/ 10': 0.07; '40,': 0.09; '24,': 0.16; '255': 0.16; '32,': 0.16; '36,': 0.16; '488': 0.16; '52,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'odd': 0.18; '&gt;': 0.18; 'trying': 0.22; 'feature': 0.24; 'skip:" 20': 0.26; 'figure': 0.27; 'message-id:@mail.gmail.com': 0.27; 'function': 0.28; 'this.': 0.28; 'skip:( 20': 0.28; 'skip:( 50': 0.29; 'convert': 0.29; 'actively': 0.30; 'help!': 0.30; 'skip:& 30': 0.30; 'to:name :python-list': 0.30; 'largest': 0.31; 'anyone': 0.32; 'received:google.com': 0.35; 'ahead': 0.35; 'asking': 0.35; 'but': 0.36; 'too': 0.36; 'skip:i 20': 0.36; 'there': 0.36; 'received:209.85': 0.36; 'possible': 0.36; 'to:addr:python-list': 0.36; '12,': 0.37; 'received:209.85.213': 0.37; 'things': 0.38; 'received:209': 0.38; 'skip:s 40': 0.38; 'thank': 0.38; 'does': 0.39; 'skip:- 60': 0.39; 'to:addr:python.org': 0.40; 'hello,': 0.40; 'some': 0.40; 'easy': 0.60; 'your': 0.60; 'show': 0.62; 'url:0': 0.63; '20,': 0.66; 'skip:\xc2 10': 0.67; 'paper': 0.73; 'url:10': 0.79; 'subject:down': 0.84; 'url:23': 0.93; 'url:16': 0.95
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=8wdh0t0fklvdBnysfvJBsMFSsYM/JAc/v/hDWvn1/Sc=; b=vPzzCEitooF0K0y2dDd81CTHcoDpWpJre48vpySUHYy/d4wOH1clQjhc8F4NlZjWNQ vsAEnV8okXwzCuRgN3JYiS+kX1i//dAj4VE6wNRhwpuTpbr+kud6mWm9PeF95H4FVIUD yhA30R9Fk8s//Bhp8JB9Mq+xdhbHNkB9BcCKhcf8UEn0fIR7SQ5u8RTLteudhjQCYD3t WGM6L7QfsR+h3x3Lj6w7c61mtqwWRZDzidj00frgqDjDVOkXU/FuBpTiamQZajadM6nN AFNtPcHSa3somzcqqDzyUgmJ2L4P6EPGOlFXk96RhzSwBsjDI787WH+eKmesFLvAo+zE 1GsQ==
X-Google-DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=8wdh0t0fklvdBnysfvJBsMFSsYM/JAc/v/hDWvn1/Sc=; b=DN/zop8m9GB2yWi9BYinI4eLCo8+aWCkkSpRwMFwprX59lQ70xJDiV7mlmD+FzxuNK aMSBja/arpHP/qZQ23KwY1hI5jNF/9Cnv/erdCcquLB0cEf/XzCg3ZXZmL5HbaWKOfGO W60LXpiIzEp7SCRHRTJ/MvD4ypnhV/VILKHipvVo+fXCiMam3dIagbHosSN7QW9m5wNk DQxXAeDUvVY8qu0mKtEmGEkJDAq9pNeN5eQLqv5JCJuY+5wlwP8mTzcKHsfj+TlxvvY1 olzvSDji1Cxo4NZnlJo8vqtrwQrJptOgGgzxk69WT/cggYlryfqLG5FqBG1pif8oIbTZ wuow==
X-Gm-Message-State ALyK8tK07abHHsK6yfXE8zoi6fNsAZf0MJQo9BK3fx76aZDkKoXlH/V3B+TqKvXOyKH7YFchLYGnOfkulH7GpQ==
X-Received by 10.176.5.68 with SMTP id 62mr2210574uax.45.1464796681379; Wed, 01 Jun 2016 08:58:01 -0700 (PDT)
X-Content-Filtered-By Mailman/MimeDel 2.1.22
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CAOA=+Nt9D4m=10b4KS9mXksf_zCZ=toGAY5dZ0B8Qz6ZvFBWxQ@mail.gmail.com>
Xref csiph.com comp.lang.python:109311

Show key headers only | View raw


Hello,

Does anyone know about a feature of ipaddress that will take the following
network range:

"10.224.16.0-10.224.23.0"

and convert it to individual networks?

I am trying to figure out the best way to take a network range and break it
up into the largest possible networks.

I started working out some things on paper but I don't want to get too far
ahead of myself in case there is a function or easy way that already does
this.

Thank you for your help!
Aaron




-------------------------------------------------------------
Pasted some brainstorming below to show that I am actively working this and
not just asking before trying.


ipaddress.ip_network('10.224.16.0/24') - (ipaddress.ip_network('
10.224.23.0/24'))
IPv4Network

IPv4Network('10.224.16.0/24').compare_networks(IPv4Network('10.224.23.0/24')
)



str(ipaddress.IPv4Address('192.168.0.1'))

IPv4Address('10.224.16.0') + 3

ipaddress.ip_address('10.224.16.0') + 256


0.0.x=0.0
/24 x + 0
/23 x + 1 = 0.0.0.0
/22 x + 3 = 0.0.0.0

1  can be /18 if x = 0
2  can be /19 if x = 0, 32
4  can be /20 if x = 0, 16, 32, 48
8  can be /21 if x = 0, 8, 16, 24, 32, 40, 48, 56
16 can be /22 if x = 0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52,
56, 60
32 can be /23 if x = 0 through 62


64 can be /24 if x = 0 though 255

10.224.255.0

start > can be
odd  > /24
even > /24/23
0  >  /22/21/20/19/18...
4  >  /22
8  >  /22/21
12 >  /22
16 >  /22/21/20
20 >  /22
24 >  /22/21
28 >  /22
32 >  /22/21/20/19
36 >  /22
40 >  /22/21
44 >  /22
48 >  /22/21/20

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Breaking down network range to individual networks Aaron Christensen <aaron.christensen@gmail.com> - 2016-06-01 11:58 -0400

csiph-web