DaemonForums  

Go Back   DaemonForums > Other Operating Systems > Other BSD and UNIX/UNIX-like

Other BSD and UNIX/UNIX-like Any other flavour of BSD or UNIX that does not have a section of its own.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 3 Weeks Ago
mateusrico mateusrico is offline
New User
 
Join Date: May 2008
Posts: 5
Default Help with script

Hello friends
I need help, I have three files with thousands of subnets, sometimes I need to unlock an ip that is connected to some or some subnets.
I need a script that typing the IP look for these three files showing the subnets attached to that IP, removing the subnet automatically remove the block for the IP. the method I use currently allows me to find in which file the subnet is, but finding the subnet is not so easy.
I use linux ubuntu and the files are in "ipset" format, the script can be in bash, perl, python, etc ...
Thanks for the help.
Reply With Quote
  #2   (View Single Post)  
Old 3 Weeks Ago
ibara's Avatar
ibara ibara is offline
Future Defcon 201 speaker
 
Join Date: Jan 2014
Posts: 630
Default

I have no idea what ipset format is, but seems like this is an awk one-liner.
Reply With Quote
  #3   (View Single Post)  
Old 3 Weeks Ago
mateusrico mateusrico is offline
New User
 
Join Date: May 2008
Posts: 5
Default

Quote:
Originally Posted by ibara View Post
I have no idea what ipset format is, but seems like this is an awk one-liner.
ipset format is
add country-name xxx.xxx.xxx.xxx/xx
add country-name xxx.xxx.xxx.xxx/xx

basically one subnet per line
Reply With Quote
  #4   (View Single Post)  
Old 3 Weeks Ago
ibara's Avatar
ibara ibara is offline
Future Defcon 201 speaker
 
Join Date: Jan 2014
Posts: 630
Default

Still not entirely sure what you're asking. Can you write out an actual line you want to change and what you want to change it to?
Reply With Quote
  #5   (View Single Post)  
Old 3 Weeks Ago
mateusrico mateusrico is offline
New User
 
Join Date: May 2008
Posts: 5
Default

Quote:
Originally Posted by ibara View Post
Still not entirely sure what you're asking. Can you write out an actual line you want to change and what you want to change it to?
I need a script that finds the subnet related to it in a file containing several subnets of some sort.
./findip.sh 187.221.32.45 /root/country.txt
and as a result:
187.221.32.0/24
I do not have advanced knowledge in bash script to do it.
My language is Portuguese, I'm using google translate to write this.
Reply With Quote
  #6   (View Single Post)  
Old 2 Weeks Ago
ibara's Avatar
ibara ibara is offline
Future Defcon 201 speaker
 
Join Date: Jan 2014
Posts: 630
Default

Please upload one of those files here (if you can).
Reply With Quote
  #7   (View Single Post)  
Old 2 Weeks Ago
jb_daefo jb_daefo is offline
Spam Deminer
 
Join Date: May 2008
Posts: 289
Default

That includes subnetting arithmetic...
better yet
grep 187.221.32 /root/country.txt
then awk to exclude the country name if that is needed.

An educated guess anyway
__________________
FreeBSD 12.0-CURRENT
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Learning to script... RJPugh Programming 7 9th November 2014 08:04 PM
Script: how translate for i in `seq $1 $2`? aleunix OpenBSD General 5 12th March 2012 07:38 PM
Handy X11 script Gabe_G23 Guides 6 25th October 2008 05:08 PM
my 1st sh script graudeejs Programming 12 18th August 2008 10:25 PM
Perl Script c0mrade Programming 1 26th June 2008 05:04 AM


All times are GMT. The time now is 09:55 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick