• 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

ping not working on a Newly Built CentOS/RHEL server

by admin

Question: We can ssh into the Newly Built CentOS/RHEL 8 machine, but ping is not working, not even self ping. Firewalld and Selinux services are disabled. How to resolve the issue?

1. First, check for the contents of the dynamic file /proc/sys/ipv4/icmp_echo_ignore. If this value is set to 1, in other words on or true, the kernel chooses to totally ignore all ICMP echo requests. This variable takes a boolean value and is per default set to false, or off.

# cat /proc/sys/ipv4/icmp_echo_ignore
1

2. You can confirm the same from “netstat -s” and “sysctl -a” commands:

# netstat -s
...
Icmp:
  2371 ICMP messages received
  0 input ICMP message failed
  ICMP input histogram:
  echo requests: 2339
  timestamp request: 32
  40 ICMP messages sent
  0 ICMP messages failed
  ICMP output histogram:
  echo requests: 8
  timestamp replies: 32
IcmpMsg:
  InType8: 2339
  InType13: 32
  OutType8: 8
  OutType14: 32
# sysctl -a | grep icmp_echo_ignore_all
net.ipv4.icmp_echo_ignore_all = 1

3. Edit the following line in /etc/sysctl.conf as shown below:

# vi /etc/sysctl.conf
net.ipv4.icmp_echo_ignore_all = 0

or to make the changes temporarily use below command:

# echo "0" > /proc/sys/net/ipv4/icmp_echo_ignore_all

4. To make it persistent after reboot:

# sysctl -p

Then you can test the ping locally or from another machine:

$ ping 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.023 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.035 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.037 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.029 ms
64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.033 ms
64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.035 ms
64 bytes from 127.0.0.1: icmp_seq=8 ttl=64 time=0.030 ms
^C
--- 127.0.0.1 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7000ms
rtt min/avg/max/mdev = 0.023/0.032/0.037/0.006 ms

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

Some more articles you might also be interested in …

  1. How to change the Default Log Directory(/var/log) in Rsyslog for CentOS/RHEL 6,7
  2. abroot Command Examples in Linux
  3. foreman: command not found
  4. The System Continuously Displayed the Error Message from the “avahi-demon” in /var/log/messages
  5. a2ensite Command Examples in Linux
  6. hdparm Command Examples in Linux
  7. img2txt Command Examples in Linux
  8. CentOS / RHEL : DNS servers in /etc/resolv.conf change after a reboot/network service restart. How to make them permanent
  9. ddcutil Command Examples in Linux
  10. How to use shell expansions for generating shell tokens under Linux

You May Also Like

Primary Sidebar

Recent Posts

  • “aws workmail” Command Examples
  • aws-vault Command Examples (A vault for securely storing and accessing AWS credentials in development environments)
  • “aws sts” Command Examples
  • “aws sqs” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright