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.
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.
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.
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.
Magento is a free and open-source e-commerce platform written in PHP. It is simple, easy…
ISPConfig is an open-source control panel that allows users to manage multiple servers from a…
As a Linux administrator, you may find it necessary to troubleshoot or test your Simple…
Ubuntu 24.04, like many modern Linux distributions, relies on the NetworkManager for managing network connections.…
Restic is a modern, open-source backup program designed for efficiency, security, and simplicity. It enables…
phpMyAdmin is a popular free tool written in PHP intended to administer MySQL and MariaDB…