LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 01-31-2012, 03:32 PM   #1
-Karl-
LQ Newbie
 
Registered: Jan 2012
Posts: 3

Rep: Reputation: Disabled
iptables population


Hello,

Is there such a way as to drop ALL traffic except those which are defined in a text file?

I want output the IP's which are located in a database to a text file on a different server, and whitelist those IP's on that server, but drop all others.

Firstly, is it possible? Secondly, what would be the best way about doing it from a different server?

Regards,
Karl
 
Old 01-31-2012, 03:57 PM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
You could use a script to create iptables rules from the text file and use that to populate your iptables file then simply restart iptables so it reads in the modified file. You'd put in all your white list items towards the top of the file and your final rule would be the one that drops everything.

If this is a RHEL derived distro the iptables file is /etc/sysconfig/iptables.
 
Old 01-31-2012, 03:58 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
yes, that's possible to achieve, but you wouldn't actually read them from a file as part of the rules. You'd need some script which will load the list and insert the rules into the rule base. You could take a few approaches, but I'd probably suggest that create a separate chain specifically for these IP addresses, and point your standard rulebase to that chain at the appropriate place. then write a separate script to take whatever form of output your database provides and drop each one into an iptables command in this new chain. so each time that file changes you flush out the chain and repopulate it really easily. That should be simple enough if you have no preferential way of doing it.
 
1 members found this post helpful.
Old 01-31-2012, 04:02 PM   #4
-Karl-
LQ Newbie
 
Registered: Jan 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks for your advice guys, There's one problem, I wouldn't know where to begin to create such a script to do that.
 
Old 01-31-2012, 05:13 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
At the end of the PDF posted at http://www.linuxquestions.org/questi...dresses-29893/ you'll find some eay ways to achieve what you want using the iptables "recent" module or using 'ipset'.
 
  


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
Google+ population explodes to 10 million dEnDrOn Linux - News 0 07-12-2011 07:33 PM
World Population of Apple Mac HomeDesktop/Servers v.s. Linux / MicrosoftWindows? frenchn00b Other *NIX 3 01-07-2008 06:10 PM
LXer: Second Life's population problems LXer Syndicated Linux News 0 03-07-2007 10:31 AM
Make Linux easier for the general population! Please. Paul Parr General 2014 06-03-2005 02:53 PM
LQ Population X11 General 32 04-17-2002 09:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:50 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