LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 08-16-2012, 07:18 AM   #1
m4rtin
Member
 
Registered: Sep 2007
Posts: 261

Rep: Reputation: 16
Question is it possible to move iptables rules up or down?


If I execute "iptables -L -n" I can see all the rules in all the chains. Is it possible to change the order of rules using the iptables utility? For example move certain rule up from the bottom? Or is the only way to achieve this by editing the firewall configuration file? In Cisco IOS it's a good practice to add rules with sequence numbers which allows one later to easily insert rules before a certain rule.

Last edited by m4rtin; 08-16-2012 at 07:20 AM.
 
Old 08-16-2012, 08:01 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,373

Rep: Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962Reputation: 1962
you can use the "-I INPUT ##" option to insert at a specific point.
 
Old 08-17-2012, 09:36 AM   #3
m4rtin
Member
 
Registered: Sep 2007
Posts: 261

Original Poster
Rep: Reputation: 16
Quote:
Originally Posted by acid_kewpie View Post
you can use the "-I INPUT ##" option to insert at a specific point.
Thanks! This works beautifully. However, is there a way to list rule numbers in a chain? It would be more convenient to insert rules to chains if for example "iptables -t filter -L INPUT" would print rule number in front of each rule I'm using iptables v1.4.12.1
 
Old 08-17-2012, 09:41 AM   #4
nikmit
Member
 
Registered: May 2011
Location: Nottingham, UK
Distribution: Debian
Posts: 178

Rep: Reputation: 34
Use the --line-numbers option.
iptables -t filter -L INPUT --line-numbers
 
  


Reply


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
iptables - Anyone using iptables with 50,000+ rules? lrirwin Linux - Networking 1 03-21-2012 06:35 PM
Restore iptables Rules that have been saved with iptables-save tiuz Linux - Security 4 08-14-2010 05:50 PM
Why move the udev rules? okos Slackware 8 04-23-2009 09:05 PM
iptables 1.27a still loading rules after installing iptables 1.3.0 yawe_frek Linux - Software 1 06-07-2007 09:50 PM
IPTABLES - rules in /etc/sysconfig/iptables The_JinJ Linux - Newbie 6 11-20-2004 01:40 AM


All times are GMT -5. The time now is 08:03 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration