New FAMILUG

The PyMiers

Sunday 2 March 2014

Lấy External IP


Để lấy public IP của máy mình hiện tại, dùng lệnh:

$ dig +short myip.opendns.com @resolver1.opendns.com
113.190.182.179

Ngoài ra còn vài cách khác, có thể kể đến

$ curl icanhazip.com
113.190.182.179

source: https://coderwall.com/p/lyrjsq?utm_campaign=weekly_digest&utm_content=Privately+receive+personally+curated&utm_medium=email

Hết!

3 comments:

  1. Gán alias
    myip="curl icanhazip.com"
    myip="dig +short myip.opendns.com @resolver1.opendns.com"

    cho gọn

    ReplyDelete
  2. dùng ip của OpenDNS cho kết quả nhanh hơn vì không cần resolve domain của opendns

    hvn@lappy: ~ () $ time dig +short myip.opendns.com @208.67.222.222
    113.190.182.179

    real 0m0.088s
    user 0m0.004s
    sys 0m0.008s
    hvn@lappy: ~ () $ time dig +short myip.opendns.com @resolver1.opendns.com
    113.190.182.179

    real 0m0.366s
    user 0m0.008s
    sys 0m0.004s

    ReplyDelete
    Replies
    1. đầu óc dạo này già nua rồi, đành dùng loại ngắn:
      $dig myip.opendns.com @208.67.222.222

      được cái là đã thuộc IP của opendns :D

      Delete