LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-10-2008, 08:29 PM   #1
Shwick
Member
 
Registered: Jun 2008
Posts: 111

Rep: Reputation: 15
how to clean up iptables?


My iptables script is getting bloated, redundant, and there's code duplication everywhere, how can I clean it up?

Use shell script functions?
Develop it in a different language, like python?
 
Old 12-11-2008, 01:16 AM   #2
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
iptables -F this is most important (flush all rules)
iptables -X (delete all chains)
iptables -Z (clear all the counted packages in all chains)
 
Old 12-11-2008, 04:10 AM   #3
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 4,070

Rep: Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897Reputation: 897
Quote:
and there's code duplication everywhere, how can I clean it up?
Well, you could get rid of the code duplication, that would be a start.

Quote:
...My iptables script...
Does this mean that you are generating your iptables rule set from something like a bash script? If so, much as I like python, i don't think that doing the same thing in python (or other higher level scripting language) is going to make much difference.

My feeling is that you probably need to sit down with a clean sheet of paper and work out a new, more elegant, design than something that has grown over time, and may have become a bit byzantine in structure. But then, I haven't seen what you have at the moment, so its a complete guess as to what you have.
 
Old 12-12-2008, 08:48 AM   #4
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
If you decide to post your script, please do it in a pastebin, not in the thread. This will reduce clutter in the thread, as well as allow opening the script in a separate tab or window or even workspace, so the readers can easily switch between it & the posts about it w/o losing their places in either one (the thread or the script).
 
Old 12-12-2008, 04:29 PM   #5
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 167Reputation: 167
Quote:
Originally Posted by Shwick View Post
My iptables script is getting bloated, redundant, and there's code duplication everywhere, how can I clean it up?

Use shell script functions?
Develop it in a different language, like python?
Sort it into sections, use subroutines, remove extraneous code, change from individual ip addresses to ranges when appropriate, etc.

There are a lot of ways to do this, but most of them involve just sitting down and doing manual clean up of the script.
 
Old 12-12-2008, 04:38 PM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
It might help to print out the different tables separately. E.G. iptables -L INPUT. This may help show where the bloat is and where it isn't.
 
  


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
Clean out HD Mr.Carioca Linux - Software 3 02-10-2008 10:32 PM
iptables v1.2.9: Unknown arg `/sbin/iptables' Try `iptables -h' or 'iptables --help' Niceman2005 Linux - Security 4 12-29-2005 08:20 PM
IPtables Log Analyzer from http://www.gege.org/iptables/ brainlego Linux - Software 0 08-11-2003 06:08 AM
How can I do a clean-up? J_Szucs Linux - Newbie 3 04-30-2002 04:17 PM
My iptables script is /etc/sysconfig/iptables. How do i make this baby execute on boo ForumKid Linux - General 3 01-22-2002 07:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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