Categories: DebianLinuxShell

How to Enable/Disable Ping using iptables on Debian 10

In a production environment, it is common practice to disable network ping for a security reason so that no one can ping your server. However, by default, ping is enabled on Linux servers.

In this tutorial, I am going to show you the way you can use iptables firewall to disable or enable the ping port. I have run the commands on Debian 10. However, it should work on most other Linux systems as well.

Checking Ping in iptables

Open the terminal and check the ping status using the following command.

ping 127.0.0.1

As you can see from the following screenshot, the ping is enabled on our system.

Disabling Ping with iptables

When we have verified that the ping is enabled, let us disable it in iptables.

Open the terminal with root privileges and execute the following command.

$ sudo iptables -A INPUT -p icmp --icmp-type echo-request -j REJECT

Again, let us check the list of rules in iptable using the following command.

iptables -L

From the following screenshot, we can clearly see that the new rule is in iptables.

Let us check the ping status now using the following command.

ping 127.0.0.1

As you can see from the above screenshot, the ping is now disabled.

Enabling Ping in iptables

If you want to enable the ping in an iptables, run the following command to delete the above rule.

Issue the following command and you will notice that there is no rule in iptables.

You can also ping the localhost and you will notice that you are successful.

ping 127.0.0.1

I hope this tutorial was helpful to you. Wait for the new article.

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

Recent Posts

How to Install Magento 2 on AlmaLinux

Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…

1 year ago

How to Install ISPConfig Hosting Control Panel with Apache Web Server on Ubuntu 24.04

ISPConfig is an open-source control panel that allows users to manage multiple servers from a…

1 year ago

How to Test your Email Server (SMTP) Using the Telnet Command

As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…

1 year ago

Managing Network Interfaces and Settings on Ubuntu 24.04 with nmcli

Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…

2 years ago

Using Restic Backup on Ubuntu 24.04

Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…

2 years ago

Installing phpMyAdmin on Rocky Linux 9 and Securing it with Let’s Encrypt SSL

phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…

2 years ago