• 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

How to block a specific IP Connecting to a server with firewall-cmd

by admin

Question: How tp add a rule using firewall-cmd to drop/reject specific IP connecting to the server? This can be used as an added security on the server.

firewall-cmd is the most common method of managing firewalld configurations (both running as well as permanent). This tool is a part of the firewalld package.

1. Create new rule to drop specific IP connecting on the server.

# firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='xx.xx.xx.xx/xx' drop"

2. Reload firewall-cmd

# firewall-cmd --reload

3. Check new rules.

# firewall-cmd --list-all

Remove the Rule

To remove new created rule:

# firewall-cmd --permanent --remove-rich-rule="rule family='ipv4' source address='xx.xx.xx.xx/xx' drop"

Filed Under: CentOS/RHEL, CentOS/RHEL 7, CentOS/RHEL 8, Linux

Some more articles you might also be interested in …

  1. How to configure xhost to be persistent across reboots in Linux
  2. How to Configure Network Interface Teaming in CentOS/RHEL 7 and 8
  3. 14 Useful “cat” Command Examples in Linux
  4. How to Reset Unknown VM in RHV Engine Database
  5. How to Disable IPv6 on Ubuntu 18.04 Bionic Beaver Linux
  6. How to use compress, zip, gzip commands under Linux
  7. How to set “max_report_luns” and “max_luns” on CentOS/RHEL 7 to scan more than 16,383 LUNs
  8. join Command Examples in Linux
  9. Understanding System Security Services Daemon (SSSD)
  10. CentOS / RHEL : How to make iptable rules persist across reboots

You May Also Like

Primary Sidebar

Recent Posts

  • qemu-system-x86_64: command not found
  • timedatectl: command not found
  • mpirun.openmpi: command not found
  • startkde: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright