From owner-freebsd-questions@freebsd.org Mon Dec 2 12:06:45 2019 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 634721A80D0 for ; Mon, 2 Dec 2019 12:06:45 +0000 (UTC) (envelope-from jerry@seibercom.net) Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47RP3m2f19z3Hl5 for ; Mon, 2 Dec 2019 12:06:44 +0000 (UTC) (envelope-from jerry@seibercom.net) Received: by mail-qk1-x72a.google.com with SMTP id a10so9213093qko.9 for ; Mon, 02 Dec 2019 04:06:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seibercom.net; s=google; h=date:from:to:subject:message-id:in-reply-to:references:reply-to :organization:mime-version; bh=07+a++7hAdi6RduHSd9uqIxgA8MGoM7r1lmr0poFLrQ=; b=OQ3UUsPIwpzY6+cxrp2kS0bztKCuBkf/P4sAfwRqTV9Q+hLyxlntQnPtAxnBkAs2Ji xxMiVb/nEscqC8ml/b86ERAtXSG8tpydH8ZXJE2rivCJ2n2mcBfD1Lp84fZDNdu3kZta G4SdcBPnyU4/R9jpNZLsi+2JkrgetB2jQrgbI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:in-reply-to :references:reply-to:organization:mime-version; bh=07+a++7hAdi6RduHSd9uqIxgA8MGoM7r1lmr0poFLrQ=; b=AnmW7JzVP14o6h6d08yE0Fik1w2dOhOM6sIj7wLoTNYYq/lwfn4HoEw2DpF+b1DxzI nQGhn+HPcNlHyoyF6IRBWyzzDE3Xob6NGeAXiEw/O/1+P9w9IJb7AetWcbo458NtuZF2 qSR8S0LVuHrlxWNDHSqeoCJsU1zs9N1nVGHVEx5/vD6jsgbKbvZHHnyiyb/Rhk9EyCLt uvYi9J03/dYNIW5mQhuw2s3qD7rMltIryxrCuaqiBbswgzFvf2rGfmxkICMlgnTgOfd0 NMBLuhl8ZrF/MqW1z+fyIKqSG2aRe5iS3xb+H+VVzsl/WbOR9JvolduG6ZRNLFZf2QrD Txxg== X-Gm-Message-State: APjAAAVfZgXVo2wkUVBJCmNsvJEt+DwwxU0fH8rrIl2U0jrbJEleiTqQ dF79lOM6EDN9tRpu/txygrufVp2pdw0= X-Google-Smtp-Source: APXvYqzFobJfPB5JSVfs/k5KC7F/NIYkus1w5RiHI6eMSlC2iqVYJYr0bIVX1Nrc8dYiWIytRaXEUw== X-Received: by 2002:a05:620a:12cf:: with SMTP id e15mr2520183qkl.120.1575288402787; Mon, 02 Dec 2019 04:06:42 -0800 (PST) Received: from scorpio.seibercom.net (cpe-174-109-225-250.nc.res.rr.com. [174.109.225.250]) by smtp.gmail.com with ESMTPSA id 17sm4992185qkk.81.2019.12.02.04.06.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 04:06:42 -0800 (PST) Received: from localhost (HP-ENVY [192.168.0.102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: jerry@seibercom.net) by scorpio.seibercom.net (Postfix) with ESMTPSA id 47RP3j1fV6z1yjp for ; Mon, 2 Dec 2019 07:06:41 -0500 (EST) Date: Mon, 2 Dec 2019 07:06:32 -0500 From: Jerry To: freebsd-questions@freebsd.org Subject: Re: Network Aggregation Message-ID: <20191202070632.00006110@seibercom.net> In-Reply-To: <6d5f214c-0f40-50d0-8cf7-b5954c18e266@FreeBSD.org> References: <20191202060719.000059a1@seibercom.net> <6d5f214c-0f40-50d0-8cf7-b5954c18e266@FreeBSD.org> Reply-To: freebsd-questions@freebsd.org Organization: seibercom.net X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/70ydY5=lhCpEjkNFbyEZQCh"; protocol="application/pgp-signature" X-Rspamd-Queue-Id: 47RP3m2f19z3Hl5 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=seibercom.net header.s=google header.b=OQ3UUsPI; dmarc=none; spf=pass (mx1.freebsd.org: domain of jerry@seibercom.net designates 2607:f8b0:4864:20::72a as permitted sender) smtp.mailfrom=jerry@seibercom.net X-Spamd-Result: default: False [-2.31 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[freebsd-questions@freebsd.org]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; TO_DN_NONE(0.00)[]; HAS_ORG_HEADER(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; DKIM_TRACE(0.00)[seibercom.net:+]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; IP_SCORE(-2.71)[ip: (-9.31), ipnet: 2607:f8b0::/32(-2.24), asn: 15169(-1.94), country: US(-0.05)]; REPLYTO_EQ_TO_ADDR(5.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; MID_RHS_MATCH_FROM(0.00)[]; RECEIVED_SPAMHAUS_PBL(0.00)[250.225.109.174.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.10]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[seibercom.net:s=google]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.20)[multipart/signed,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-questions@freebsd.org]; DMARC_NA(0.00)[seibercom.net]; RCPT_COUNT_ONE(0.00)[1]; RCVD_IN_DNSWL_NONE(0.00)[a.2.7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; RCVD_TLS_ALL(0.00)[] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Dec 2019 12:06:45 -0000 --Sig_/70ydY5=lhCpEjkNFbyEZQCh Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 2 Dec 2019 12:02:23 +0000, Matthew Seaman commented: >On 02/12/2019 11:07, Jerry wrote: >> I am looking for a program that will automate combining IP addresses, >> usually referred to as aggregation. I have been doing it by hand, and >> it is a real PIA. =20 > >As in: take a list of IP numbers and output the smallest netblock >(network address, netmask) that will contain them all? > >If you want a graphical approach, than most IP Address Managment >applications will pretty much do this. Try Netbox for instance: > > https://netbox.readthedocs.io/en/stable/ > >In ports as net-mgmt/netbox. > >Although netbox itself depends on the ip address data types provided by >postgresql: > > https://www.postgresql.org/docs/11/datatype-net-types.html > https://www.postgresql.org/docs/11/functions-net.html > >which suggests that reading your list of ip numbers into a table, and >then calling inet_merge() on the minimum and maximum values will give >you what you want. Something like: > > CREATE TABLE ip_numbers ( ip inet ); > INSERT INTO ip_numbers (ip) VALUES ('192.168.1.1/32'), >'192.168.1.3/32'), ('192.168.24.234/32'),('192.168.63.1/32') ; > >Then: > >=3D> SELECT * FROM ip_numbers ORDER BY ip; =20 > ip >---------------- > 192.168.1.1 > 192.168.1.3 > 192.168.24.234 > 192.168.63.1 >(4 rows) > >=3D> SELECT inet_merge(MIN(ip), MAX(ip)) FROM ip_numbers ; =20 > inet_merge >---------------- > 192.168.0.0/18 >(1 row) > >If you want a more scripted approach, then I'd turn to the netaddr >module in Python: https://netaddr.readthedocs.io/en/latest/ -- >specifically this method: > >https://netaddr.readthedocs.io/en/latest/_modules/netaddr/ip.html#spanning= _cidr > >but writing a very small script to apply that to a list of addresses is >left as an exercise for the student... > > Cheers, > > Matthew Thanks, Matthew. I will give them a try. --=20 Jerry --Sig_/70ydY5=lhCpEjkNFbyEZQCh Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEIQb/tTwl6I1ueEVtOHMGOIfexWQFAl3k/kgACgkQOHMGOIfe xWQ8DggAuc4VFMjYYmU5iUS8HmyaVfLKtiy3ufyEeP9fFtG1RKPkJXbdSWAe9IMm FwNMl4+jjVPeVWuAyvEM4S8oqJI6VR7IM3ewniZ4hiJJVMkSbLx338IJ/ETCkkiu bQDxq/E9GUC8RxbCD33O44rgpsvgwtNWxUyY2NzcMWaRtTr0sEeaKfToWn4pUeIn 8obR1c4jsFQyGJoDHkuDI86YqQi2FkYkbU4N9T2gk+L7YaEGFpK5FoC4Odz8DtRH LOsXv3rHkL+ppHynkjwS+jj5iXs9i6Oj14/c8mgH9PXMk7hcu61Qedn4S3aZkmiD Iqaq87fo7x6UV8dd+u92MdVTawTEoA== =bh6b -----END PGP SIGNATURE----- --Sig_/70ydY5=lhCpEjkNFbyEZQCh--