linuxÔõô¶ÁÈ¡¹«Íø
ÔõÑù¶ÁÈ¡ linux µÄ¹«Íø ip µØµã£¿Äú¿ÉÒÔʹÓÃÒÔÏÂÒªÁì»ñÈ¡ linux ÅÌËã»úµÄ¹«Íø ip µØµã£ºÊ¹Óà curl ÏÂÁ curl ifconfig.meʹÓà wget ÏÂÁ wget -qo- https://ifconfig.meʹÓà dig ÏÂÁ dig +short myip.opendns.com @resolver1.opendns.comʹÓà ipify ÏÂÁ ipifyÒª½«¹«Íø ip µØµãÉúÑÄÔÚ±äÁ¿ÖУ¬¿ÉÒÔʹÓà public_ip=$(curl ifconfig.me
ÔÚ Linux ÖжÁÈ¡¹«Íø IP µØµã
Òª»ñÈ¡ Linux ÅÌËã»úµÄ¹«Íø IP µØµã£¬¿ÉÒÔʹÓÃÒÔÏÂÒªÁ죺
ʹÓà curl ÏÂÁ
curl ifconfig.me
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
ʹÓà wget ÏÂÁ
wget -qO- https://ifconfig.me
µÇ¼ºó¸´ÖÆ
ʹÓà dig ÏÂÁ
dig +short myip.opendns.com @resolver1.opendns.com
µÇ¼ºó¸´ÖÆ
ʹÓà ipify ÏÂÁ
ipify
µÇ¼ºó¸´ÖÆ
½«Ð§¹ûÉúÑÄÔÚ±äÁ¿ÖУº
Òª½«»ñÈ¡µÄ¹«Íø IP µØµãÉúÑÄÔÚ±äÁ¿ÖУ¬¿ÉÒÔʹÓÃÒÔÏÂÓï·¨£º
public_ip=$(curl ifconfig.me)
µÇ¼ºó¸´ÖÆ
ʾÀý£º
»ñÈ¡¹«Íø IP µØµã²¢½«Æä´òÓ¡µ½Öնˣº
curl ifconfig.me
µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ
»ñÈ¡¹«Íø IP µØµã²¢½«ÆäÉúÑÄÔÚ±äÁ¿ÖУº
public_ip=$(curl ifconfig.me) echo $public_ip
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇlinuxÔõô¶ÁÈ¡¹«ÍøµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡