linuxÖÐhostsÎļþÃûÌùýʧÔõô½â¾ö
linuxÖÐhostsÎļþÃûÌùýʧµÄ½â¾öÒªÁìÊÇ£º1¡¢ÒÔÖÎÀíÔ±Éí·Ý·¿ªÖն˻òʹÓÃsudoÏÂÁ2¡¢·¿ªhostsÎļþ£¬ÏÂÁîΪ¡°sudo vi /etc/hosts¡±£»3¡¢¼ì²éºÍÐÞ¸´ÃûÌùýʧ£¬È·±£Ã¿¸öÌõÄ¿¶¼Õ¼ÓÃÒ»ÐУ¬²¢Óÿոñ»òÖƱí·ûÍÑÀë×ֶΣ»4¡¢ÉúÑÄÎļþ²¢Í˳ö±à¼Æ÷£»5¡¢²âÊÔÐÞ¸ÄÊÇ·ñÉúЧ¡£
±¾½Ì³Ì²Ù×÷ϵͳ£ºLinux5.18.14ϵͳ¡¢Dell G3µçÄÔ¡£
ÈôÊÇÔÚLinuxÖеÄhostsÎļþÖб£´æÃûÌùýʧ£¬¿ÉÒÔ½ÓÄÉÒÔÏ°취À´½â¾ö£º
1¡¢ÒÔÖÎÀíÔ±Éí·Ý·¿ªÖն˻òʹÓÃsudoÏÂÁҪÐÞ¸ÄhostsÎļþ£¬ÄãÐèÒª¾ßÓÐÖÎÀíԱȨÏÞ¡£
2¡¢·¿ªhostsÎļþ£ºhostsÎļþλÓÚ /etc/hosts Ŀ¼Ï¡£¿ÉÒÔʹÓÃÎı¾±à¼Æ÷£¨Èçvi¡¢nanoµÈ£©·¿ª¸ÃÎļþ¡£
sudovi/etc/hosts
µÇ¼ºó¸´ÖÆ
3¡¢¼ì²éºÍÐÞ¸´ÃûÌùýʧ£ºÔÚhostsÎļþÖУ¬Ã¿¸öÌõÄ¿Ó¦¸Ãƾ֤ÒÔÏÂÃûÌþÙÐÐÅÅÁУºIPµØµã Ö÷»úÃû [ÓÖÃû]¡£È·±£Ã¿¸öÌõÄ¿¶¼Õ¼ÓÃÒ»ÐУ¬²¢Óÿոñ»òÖƱí·ûÍÑÀë×ֶΡ£
ÀýÈ磬һ¸ö׼ȷµÄhostsÎļþʾÀý£º
127.0.0.1localhost 192.168.0.1example.comalias1
µÇ¼ºó¸´ÖÆ
¼ì²éÎļþÖеÄÿһÐУ¬È·±£ÃûÌÃ׼ȷÇÒûÓÐÌØÁíÍâ¿Õ¸ñ¡¢×¢ÊÍ»òÆäËûÌØÊâ×Ö·û¡£
4¡¢ÉúÑÄÎļþ²¢Í˳ö±à¼Æ÷£ºÔÚ±à¼Æ÷ÖÐÉúÑÄÐ޸ĺó£¬Æ¾Ö¤±à¼Æ÷µÄÖ¸ÄÏÉúÑÄÎļþ²¢Í˳ö¡£
5¡¢²âÊÔÐÞ¸ÄÊÇ·ñÉúЧ£ºÔÚÐÞ¸ÄÍêhostsÎļþºó£¬¿ÉÒÔʵÑéʹÓÃÒÑÐ޸ĵÄÖ÷»úÃû»òÓÖÃû»á¼ûÏìÓ¦µÄIPµØµã£¬ÒÔÈ·ÈÏÐÞ¸ÄÊÇ·ñÉúЧ¡£
Çë×¢ÖØ£¬ÔÚÐÞ¸ÄhostsÎļþ֮ǰ£¬×îºÃ±¸·ÝÔʼÎļþÒÔ·À·ºÆðÎÊÌâ¡£ÕâÑù¿ÉÒÔÈ·±£ÔÚÐèҪʱ¿ÉÒÔ»Ö¸´µ½ÏÈÇ°µÄÉèÖá£
ÒÔÉϾÍÊÇlinuxÖÐhostsÎļþÃûÌùýʧÔõô½â¾öµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡