Tuc*_*uco 3 windows ip shell ip-address command-prompt
在不使用任何第三方软件或依赖PowerShell的情况下通过命令提示符执行此操作的任何方法?
一个简单的命令就像在我用的Linux/Mac上一样curl http://ipinfo.io/ip.
谢谢!
在powershell中使用Invoke-WebRequest模块.例如:
Invoke-WebRequest ifconfig.me/ip
Run Code Online (Sandbox Code Playgroud)
编辑:我误解了这个问题,并认为你需要使用Powrshell.
cmd.exe中没有内置命令可返回公共IP地址.但你可以使用nslookup解决它,就像这样;
nslookup myip.opendns.com. resolver1.opendns.com
Run Code Online (Sandbox Code Playgroud)
OP的另一个选择:
telnet curlmyip.com 80
Run Code Online (Sandbox Code Playgroud)
连接后键入"GET".
注意:Windows上默认不安装/启用telnet.
您可以在 Windows 和 Linux 中使用这些命令
curl ifconfig.me
Curl是升级到最新版本时Windows内置的东西,所以它不被称为第三方软件。
或者
curl ifconfig.co
在 Linux 中,几乎发行版已经有了这个命令。
非常感谢ArthurG您的命令。它工作完美,可以通过多种方式用于批处理脚本。