Estas são algumas das opções para que você possa visualizar o IP Público via Terminal no Windows, Linux ou MAC.
É um ótima alternativa para que você possa inserir em seus scripts ou fazer apenas consulta para descobrir qual o IP Público sem sair do Terminal.
set URL="http://myexternalip.com/raw" bitsadmin /transfer "meuip" "%URL%" "%TEMP%"\meuip.txt type "%TEMP%"\meuip.txt
curl ifconfig.me curl icanhazip.com curl ipecho.net/plain curl ipinfo.io/ip curl l2.io/ip curl l2.io/ip.json?var=meuip curl httpbin.org/ip curl ipv4.icanhazip.com curl ipv6.icanhazip.com curl ident.me curl v4.ident.me curl v6.ident.me curl checkip.amazonaws.com curl rkeene.org/whatismyip curl ipv4.rkeene.org/whatismyip curl ipv6.rkeene.org/whatismyip curl whatismyip.akamai.com curl tnx.nl/ip curl myip.dnsomatic.com curl ip.appspot.com curl ip.telize.com curl curlmyip.com curl api.ipify.org?format=json curl api6.ipify.org?format=json curl icanhazip.com curl icanhazptr.com curl icanhaztrace.com curl icanhaztraceroute.com curl -s checkip.dyndns.org | sed 's/.*IP Address: \([0-9\.]*\).*/\1/g' curl -4 icanhazip.com curl -6 icanhazip.com
dig +short myip.opendns.com @resolver1.opendns.com dig TXT +short o-o.myaddr.l.google.com @ns1.google.com dig TXT +short o-o.myaddr.l.google.com @ns1.google.com | awk -F'"' '{ print $2}'
exec 3<> /dev/tcp/icanhazip.com/80 && echo 'GET /' >&3 && read -u 3 && echo $REPLY && exec 3>&-
Crie o arquivo meuip.go com o conteúdo abaixo :
package main import ( "io"; "net/http"; "os" ) func main() { resp, err := http.Get("http://myexternalip.com/raw") if err != nil { os.Stderr.WriteString(err.Error()) os.Stderr.WriteString("\n") os.Exit(1) } defer resp.Body.Close() io.Copy(os.Stdout, resp.Body) }
Execute o meuip.go
go run meuip.go
host myip.opendns.com resolver1.opendns.com | grep "myip.opendns.com has" | awk '{print $4}'
Crie o arquivo meuip.pl com o conteúdo abaixo :
var http = require('http'); var url = 'http://myexternalip.com/raw'; http.get(url, function(r) { r.setEncoding('utf8'); r.on('data', console.log.bind(console)); });
Execute o meuip.js
node meuip.js
Crie o arquivo meuip2.pl com o conteúdo abaixo :
var request = require('request'); var url = 'http://myexternalip.com/raw'; request(url, function (err, resp, meuip) { console.log(meuip); });
Execute o meuip2.js
node meuip2.js
npm install --global public-ip-cli public-ip
nslookup myip.opendns.com resolver1.opendns.com
perl -e 'use LWP::Simple; $url = "http://myexternalip.com/raw"; print (get $url);'
Crie o arquivo meuip.pl com o conteúdo abaixo :
#!/usr/bin/perl use LWP::UserAgent; my $useragent = new LWP::UserAgent(); my $meuip = $useragent->get('https://l2.io/ip')->content; print 'Meu IP : '. $meuip;
Execute o meuip.pl
perl meuip.pl
php -r '$meuip = "http://myexternalip.com/raw"; echo file_get_contents($meuip);'
Invoke-RestMethod ipinfo.io/ip (Invoke-WebRequest -uri "http://ifconfig.me/ip").Content Invoke-RestMethod -Uri ('https://ipinfo.io/') (Invoke-WebRequest ifconfig.me/ip).Content.Trim() (((nslookup myip.opendns.com resolver1.opendns.com 2>null| select-string -pattern "Address:") -split ":")[3]).Trim() [System.Net.Dns]::GetHostAddresses("www.google.com")[0] | Select IPAddressToString -ExpandProperty IPAddressToString
$meuip = new-object System.Net.WebClient $url="http://myexternalip.com/raw" $meuip.DownloadString($url)
$meuip = Invoke-WebRequest -URI http://myip.dnsomatic.com/ $meuip.Content
import urllib url = 'http://myexternalip.com/raw' meuip = urllib.urlopen(url).read() print meuip
import requests url = 'http://myexternalip.com/raw' meuip = requests.get(url) ip = meuip.text ip
from requests import get meuip = get('https://l2.io/ip').text print 'Meu IP : ', meuip
Crie o arquivo meuip.rb com o conteúdo abaixo :
#!/usr/bin/ruby require 'net/http' require 'timeout' secs_to_wait = ARGV[0].to_f || 10 begin Timeout::timeout(secs_to_wait) do response = Net::HTTP.get URI.parse('http://checkip.dyndns.org') puts response.match( /(?:Address: )([\d\.]+)/ )[1] end rescue puts "Timeout: Unable to reach checkip.dyndns.org." end
Execute o meuip.rb
ruby meuip.rb
telnet ipecho.net 80 GET /plain HTTP/1.1 HOST: ipecho.net BROWSER: web-kit (enter) (enter)
meuip=$(curl -s https://l2.io/ip) echo "Meu IP : $meuip"
Dim wc as New System.Net.WebClient Dim meuip as String = wc.DownloadString("https://l2.io/ip") MessageBox.Show(meuip)
Crie o arquivo meuip.vbs com o conteúdo abaixo :
Option Explicit Dim http : Set http = CreateObject( "MSXML2.ServerXmlHttp" ) http.Open "GET", "http://icanhazip.com", False http.Send Wscript.Echo http.responseText Set http = Nothing
Execute o meuip.vbs
cscript meuip.vbs
wget -qO- icanhazip.com wget -qO- ipecho.net/plain ; echo wget -qO- ipecho.net/plain | xargs echo wget -qO- myexternalip.com/raw
Compartilhe comigo, envie um e-mail para : [email protected]