• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

CentOS / RHEL : How to add iptable rules

by admin

The syntax to add an iptables rule is as shown below.

# iptables -I INPUT [line number] -s [ip address or subnet] -j ACCEPT

For example to add a new rule at line number 2 to allow subnet 192.168.0.0/24.

# iptables -I INPUT 2 -s 192.168.0.0/24 -j ACCEPT

Saving iptable rules

After configuring the iptables rules from the command line, it is required to save the iptable rules. It is important to save the list of iptable rules to make them persist across reboots or restart of iptable service.

# service iptables save

Filed Under: Linux

Some more articles you might also be interested in …

  1. nano: command not found
  2. lsusb Command Examples in Linux
  3. How to uninstall fail2ban on Ubuntu
  4. How to kill Processes in Linux using kill, killall and pkill
  5. Beginners guide to Device Mapper (DM) multipathing
  6. how to add a custom script to the systemd in CentOS/RHEL 7
  7. atq Command Examples in Linux
  8. pscp – ssh_init: Network error: Cannot assign requested address
  9. qm create Command Examples in Linux
  10. How To Open A Port In CentOS / RHEL 7

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright