Difference between ping and curl

What is the internal working difference between ping and curl commands in Linux? There are times when curl to some url works and ping doesn't and vice versa.

3 answers

  • answered 2018-11-08 07:47 Laurynas Lubys

    curl tries to establish a TCP connection and send an HTTP request over that, while ping uses the ICMP protocol which is different and used for diagnostics of the internets. These two protocols are somewhat independent and a host may choose which ones to support and answer to.

  • answered 2018-11-08 08:50 Dileep Jayasundara

    curl command use to transfer data mostly from a server or to a server using set of protocols listed as DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP.

    ping command use ICMP protocol.Use mostly for make sure that a communication between two nodes can be established without any interrupt. ping command commonly in use as a diagnose tool by network admins.

  • answered 2018-11-08 18:43 xpt

    As others have explained, curl and ping use different protocols.

    • curl is mostly used to retrieve http data. When curl is not working, it basically means the server is not providing HTTP(S) services.
    • ping uses ICMP protocol. When ping is not working, it mostly means that the ICMP port has been blocked, along the route, or at the server side.

    Of course, this is just a rough coverage of the most often cases, and there are surely more to them.