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 05-22-2011, 05:42 AM   #1
lordbux
LQ Newbie
 
Registered: May 2011
Posts: 1

Rep: Reputation: Disabled
Can't APPLY Iptables rules


I added a few rules to my
/etc/iptables.rules file and then used

sudo iptables-restore < /etc/iptables.rules

but i got an error saying "iptables-restore: line 29 failed"

But the only word on that line is: COMMIT

Posting the file content below

# Generated by iptables-save v1.4.4 on Sun May 22 00:52:05 2011
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
COMMIT
# Completed on Sun May 22 00:52:05 2011
# Generated by iptables-save v1.4.4 on Sun May 22 00:52:05 2011
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
# Completed on Sun May 22 00:52:05 2011
# Generated by iptables-save v1.4.4 on Sun May 22 00:52:05 2011
*filter
:FORWARD ACCEPT [0:0]
:INPUT DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --sport 80 -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A OUTPUT -p tcp -m tcp -m owner --sport 80 --uid-owner squid -j ACCEPT
-A OUTPUT -p tcp -m tcp -m owner --sport 3128 --uid-owner squid -j ACCEPT
-A OUTPUT -p tcp -m tcp --sport 80 -j REDIRECT --to-ports 8080
-A OUTPUT -p tcp -m tcp --sport 3128 -j REDIRECT --to-ports 8080
COMMIT
# Completed on Sun May 22 00:52:05 2011
 
Old 05-22-2011, 07:25 AM   #2
vkvs
LQ Newbie
 
Registered: May 2011
Posts: 23

Rep: Reputation: 2
Here is your problem:
-A OUTPUT -p tcp -m tcp --sport 80 -j REDIRECT --to-ports 8080
-A OUTPUT -p tcp -m tcp --sport 3128 -j REDIRECT --to-ports 8080

Edit: Check out http://www.ghacks.net/2010/06/14/int...n-to-iptables/
Now each chain can handle the packet traffic in one of four different ways (actions):

ACCEPT: Allow the packet in/out.
REJECT: The target device will reject the packet.
DROP: The packet is immediately dropped and the target device never sees said packet.
RETURN: Go to another chain in your table as if it never saw the rejecting chain.

Last edited by vkvs; 05-22-2011 at 07:56 AM.
 
  


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
Restore iptables Rules that have been saved with iptables-save tiuz Linux - Security 4 08-14-2010 05:50 PM
IPTABLES Apply Certain Rules to Certain Mac Addresses weboy Linux - Security 6 07-17-2010 09:12 AM
[SOLVED] udev rules to automatically apply 666 permission linuxmandrake Linux - Newbie 2 04-03-2010 03:31 AM
iptables doesn't seem to apply new rules to already open TCP connections Ahmed_Baghdad Linux - Networking 2 09-27-2007 02:06 AM
Ximian Evolution wont apply rules/filters!! newbie2002 Linux - General 2 12-05-2002 10:50 PM

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

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