How to get a computer's internet (IP address) location using command line?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
How to get a computer's internet (IP address) location using command line?
For example, using curl or wget?
internet ip geolocation
add a comment |
How to get a computer's internet (IP address) location using command line?
For example, using curl or wget?
internet ip geolocation
4
Could you specify what an "internet location" is?
– Carsten S
Apr 16 '16 at 14:27
The IP's address location. Adding to the questions...
– AlikElzin-kilaka
Apr 17 '16 at 6:48
add a comment |
How to get a computer's internet (IP address) location using command line?
For example, using curl or wget?
internet ip geolocation
How to get a computer's internet (IP address) location using command line?
For example, using curl or wget?
internet ip geolocation
internet ip geolocation
edited Apr 17 '16 at 6:52
AlikElzin-kilaka
asked Apr 14 '16 at 6:45
AlikElzin-kilakaAlikElzin-kilaka
81111026
81111026
4
Could you specify what an "internet location" is?
– Carsten S
Apr 16 '16 at 14:27
The IP's address location. Adding to the questions...
– AlikElzin-kilaka
Apr 17 '16 at 6:48
add a comment |
4
Could you specify what an "internet location" is?
– Carsten S
Apr 16 '16 at 14:27
The IP's address location. Adding to the questions...
– AlikElzin-kilaka
Apr 17 '16 at 6:48
4
4
Could you specify what an "internet location" is?
– Carsten S
Apr 16 '16 at 14:27
Could you specify what an "internet location" is?
– Carsten S
Apr 16 '16 at 14:27
The IP's address location. Adding to the questions...
– AlikElzin-kilaka
Apr 17 '16 at 6:48
The IP's address location. Adding to the questions...
– AlikElzin-kilaka
Apr 17 '16 at 6:48
add a comment |
3 Answers
3
active
oldest
votes
There's a service providing this: ipinfo.io.
You can invoke it using curl
. Example:
curl ipinfo.io
Result:
{
"ip": "...",
"hostname": "...",
"city": "...",
"region": "...",
"country": "...",
"loc": "...,...",
"org": "..."
}
A specific IP's info can also be requested: curl ipinfo.io/216.58.194.46
:
{
"ip": "216.58.194.46",
"hostname": "dfw25s12-in-f14.1e100.net",
"city": "Mountain View",
"region": "California",
"country": "US",
"loc": "37.4192,-122.0574",
"org": "AS15169 Google Inc.",
"postal": "94043"
}
Source: http://xmodulo.com/geographic-location-ip-address-command-line.html
3
Please note this service does not provide an accurate location. 50km wrong for me.
– DavidPostill♦
Apr 14 '16 at 8:20
1
I've no idea how it works. I'm currently on mobile internet. Google maps manages to locate me perfectly well.
– DavidPostill♦
Apr 14 '16 at 8:29
1
The curl command above just goes to a service without providing anything private. ipinfo.io has almost only the source IP to use to pin point the location and get data.
– AlikElzin-kilaka
Apr 14 '16 at 8:36
2
geoip is notoriously inaccurate... I can be either in Idaho, Minnesota or Oregon depending on the DHCP netblock of the day.
– Fiasco Labs
Apr 17 '16 at 3:51
2
@DavidPostill Google Maps uses GPS to position you on the map, it's pretty accurate. Geolocation by IP address usually gets region right.
– Alexey Ivanov
Apr 17 '16 at 10:42
|
show 4 more comments
Since the question doesn't specify an OS, this is how to get that same information with PowerShell's curl
(actually an alias of Invoke-WebRequest
):
(curl ipinfo.io).Content
That produces a JSON string. To get the object that JSON represents, use ConvertFrom-Json
:
curl ipinfo.io | ConvertFrom-Json
Since that's a PowerShell object, you can easily get specific fields from it. For example, this command gets just the external IP as a string:
(curl ipinfo.io | ConvertFrom-Json).ip
Note that the geographical information from this service isn't super accurate, but it did locate me within 20 miles or so. The ISP information seems to be reliable.
add a comment |
You can also use from PowerShell:
Invoke-RestMethod http://ipinfo.io/json
The command output will already give us the location in JSON
Extracted from: https://www.sysadmit.com/2019/01/windows-saber-ip-publica-PowerShell.html
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1065263%2fhow-to-get-a-computers-internet-ip-address-location-using-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
There's a service providing this: ipinfo.io.
You can invoke it using curl
. Example:
curl ipinfo.io
Result:
{
"ip": "...",
"hostname": "...",
"city": "...",
"region": "...",
"country": "...",
"loc": "...,...",
"org": "..."
}
A specific IP's info can also be requested: curl ipinfo.io/216.58.194.46
:
{
"ip": "216.58.194.46",
"hostname": "dfw25s12-in-f14.1e100.net",
"city": "Mountain View",
"region": "California",
"country": "US",
"loc": "37.4192,-122.0574",
"org": "AS15169 Google Inc.",
"postal": "94043"
}
Source: http://xmodulo.com/geographic-location-ip-address-command-line.html
3
Please note this service does not provide an accurate location. 50km wrong for me.
– DavidPostill♦
Apr 14 '16 at 8:20
1
I've no idea how it works. I'm currently on mobile internet. Google maps manages to locate me perfectly well.
– DavidPostill♦
Apr 14 '16 at 8:29
1
The curl command above just goes to a service without providing anything private. ipinfo.io has almost only the source IP to use to pin point the location and get data.
– AlikElzin-kilaka
Apr 14 '16 at 8:36
2
geoip is notoriously inaccurate... I can be either in Idaho, Minnesota or Oregon depending on the DHCP netblock of the day.
– Fiasco Labs
Apr 17 '16 at 3:51
2
@DavidPostill Google Maps uses GPS to position you on the map, it's pretty accurate. Geolocation by IP address usually gets region right.
– Alexey Ivanov
Apr 17 '16 at 10:42
|
show 4 more comments
There's a service providing this: ipinfo.io.
You can invoke it using curl
. Example:
curl ipinfo.io
Result:
{
"ip": "...",
"hostname": "...",
"city": "...",
"region": "...",
"country": "...",
"loc": "...,...",
"org": "..."
}
A specific IP's info can also be requested: curl ipinfo.io/216.58.194.46
:
{
"ip": "216.58.194.46",
"hostname": "dfw25s12-in-f14.1e100.net",
"city": "Mountain View",
"region": "California",
"country": "US",
"loc": "37.4192,-122.0574",
"org": "AS15169 Google Inc.",
"postal": "94043"
}
Source: http://xmodulo.com/geographic-location-ip-address-command-line.html
3
Please note this service does not provide an accurate location. 50km wrong for me.
– DavidPostill♦
Apr 14 '16 at 8:20
1
I've no idea how it works. I'm currently on mobile internet. Google maps manages to locate me perfectly well.
– DavidPostill♦
Apr 14 '16 at 8:29
1
The curl command above just goes to a service without providing anything private. ipinfo.io has almost only the source IP to use to pin point the location and get data.
– AlikElzin-kilaka
Apr 14 '16 at 8:36
2
geoip is notoriously inaccurate... I can be either in Idaho, Minnesota or Oregon depending on the DHCP netblock of the day.
– Fiasco Labs
Apr 17 '16 at 3:51
2
@DavidPostill Google Maps uses GPS to position you on the map, it's pretty accurate. Geolocation by IP address usually gets region right.
– Alexey Ivanov
Apr 17 '16 at 10:42
|
show 4 more comments
There's a service providing this: ipinfo.io.
You can invoke it using curl
. Example:
curl ipinfo.io
Result:
{
"ip": "...",
"hostname": "...",
"city": "...",
"region": "...",
"country": "...",
"loc": "...,...",
"org": "..."
}
A specific IP's info can also be requested: curl ipinfo.io/216.58.194.46
:
{
"ip": "216.58.194.46",
"hostname": "dfw25s12-in-f14.1e100.net",
"city": "Mountain View",
"region": "California",
"country": "US",
"loc": "37.4192,-122.0574",
"org": "AS15169 Google Inc.",
"postal": "94043"
}
Source: http://xmodulo.com/geographic-location-ip-address-command-line.html
There's a service providing this: ipinfo.io.
You can invoke it using curl
. Example:
curl ipinfo.io
Result:
{
"ip": "...",
"hostname": "...",
"city": "...",
"region": "...",
"country": "...",
"loc": "...,...",
"org": "..."
}
A specific IP's info can also be requested: curl ipinfo.io/216.58.194.46
:
{
"ip": "216.58.194.46",
"hostname": "dfw25s12-in-f14.1e100.net",
"city": "Mountain View",
"region": "California",
"country": "US",
"loc": "37.4192,-122.0574",
"org": "AS15169 Google Inc.",
"postal": "94043"
}
Source: http://xmodulo.com/geographic-location-ip-address-command-line.html
edited Apr 17 '16 at 2:41
Scott
16.2k113990
16.2k113990
answered Apr 14 '16 at 6:45
AlikElzin-kilakaAlikElzin-kilaka
81111026
81111026
3
Please note this service does not provide an accurate location. 50km wrong for me.
– DavidPostill♦
Apr 14 '16 at 8:20
1
I've no idea how it works. I'm currently on mobile internet. Google maps manages to locate me perfectly well.
– DavidPostill♦
Apr 14 '16 at 8:29
1
The curl command above just goes to a service without providing anything private. ipinfo.io has almost only the source IP to use to pin point the location and get data.
– AlikElzin-kilaka
Apr 14 '16 at 8:36
2
geoip is notoriously inaccurate... I can be either in Idaho, Minnesota or Oregon depending on the DHCP netblock of the day.
– Fiasco Labs
Apr 17 '16 at 3:51
2
@DavidPostill Google Maps uses GPS to position you on the map, it's pretty accurate. Geolocation by IP address usually gets region right.
– Alexey Ivanov
Apr 17 '16 at 10:42
|
show 4 more comments
3
Please note this service does not provide an accurate location. 50km wrong for me.
– DavidPostill♦
Apr 14 '16 at 8:20
1
I've no idea how it works. I'm currently on mobile internet. Google maps manages to locate me perfectly well.
– DavidPostill♦
Apr 14 '16 at 8:29
1
The curl command above just goes to a service without providing anything private. ipinfo.io has almost only the source IP to use to pin point the location and get data.
– AlikElzin-kilaka
Apr 14 '16 at 8:36
2
geoip is notoriously inaccurate... I can be either in Idaho, Minnesota or Oregon depending on the DHCP netblock of the day.
– Fiasco Labs
Apr 17 '16 at 3:51
2
@DavidPostill Google Maps uses GPS to position you on the map, it's pretty accurate. Geolocation by IP address usually gets region right.
– Alexey Ivanov
Apr 17 '16 at 10:42
3
3
Please note this service does not provide an accurate location. 50km wrong for me.
– DavidPostill♦
Apr 14 '16 at 8:20
Please note this service does not provide an accurate location. 50km wrong for me.
– DavidPostill♦
Apr 14 '16 at 8:20
1
1
I've no idea how it works. I'm currently on mobile internet. Google maps manages to locate me perfectly well.
– DavidPostill♦
Apr 14 '16 at 8:29
I've no idea how it works. I'm currently on mobile internet. Google maps manages to locate me perfectly well.
– DavidPostill♦
Apr 14 '16 at 8:29
1
1
The curl command above just goes to a service without providing anything private. ipinfo.io has almost only the source IP to use to pin point the location and get data.
– AlikElzin-kilaka
Apr 14 '16 at 8:36
The curl command above just goes to a service without providing anything private. ipinfo.io has almost only the source IP to use to pin point the location and get data.
– AlikElzin-kilaka
Apr 14 '16 at 8:36
2
2
geoip is notoriously inaccurate... I can be either in Idaho, Minnesota or Oregon depending on the DHCP netblock of the day.
– Fiasco Labs
Apr 17 '16 at 3:51
geoip is notoriously inaccurate... I can be either in Idaho, Minnesota or Oregon depending on the DHCP netblock of the day.
– Fiasco Labs
Apr 17 '16 at 3:51
2
2
@DavidPostill Google Maps uses GPS to position you on the map, it's pretty accurate. Geolocation by IP address usually gets region right.
– Alexey Ivanov
Apr 17 '16 at 10:42
@DavidPostill Google Maps uses GPS to position you on the map, it's pretty accurate. Geolocation by IP address usually gets region right.
– Alexey Ivanov
Apr 17 '16 at 10:42
|
show 4 more comments
Since the question doesn't specify an OS, this is how to get that same information with PowerShell's curl
(actually an alias of Invoke-WebRequest
):
(curl ipinfo.io).Content
That produces a JSON string. To get the object that JSON represents, use ConvertFrom-Json
:
curl ipinfo.io | ConvertFrom-Json
Since that's a PowerShell object, you can easily get specific fields from it. For example, this command gets just the external IP as a string:
(curl ipinfo.io | ConvertFrom-Json).ip
Note that the geographical information from this service isn't super accurate, but it did locate me within 20 miles or so. The ISP information seems to be reliable.
add a comment |
Since the question doesn't specify an OS, this is how to get that same information with PowerShell's curl
(actually an alias of Invoke-WebRequest
):
(curl ipinfo.io).Content
That produces a JSON string. To get the object that JSON represents, use ConvertFrom-Json
:
curl ipinfo.io | ConvertFrom-Json
Since that's a PowerShell object, you can easily get specific fields from it. For example, this command gets just the external IP as a string:
(curl ipinfo.io | ConvertFrom-Json).ip
Note that the geographical information from this service isn't super accurate, but it did locate me within 20 miles or so. The ISP information seems to be reliable.
add a comment |
Since the question doesn't specify an OS, this is how to get that same information with PowerShell's curl
(actually an alias of Invoke-WebRequest
):
(curl ipinfo.io).Content
That produces a JSON string. To get the object that JSON represents, use ConvertFrom-Json
:
curl ipinfo.io | ConvertFrom-Json
Since that's a PowerShell object, you can easily get specific fields from it. For example, this command gets just the external IP as a string:
(curl ipinfo.io | ConvertFrom-Json).ip
Note that the geographical information from this service isn't super accurate, but it did locate me within 20 miles or so. The ISP information seems to be reliable.
Since the question doesn't specify an OS, this is how to get that same information with PowerShell's curl
(actually an alias of Invoke-WebRequest
):
(curl ipinfo.io).Content
That produces a JSON string. To get the object that JSON represents, use ConvertFrom-Json
:
curl ipinfo.io | ConvertFrom-Json
Since that's a PowerShell object, you can easily get specific fields from it. For example, this command gets just the external IP as a string:
(curl ipinfo.io | ConvertFrom-Json).ip
Note that the geographical information from this service isn't super accurate, but it did locate me within 20 miles or so. The ISP information seems to be reliable.
answered Apr 17 '16 at 2:55
Ben NBen N
30k1399146
30k1399146
add a comment |
add a comment |
You can also use from PowerShell:
Invoke-RestMethod http://ipinfo.io/json
The command output will already give us the location in JSON
Extracted from: https://www.sysadmit.com/2019/01/windows-saber-ip-publica-PowerShell.html
add a comment |
You can also use from PowerShell:
Invoke-RestMethod http://ipinfo.io/json
The command output will already give us the location in JSON
Extracted from: https://www.sysadmit.com/2019/01/windows-saber-ip-publica-PowerShell.html
add a comment |
You can also use from PowerShell:
Invoke-RestMethod http://ipinfo.io/json
The command output will already give us the location in JSON
Extracted from: https://www.sysadmit.com/2019/01/windows-saber-ip-publica-PowerShell.html
You can also use from PowerShell:
Invoke-RestMethod http://ipinfo.io/json
The command output will already give us the location in JSON
Extracted from: https://www.sysadmit.com/2019/01/windows-saber-ip-publica-PowerShell.html
answered Jan 27 at 10:39
Peter McAllisterPeter McAllister
1
1
add a comment |
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1065263%2fhow-to-get-a-computers-internet-ip-address-location-using-command-line%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
4
Could you specify what an "internet location" is?
– Carsten S
Apr 16 '16 at 14:27
The IP's address location. Adding to the questions...
– AlikElzin-kilaka
Apr 17 '16 at 6:48