Knowledgebase

Iptables insert rule at top of tables ( PREPEND rule on Linux )

iptables is Linux administration tool for IPv4 packet filtering and NAT. One can use iptables/ip6tables to set up, manage, and examine the tables of IPv4 and IPv6 packet filter rules in the Linux kernel. This page shows how to use Iptables to insert the rule at top of tables.

To list iptables rules with line numbers

syntax:
sudo iptables -t filter -L INPUT --line-numbers -n
sudo iptables -t filter -L OUTPUT --line-numbers -n
sudo iptables -t filter -L FORWARD --line-numbers -n
sudo iptables -t nat -L --line-numbers -n

Iptables insert the rule at top of tables Linux syntax

The iptables allows you to APPEND or INSERT or REPLACE firewall rules as follows.

Iptables append firewall rules to the end of the selected chain

The syntax is:

iptables -A chain firewall-rule

Iptables prepend firewall rules to the end of the selected chain

You need to use the following syntax:

iptables -I chain [rule-number] firewall-rule

Linux Iptables insert/prepend rule at top of tables command summary

You need to use the following syntax:

sudo iptables -I chain [rule-number] firewall-rule
 

 

  • Iptables insert rule at top of tables ( PREPEND rule on Linux )
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

System Requirements

Most current web servers with PHP & MySQL installed will be capable of running WHMCS. The...

Common logs file paths

Log files are helpful in troubleshooting issues and in monitoring the performance of cPanel...

Disable ModSecurity in cPanel

What is ModSecurity?Mod_security is an apache module that helps to protect your website from...

How to disable directory listing in cpanel?

Disable directory listing in cpanelIndex Manger in cPanelThe Index Manager allows you to...

How to disable the listing in a non-cPanel CentOS server?

How to disable the listing in a non-cPanel CentOS server?1. Locate your httpd.conf file. Normally...