• 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. archivemount Command in Linux
  2. physlock: command not found
  3. pacman: command not found
  4. How to monitor /etc/shadow and /etc/passwd file for changes with Auditd?
  5. What are the Network Bonding Modes In CentOS / RHEL
  6. Linux OS Service ‘yum-updatesd’
  7. How to Uninstall/Remove GNOME from CentOS/RHEL 7
  8. printf: command not found
  9. How to set custom device names using udev in CentOS/RHEL 7
  10. CentOS / RHEL 7 : How to Install GUI

You May Also Like

Primary Sidebar

Recent Posts

  • pw-cat Command Examples in Linux
  • pvs: command not found
  • pulseaudio: command not found
  • pulseaudio Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright