Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
A little IP shortening script?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
RayOfLight
n00b
n00b


Joined: 27 Aug 2013
Posts: 56
Location: Catalunya

PostPosted: Wed Feb 14, 2018 3:51 pm    Post subject: A little IP shortening script? Reply with quote

In the last years I have accrued a large list of naughty IPs: Santa's naughty IP list

This list is duplicated in my iptables configuration, but I'd like to compress it, and maybe make it less specific and more general.

Does anyone here know of a tool that given a set of IPs, outputs the largest possible subnet / CIDR format?

for example, given 1.2.3.4 and 2.3.4.5, it outputs 1.2.3.4/32 and 2.3.4.5/32, but with 1.2.3.0 and 1.2.3.1, it outputs 1.2.3.0/31

It is my understanding that iptables can not only apply rules on a specific address but on a full subnet if required.


Last edited by RayOfLight on Wed Feb 14, 2018 4:54 pm; edited 1 time in total
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 2878
Location: Illinois, USA

PostPosted: Wed Feb 14, 2018 4:49 pm    Post subject: Reply with quote

Post a list like that with pastebin. I wondered if it ever was going to finish scrolling.
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5592

PostPosted: Wed Feb 14, 2018 4:55 pm    Post subject: Reply with quote

Not automated, but most of that list can trivially be compacted.
Code:
~ $ jwhois 222.186.21.235
inetnum:        222.184.0.0 - 222.191.255.255

~ $ ipcalc 222.184.0.0 - 222.191.255.255
deaggregate 222.184.0.0 - 222.191.255.255
222.184.0.0/13
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum