Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-14-2010, 11:47 AM
|
#1
|
|
Member
Registered: Mar 2006
Distribution: Slackware
Posts: 42
Rep:
|
Restore iptables Rules that have been saved with iptables-save
Hello,
A while ago i have saved iptables Rules with iptables-save to a file.
Now i need to do some modifikations and i would like to know if there is a way to get the contents of the file that has been saved with iptables-save back to "Human Readable form again"
For example: THIS form:
# Generated by iptables-save v1.3.5 on Sat Oct 28 15:10:09 2006
*mangle
:PREROUTING ACCEPT [40511857:54699979328]
:INPUT ACCEPT [40485221:54677480953]
:FORWARD ACCEPT [26394:22470203]
:OUTPUT ACCEPT [22521741:1599930162]
:POSTROUTING ACCEPT [22544591:1622118540]
COMMIT
# Completed on Sat Oct 28 15:10:10 2006
# Generated by iptables-save v1.3.5 on Sat Oct 28 15:10:10 2006
*filter
:INPUT ACCEPT [40479586:54675697556]
:FORWARD ACCEPT [26385:22469703]
:OUTPUT ACCEPT [22515275:1599136686]
-A INPUT -i eth1 -j DROP
COMMIT
# Completed on Sat Oct 28 15:10:10 2006
Into this form (how you enter the rules with iptables):
iptables -A INPUT -i ppp0 -p tcp --dport 21 -j DROP
etc etc.....
Thanks,
tz
|
|
|
|
08-14-2010, 01:45 PM
|
#2
|
|
Moderator
Registered: May 2001
Posts: 24,805
|
It's human readable form already and you only have one filtering rule (which kind of fails to make sense anyway). Your new line you can add to the "*filter" table section below or instead of the "-A INPUT -i eth1 -j DROP" as "-A INPUT -i ppp0 -p tcp --dport 21 -j DROP".
|
|
|
|
08-14-2010, 04:05 PM
|
#3
|
|
Member
Registered: Mar 2006
Distribution: Slackware
Posts: 42
Original Poster
Rep:
|
Erm, well itīs only a part of the iptables-saved file (not the full one) and the line with A INPUT -i eth1 -j DROP was where just examples. I just want to know if itīs possible to get rules that have been saved with iptables-save back into a form as you give with iptables.
I mean you donīt enter
:PREROUTING ACCEPT [40511857:54699979328]
:INPUT ACCEPT [40485221:54677480953]
:FORWARD ACCEPT [26394:22470203] etc...etc...
in the command line
tz
|
|
|
|
08-14-2010, 05:33 PM
|
#4
|
|
Moderator
Registered: May 2001
Posts: 24,805
|
Here's a kludge:
Code:
cat /path/to/iptables-save | while read LINE; do
case "${LINE}" in
\**) export TABLE="${LINE:1}";;
:*) LINE=(${LINE}) ; echo "/sbin/iptables -t "${TABLE} -P ""${LINE[0]:1:255}" "${LINE[1]}"";;
-A*) echo "/sbin/iptables -t ${TABLE} ${LINE}";;
esac
done
YMMV(VM)
|
|
|
|
08-14-2010, 05:50 PM
|
#5
|
|
Member
Registered: Mar 2006
Distribution: Slackware
Posts: 42
Original Poster
Rep:
|
Nice one ! THANKS !!
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 09:48 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|