Results 1 to 6 of 6

Thread: Adding a suffix to CIDR formatted IP blocks

  1. #1
    ɯʎɔɐɹsɐʌʍ mycarsavw's Avatar
    Join Date
    Feb 2007
    Posts
    4,945
    Thanks
    1,097
    Thanked
    652 times in 481 posts
    • mycarsavw's system
      • Motherboard:
      • P8H77-M Pro
      • CPU:
      • i5 3350P
      • Memory:
      • 16Gb
      • Storage:
      • Lots
      • Graphics card(s):
      • R9 285
      • PSU:
      • HX 620w
      • Case:
      • FD Define Mini
      • Operating System:
      • W10
      • Monitor(s):
      • BenQ G2420HDBL + GL2450HT
      • Internet:
      • Sky

    Adding a suffix to CIDR formatted IP blocks

    Not sure if this is the correct subforum for this, but it concerns networking so why not?

    I'll explain it all in case there's an easier procedure that I've missed. I understand cron jobs but I need to add my own data to the IP blocks

    I block Chinese and Korean spam by using a list of IP blocks from here - the guy who maintains the list has added China or Korea to identify the origin country of each block.

    I paste the list into /var/smoothwall/ipblock/config and use Find/Replace to edit the rules into the correct syntax recognised by the Smoothwall

    I start with 1.11.0.0/16 Korea. I use Find to locate all instances of ' Korea' and use Replace to replace all instance with ',off,DROP,on,#Korea'. I end up with - 1.11.0.0/16,off,DROP,on,#Korea

    off stops the firewall logs being filled up with hits from these IPs | DROP drops the packets | on enables the rule | #<text> adds a comment or identifier to the rule

    This works. Korean/Chinese spam is blocked and my logs aren't full of hits.

    Still with me?

    I'd like to add Russia and a few other questionable blocks to my spamblocklist. Country IP Blocks™ has the data I need, but the blocks aren't labelled and there's a lot of them.

    Code:
    # Country: RUSSIAN FEDERATION
    # ISO Code: RU
    # Total Networks: 4,654
    # Total Subnets:  37,036,552
    2.60.0.0/14
    2.92.0.0/14
    31.3.....
    Word, Wordpad, Notepad, Notepad+ and so on do not allow you to replace 'nothing' with text, so I can't use Find/Replace.

    So, the whole point of this post is to ask how I can add ,off,DROP,on,#Russia to the end of each of the 4,654(!) lines.
    Last edited by mycarsavw; 29-09-2011 at 03:51 PM.
    |Kata: "Read title as 'fisting'. Not sure why I clicked. Relieved, really."|
    |TAKTAK: "It was so small that mine wouldn't fit into it"|

  2. #2
    Senior Member FatalSaviour's Avatar
    Join Date
    Jun 2004
    Location
    London/Oxford/York
    Posts
    1,876
    Thanks
    42
    Thanked
    12 times in 11 posts
    • FatalSaviour's system
      • Motherboard:
      • MSI P55-GD80
      • CPU:
      • Intel Core i7 860
      • Memory:
      • 4x2GB GEiL PC17000
      • Storage:
      • 3x1000GB, 2x500GB (RAID1), 1x2TB
      • Graphics card(s):
      • GTX 470
      • PSU:
      • Corsair HX700
      • Case:
      • Antec P180
      • Operating System:
      • Win 7 x64
      • Monitor(s):
      • Dell U2311, Dell 2005FPW
      • Internet:
      • VM 30Mb

    Re: Adding a suffix to CIDR formatted IP blocks

    Chuck it into Excel, copy and paste the suffix into the column adjacent to these and then use CONCATENATE to merge the two?
    Hope that helps, but apologies if I've misunderstood!
    Quote Originally Posted by Noni
    What the hell does "WTH" mean


  3. Received thanks from:

    mycarsavw (29-09-2011)

  4. #3
    ɯʎɔɐɹsɐʌʍ mycarsavw's Avatar
    Join Date
    Feb 2007
    Posts
    4,945
    Thanks
    1,097
    Thanked
    652 times in 481 posts
    • mycarsavw's system
      • Motherboard:
      • P8H77-M Pro
      • CPU:
      • i5 3350P
      • Memory:
      • 16Gb
      • Storage:
      • Lots
      • Graphics card(s):
      • R9 285
      • PSU:
      • HX 620w
      • Case:
      • FD Define Mini
      • Operating System:
      • W10
      • Monitor(s):
      • BenQ G2420HDBL + GL2450HT
      • Internet:
      • Sky

    Re: Adding a suffix to CIDR formatted IP blocks

    I spent about 300 hours trying to work out how to phrase the question.

    Now I look stupid.

    Thank you
    |Kata: "Read title as 'fisting'. Not sure why I clicked. Relieved, really."|
    |TAKTAK: "It was so small that mine wouldn't fit into it"|

  5. #4
    Senior Member
    Join Date
    Feb 2008
    Posts
    925
    Thanks
    4
    Thanked
    161 times in 148 posts
    • smargh's system
      • Motherboard:
      • Gigabyte GA-EP45-UD3P
      • CPU:
      • Xeon E5450 with 775-to-771 Mod
      • Memory:
      • 16GB Crucial
      • Storage:
      • Intel X25-M G2 80GB/Adaptec 3405 4x 2TB Ultrastar RAID1 / 1x 6TB Hitachi He6 / Dying 2TB Samsung
      • Graphics card(s):
      • GTX 750 Ti
      • PSU:
      • Seasonic X-560
      • Case:
      • Lian-Li PC-A71
      • Operating System:
      • Windows 7 Ultimate 64bit
      • Monitor(s):
      • BenQ G2400WD
      • Internet:
      • Really Crap ADSL2 <3Mbit

    Re: Adding a suffix to CIDR formatted IP blocks

    Textpad, with the regex option ticked:

    Replace: $
    With: ,off,DROP,on,#Russia

    $ in regular expression speak is end-of-line. ^ is the start of the line.

    Notepad+ can probably also do regex search & replace.

  6. Received thanks from:

    mycarsavw (30-09-2011)

  7. #5
    Senior Member FatalSaviour's Avatar
    Join Date
    Jun 2004
    Location
    London/Oxford/York
    Posts
    1,876
    Thanks
    42
    Thanked
    12 times in 11 posts
    • FatalSaviour's system
      • Motherboard:
      • MSI P55-GD80
      • CPU:
      • Intel Core i7 860
      • Memory:
      • 4x2GB GEiL PC17000
      • Storage:
      • 3x1000GB, 2x500GB (RAID1), 1x2TB
      • Graphics card(s):
      • GTX 470
      • PSU:
      • Corsair HX700
      • Case:
      • Antec P180
      • Operating System:
      • Win 7 x64
      • Monitor(s):
      • Dell U2311, Dell 2005FPW
      • Internet:
      • VM 30Mb

    Re: Adding a suffix to CIDR formatted IP blocks

    Quote Originally Posted by smargh View Post
    Textpad, with the regex option ticked:

    Replace: $
    With: ,off,DROP,on,#Russia

    $ in regular expression speak is end-of-line. ^ is the start of the line.

    Notepad+ can probably also do regex search & replace.
    That's also good to know for the future - thanks smargh.
    Anywho, hope that helped OP, was interested enough in your first post to start investigating possibly putting such as blacklist in at work :-)
    Quote Originally Posted by Noni
    What the hell does "WTH" mean


  8. #6
    ɯʎɔɐɹsɐʌʍ mycarsavw's Avatar
    Join Date
    Feb 2007
    Posts
    4,945
    Thanks
    1,097
    Thanked
    652 times in 481 posts
    • mycarsavw's system
      • Motherboard:
      • P8H77-M Pro
      • CPU:
      • i5 3350P
      • Memory:
      • 16Gb
      • Storage:
      • Lots
      • Graphics card(s):
      • R9 285
      • PSU:
      • HX 620w
      • Case:
      • FD Define Mini
      • Operating System:
      • W10
      • Monitor(s):
      • BenQ G2420HDBL + GL2450HT
      • Internet:
      • Sky

    Re: Adding a suffix to CIDR formatted IP blocks

    smargh - that works and is a lot easier - thank you!

    Fatal - thanks, they both helped and I learnt something new again.

    As for trying it out, go for it
    |Kata: "Read title as 'fisting'. Not sure why I clicked. Relieved, really."|
    |TAKTAK: "It was so small that mine wouldn't fit into it"|

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. 4 days and counting...
    By Lowe in forum Software
    Replies: 72
    Last Post: 03-02-2008, 11:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •