LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-03-2013, 01:21 PM   #1
mcginlej
LQ Newbie
 
Registered: Aug 2013
Location: Parsippany, NJ
Distribution: SUSE 11.0 SP2 & SP3
Posts: 7

Rep: Reputation: Disabled
iptables blocking all ips except US & US Amazon. Can't log dropped IPs.


I'm looking for help logging dropped IPs (Non US). If I place the log request before the -P INPUT DROP all IPs get logged. Can someone please advise.

-A INPUT -p tcp --dport 22 -j ACCEPT
-A OUTPUT -p tcp --sport 22 -j ACCEPT
-A INPUT -j LOG --log-level 4 --log-prefix 'InDrop '
-P INPUT DROP
-A INPUT -s 192.168.0.0/24 -j ACCEPT
-A INPUT -s 172.16.1.30/24 -j ACCEPT
.
. Accepting US IPs
.
-A INPUT -s 149.11.66.6/31 -j ACCEPT
-A INPUT -s 72.44.32.0/19 -m limit --limit 5/m --limit-burst 7 -j LOG --log-prefix "Amazonaws IP Drop A:"
-A INPUT -s 67.202.0.0/18 -m limit --limit 5/m --limit-burst 7 -j LOG --log-prefix "Amazonaws IP Drop A:"
.
. Logging Amazon Cloud
.
-A INPUT -s 54.233.0.0/18 -m limit --limit 5/m --limit-burst 7 -j LOG --log-prefix "Amazonaws IP Drop A:"
-A INPUT -s 96.127.0.0/18 -m limit --limit 5/m --limit-burst 7 -j LOG --log-prefix "Amazonaws IP Drop A:"
-A INPUT -s 72.44.32.0/19 -j DROP
-A INPUT -s 67.202.0.0/18 -j DROP
.
. Dropping Amazon Cloud
.
-A INPUT -s 174.129.0.0/16 -j DROP
-A INPUT -s 204.236.192.0/18 -j DROP

Thanks,

Jamie
 
Old 10-05-2013, 02:00 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Couple of problems with your post: you seem to miss common rules with respect to state and devices (loopback), your rules do not seem to have a logical order and you're trying to -j DROP stuff even while you have a DROP ingress policy. That can be easily remedied by reading http://www.frozentux.net/documents/iptables-tutorial/. You also posted a seemingly incomplete rule set: best just run 'iptables-save' to get the right output. If you understand what you're doing you could change the filter table INPUT chain default policy to ACCEPT, the use -j LOG lines directly before -j DROPping traffic and end the chain with a catch all REJECT or DROP rule.
 
1 members found this post helpful.
Old 10-08-2013, 10:43 AM   #3
mcginlej
LQ Newbie
 
Registered: Aug 2013
Location: Parsippany, NJ
Distribution: SUSE 11.0 SP2 & SP3
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks for your advice. I am new to iptables and am still trying to understand it better. I thought making the INPUT policy DROP and accepting USA would be easier then identifying all Non-US country IP & would take less storage to load. The reason I logged & dropped Amazon AWS was because the IP's were in the US. Our Linux system is in between the Internet and our mainframe. It was getting hammered and I had to come up with a solution which is working but needs to be setup properly. I will check out the link you provided.
 
Old 10-08-2013, 12:18 PM   #4
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
To be clear, order in iptables matters. So if you have "ACCEPT" rules before your "BLOCK" rules then the "ACCEPT" rules will skip over them. You must order them in a way in which you wish them to be addressed. That means if you accept certain IP blocks but wish to drop ip ranges which fall inside the accepted blocks then you must put those DROP rules for the blocked range before the encompassing ACCEPT range.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Blocking IPs log from honeyd crackyblue Linux - Enterprise 3 09-19-2007 10:07 PM
iptables help please with blocking range of IPs lleb Linux - Software 7 02-26-2007 10:09 AM
Blocking certain IPs with iptables - what am I doing wrong? thinksincode Linux - Security 2 12-21-2004 10:27 AM
how to define a specific range of IPs and/or multiple IPs in an iptables rule?... TheHellsMaster Linux - Security 9 09-20-2004 10:06 AM
Blocking A Class of Ips w/ Iptables kemplej Linux - Security 4 09-03-2004 11:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration