Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 05-10-2013, 07:46 AM   #1
Registered: Sep 2007
Posts: 102

Rep: Reputation: 12
How to use the -R[replace] option of the iptables.


I am not able find a simple example of use of -R option of iptables.
what I got is ,it is possible to replace a previous rule to some other position.but how to do this.

Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- anywhere
DROP all -- anywhere

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

I need the rule 2 to be the first one so ,how I will do that.

Kindly tell any answer regarding this.

Old 05-10-2013, 09:14 AM   #2
Senior Member
Registered: Oct 2009
Location: Wroclaw, Poland
Distribution: Arch, Kubuntu
Posts: 1,261

Rep: Reputation: 315Reputation: 315Reputation: 315Reputation: 315
-R option is for replacing rules, not for moving it. You want to make delete and then insert in proper position, like:
iptables -D INPUT 1
iptables -I INPUT 2 -s -j DROP
iptables -A INPUT -s -j DROP
As these are probably only temporary, you need to change position of these rules in your firewall configuration file, where they are loaded at boot.

Last edited by eSelix; 05-10-2013 at 09:18 AM.
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Iptables error, unknown option --state leftism Linux - Networking 1 11-03-2012 04:34 AM
IPTables interface option priyadarshan Linux - Security 6 11-11-2011 12:24 AM
Question about an iptables option kaplan71 Linux - Software 1 01-21-2009 05:18 PM
How to replace iptables by fwbuilder script ? marozsas Fedora 2 04-10-2006 08:40 AM
iptables-restore v1.2.11: Line 68 seems to have a -t table option. SupaDucta Linux - Networking 2 01-11-2006 05:38 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:46 PM.

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