0

I want to record my server how many times was ping using php.

if someone is trying to ping my server i want to store it for record.

is there any way to record using PHP script

ping example.com/index.php

using php script index.php i want to record how many times i was ping

Nitin Shinde
  • 136
  • 9
  • 1
    You can't ping a URL, just a machine. – Barmar Dec 22 '21 at 06:34
  • Hello Nitin Shinde, Umm could please provide more information on your request? The script can vary in many points where the machine, the ports and even the installation of the software or OS on it matters. – Periklis Kakarakidis Dec 22 '21 at 06:34
  • is there any way to record how many times my machine was ping – Nitin Shinde Dec 22 '21 at 06:35
  • Read the answers below – ADyson Dec 22 '21 at 07:03
  • A ping request is not a HTTP request. The request data will not be received by your webserver or by php – ADyson Dec 22 '21 at 07:15
  • 1
    https://stackoverflow.com/questions/29496575/what-handles-ping-in-linux might be useful if using Linux but it will take a lot of barebones protocol complying implementations to get the handler to correctly respond to pings as well as invoke a custom script. – apokryfos Dec 22 '21 at 08:04

2 Answers2

3

There is not any available user ability responsible for responding to pings. Pings sends ICMP echo packets and will received and process by the kernel's networking stack.

behzad m salehi
  • 1,038
  • 9
  • 23
2

In short, you cant. I suggest you read more about what ping is (https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol) and then why you can't intercept ping handling without network stack changes What network layer handles responding to pings?

Anton
  • 728
  • 3
  • 8