Phiên Hỏi & Đáp hôm nay đến với chúng tôi theo lịch sự của SuperUser - một phân khu của Stack Exchange, một nhóm các trang web Hỏi & Đáp do cộng đồng điều hành.
Ảnh chụp màn hình lịch sự của Paul Fenwick (Flickr).
Câu hỏi
Người đọc siêu người dùng AlikElzin-kilaka muốn biết cách tìm vị trí địa chỉ IP của máy tính bằng dòng lệnh:
How do I find a computer’s internet (IP address) location using the command line? Would I use curl or wget, for example?
Làm cách nào để tìm vị trí địa chỉ IP của máy tính bằng dòng lệnh?
Câu trả lời
Những người đóng góp của SuperUser AlikElzin-kilaka và Ben N có câu trả lời cho chúng tôi. Đầu tiên, AlikElzin-kilaka:
There is a service (IPInfo) that can provide the results. You can invoke it using curl, for example:
curl ipinfo.io
Result:
curl ipinfo.io/216.58.194.46
Result:
Source: How to look up the geographic location of an IP address from the command line
Tiếp theo là câu trả lời từ Ben N:
Since the question does not specify an operating system, this is how to get that same information with PowerShell’s curl (actually an alias of Invoke-WebRequest):
(curl ipinfo.io).Content
Which produces a JSON string. To get the object that the JSON represents, use ConvertFrom-Json:
curl ipinfo.io | ConvertFrom-Json
Since that is a PowerShell object, you can easily get specific fields from it. For example, this command gets just the external IP address as a string:
(curl ipinfo.io | ConvertFrom-Json).ip
Note that the geographical information from this service is not super accurate, but it did locate me within 20 miles or so of my actual location and the ISP information seems to be reliable.
Có cái gì để thêm vào lời giải thích? Tắt âm thanh trong các ý kiến. Bạn muốn đọc thêm câu trả lời từ những người dùng Stack Exchange có hiểu biết công nghệ khác? Xem toàn bộ chuỗi thảo luận tại đây.