Hackers could use a ping flood attack, also known as a “ping of death,” to overwhelm a target device with many ping requests, potentially causing it to crash or make it unresponsive. So, if you are concerned about the safety for your Linux Mint and want to block the ping request option then read this guide.
How to Block and Unblock Ping Requests on Linux Mint 21
The ping request is used to verify connectivity and determine the round-trip time it takes for a packet to be sent and received. There are different ways to block a ping request and vice versa, some of them are given below:
1: Block and Unblock Ping Requests Through Kernel Parameters
In the Linux operating system, kernel parameters are values that can be passed to the kernel at boot time to modify its behavior or configure certain features. So, there are three ways by which kernel parameters can be used to block and unblock ping requests:
i: Using sysctl command to change the parameters
ii: Changing parameters in the .conf file
i: Using sysctl Command to Change the Parameters
One way to block or unblock the ping request through kernel parameters is by using the sysctl command and for that go through the steps mentioned below:
Step 1: Before going to block the ping request first check if it is active or not and for that use the below given syntax:
Like in my case I have used an IP address by following the above-mentioned syntax:
Step 2: If the system is active or unblock it will receive and send packets as in the image above along with the total time, now let’s use the sysctl command to the ping request by executing:
Now let’s see if the ping request is blocked or not and for that follow the given below syntax:
To test I have sent three packets on IP address by following the above given syntax:
You will see that after some time ping statistics will appear stating 100% packet loss which depicts that ping request is blocked.
Step 3: Now to unblock the ping request and for that just change the value from 1 to zero by executing:
Now check the of the ping request is unblocked by using the same syntax we mentioned previously:
ii: Changing Parameters in the .conf File
Another way to block the ping request is by editing the configuration file by adding net.ipv4.icmp_echo_ignore_all=0 line, here are some steps that one need to follow to get along with this method:
Step 1: First open the sysctl.conf file with the help on nano command by executing:
Now enter the following line in the file and afterwards save it and close it:
Step 2: Next, to apply the changes use the –p flag with sysctl:
Step 3: Now check if the ping is blocked by using the above-mentioned syntax:
Step 4: To unblock simply change the value of the line we added previously to 0 in the configuration file from 1 and save the changes:
Next To apply the changes done to the configuration file execute:
Now check if the ping request is unblocked send three packets ping request by executing:
2: Block and Unblock Ping Requests Through Iptables
Iptables is a firewall utility built into the Linux kernel that allows users to configure rules for inbound and outbound network traffic. To make the blocking of the ping request permanently that do not reverse on reboot of Linux Mint one can use IP tables and for that go through the subsequent steps:
Step 1: Normally the iptables is already installed on Linux Mint 21 if in any case you do not have it installed then execute:
Step 2: Next, execute the following command to instruct the firewall to block any ping requests:
Now send a ping request of three packets to check if the ping request is blocked or not by executing:
Step 3: Next, to unblock the ping requests just execute the same previous command, just replace the A flag with the D flag like this:
Next to verify the if the ping request is unblocked send three packets in the ping request by executing:
The changes we made in the above steps for blocking and unblocking the ping requests will not survive the system reboot.
Using iptables-presistent to save the rules
So, to save the rules one need to install iptables persistent on Linux Mint, for that follow the below steps:
Step 1: The iptables-persistent package is a utility that allows users to save their iptables firewall rules so that they are automatically applied at boot time, to install it execute:
Next, press Enter to Yes to save the rules:
Next set the rules.v6 file as the configuration file for saving the rules of IP version 6 by pressing Enter on Yes:
Step 2: Once the installation is done check the list of rules saved in the iptables by executing:
Step 3: Next execute the following command to save the rule for blocking or unblocking the ping request:
Step 4: Next after saving the rules reload the netfilter to make the changes inevitable on reboot by executing:
Conclusion
Ping is a useful tool for troubleshooting network problems and can be used to check the status of a network connection or the availability of a particular device or service. It can be harmful as hackers can also use ping requests as a reconnaissance tool to gather information about a target network or system. To block or unblock the ping requests on Linux Mint 21 there are two primary ways one is through kernel parameters and the other is by iptables, both are discussed in this guide.