linuxÔõôÉó²éurlÊÇ·ñ׼ȷ
curl¡¢wget¡¢host ºÍ ping ÏÂÁî¿ÉÓÃÓÚ¼ì²é url ÓÐÓÃÐÔ£ºcurl£º·¢ËÍ http ÇëÇóÒÔ»ñÈ¡ÏìÓ¦´úÂ룬ÓÐÓà url ·µ»Ø 200£»wget£ºÊµÑéÏÂÔØ url£¬ÀÖ³ÉÔò url ÓÐÓã»host£ºÆÊÎöÓòÃûÒÔ»ñÈ¡ ip£¬ÀÖ³ÉÔò url ÓÐÓã»ping£ºping ip µØµãÒÔ¼ì²éÅþÁ¬ÐÔ£¬ÀÖ³ÉÔò url ¿ÉÄÜÓÐÓá£
ÔõÑùʹÓà Linux ÏÂÁî¼ì²é URL µÄÓÐÓÃÐÔ
curl
curl ÏÂÁî¿ÉÒÔÓÃÀ´¼ì²é URL µÄÓÐÓÃÐÔ¡£Ëü»á·¢ËÍÒ»¸ö HTTP ÇëÇóµ½Ö¸¶¨µÄ URL£¬²¢·µ»ØÒ»¸öÏìÓ¦´úÂë¡£ÏìÓ¦´úÂë¿ÉÒÔÓÃÀ´ÅÐ¶Ï URL ÊÇ·ñÓÐÓá£
curl -I https://www.example.com
µÇ¼ºó¸´ÖÆ
ÈôÊÇ URL ÓÐÓã¬curl ÏÂÁî»á·µ»Ø 200£¨Àֳɣ©ÏìÓ¦´úÂë¡£ÈôÊÇ URL ÎÞЧ£¬Ëü»á·µ»ØÒ»¸ö·Ç 200 µÄÏìÓ¦´úÂ룬ÀýÈç 404£¨Î´ÕÒµ½£©¡£
wget
wget ÏÂÁîÒ²¿ÉÒÔÓÃÀ´¼ì²é URL µÄÓÐÓÃÐÔ¡£Ëü»áÏÂÔØÖ¸¶¨µÄ URL£¬²¢¼ì²éÏÂÔØÊÇ·ñÀֳɡ£
wget https://www.example.com
µÇ¼ºó¸´ÖÆ
ÈôÊÇ URL ÓÐÓã¬wget ÏÂÁî»áÀÖ³ÉÏÂÔØÎļþ¡£ÈôÊÇ URL ÎÞЧ£¬Ëü»á·µ»ØÒ»¸ö¹ýʧÐÂÎÅ¡£
host
host ÏÂÁî¿ÉÒÔÓÃÀ´¼ì²é DNS ¼Í¼£¬´Ó¶ø¼ä½ÓµØ¼ì²é URL µÄÓÐÓÃÐÔ¡£Ëü»áÆÊÎöÖ¸¶¨µÄÓòÃû£¬²¢·µ»Ø IP µØµã¡£
host www.example.com
µÇ¼ºó¸´ÖÆ
ÈôÊÇÓòÃûÆÊÎöÀֳɣ¬ÌåÏָà URL ÓÐÓá£ÈôÊÇÓòÃûÆÊÎöʧ°Ü£¬ÌåÏָà URL ÎÞЧ¡£
ping
ping ÏÂÁî¿ÉÒÔÓÃÀ´¼ì²éÓëÖ¸¶¨ IP µØµãµÄÅþÁ¬ÐÔ¡£ÕâÒ²¿ÉÒÔÓÃÀ´¼ä½ÓµØ¼ì²é URL µÄÓÐÓÃÐÔ¡£
ping www.example.com
µÇ¼ºó¸´ÖÆ
ÈôÊÇ ping ÏÂÁîÀֳɣ¬ÌåÏָà URL ÓÐÓá£ÈôÊÇ ping ÏÂÁîʧ°Ü£¬ÌåÏָà URL ¿ÉÄÜÎÞЧ¡£
ÒÔÉϾÍÊÇlinuxÔõôÉó²éurlÊÇ·ñ׼ȷµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡