Kaip rasti komandų eilutės kompiuterio geografinę vietą?

Turinys:

Kaip rasti komandų eilutės kompiuterio geografinę vietą?
Kaip rasti komandų eilutės kompiuterio geografinę vietą?

Video: Kaip rasti komandų eilutės kompiuterio geografinę vietą?

Video: Kaip rasti komandų eilutės kompiuterio geografinę vietą?
Video: TOP PLEX MEDIA SERVER SETTINGS - BEST STREAMING SOFTWARE 2022 - YouTube 2024, Gegužė
Anonim
Yra daugybė būdų, kaip sužinoti kompiuterio vietą iš jo IP adreso, bet kaip tai padaryti, jei nuspręsite naudoti komandinę eilutę, kad surastumėte informaciją? Šiandienos "SuperUser" Q & A įraše yra keletas naudingų patarimų, padėsiančių skaitytojui rasti norimą informaciją.
Yra daugybė būdų, kaip sužinoti kompiuterio vietą iš jo IP adreso, bet kaip tai padaryti, jei nuspręsite naudoti komandinę eilutę, kad surastumėte informaciją? Šiandienos "SuperUser" Q & A įraše yra keletas naudingų patarimų, padėsiančių skaitytojui rasti norimą informaciją.

Šiandieninė klausimų ir atsakymų sesija pateikiama su "SuperUser" - "Stack Exchange", bendruomenės valdoma Q & A grupių asociacija.

Screenshot mandagumo Paul Fenwick (Flickr).

Klausimas

"SuperUser" skaitytuvas AlikElzin-kilaka nori sužinoti, kaip rasti kompiuterio IP adresą, naudodamas komandinę eilutę:

How do I find a computer’s internet (IP address) location using the command line? Would I use curl or wget, for example?

Kaip manote kompiuterio IP adreso vietą naudodami komandinę eilutę?

Atsakymas

"SuperUser" autoriai AlikElzin-kilaka ir Ben N turi mums atsakymą. Pirmiausia, AlikElzin-kilaka:

There is a service (IPInfo) that can provide the results. You can invoke it using curl, for example:

curl ipinfo.io

Result:

A specific IP’s info can also be requested:
A specific IP’s info can also be requested:

curl ipinfo.io/216.58.194.46

Result:

Image
Image

Source: How to look up the geographic location of an IP address from the command line

Vykdant Beno atsakymą:

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.

Ar turite ką nors įtraukti į paaiškinimą? Garsas išjungtas komentaruose. Norite skaityti daugiau atsakymų iš kitų "Tech-savvy Stack Exchange" vartotojų? Patikrinkite visą diskusijų temą čia.

Rekomenduojamas: