M
M
mihasyo2020-12-03 17:56:38
linux
mihasyo, 2020-12-03 17:56:38

How can I calculate the minimum subnet masks for a pool of addresses?

There is a txt file with 1.35 million sorted and unique IP addresses of botnet networks/infected servers that are constantly roaming the net. Type:


1.2.169.8
1.2.169.12
1.2.169.28
1.2.169.49
1.2.169.81
1.2.169.101
1.2.170.104
1.2.170.109
1.2.170.110 ...
_


Actually, there is a very strong desire to pervert and reduce this list by means of masks, with a minimal loss of "white" (not included in this list) IP addresses to the form:

1.2.169.0/25
1.2.170.104/26
...


So that later the entire list can be fed to the networks of filial Mikrotiks and set up rules in the fireworks.
Yes, I myself know that this is from a cannon on sparrows, but nonetheless. Interest pursues me.

Actually the question is: are there any programs or maybe someone has come across ready-made Python / Bash scripts with this implementation?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Keffer, 2020-12-03
@Keffer

Don't be perverted. It doesn't work that way, and littering the address of microtax sheets with lists merged somewhere with millions of addresses is noble masturbation. If you want the bots not to knock, just set up the firework correctly, determine what you are protecting and from what.

R
Roman Sokolov, 2020-12-03
@jimquery

Advise correctly. Specifically, on the topic, the iprange utility should help you:
https://github.com/firehol/iprange/wiki

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question