【问题标题】:How to get the ip address of a particular adapter in windows xp through command如何通过命令获取windows xp中特定适配器的ip地址
【发布时间】:2010-12-14 14:09:50
【问题描述】:

我的系统中有多个适配器,我想知道特定适配器的 IP。是否可以通过 Windows 中的命令,在 Linux 中很容易?还是其他方式?

【问题讨论】:

  • 调用ipconfig 看起来不像编程(至少对我来说)。

标签: networking


【解决方案1】:

以下将让您指定一个适配器(ipconfig 似乎没有这样做):

netsh interface ip show config name="Local Area Connection"

您可以将| findstr "IP Address" 添加到该命令的末尾以仅显示 IP 地址行。

【讨论】:

  • 嘿Trevor,我尝试使用“netsh interface ip show address”,它给了我系统的实际当前IP,但是当我尝试“netsh interface ip show address name="Local Area Connection"”时给了我一些我过去使用的不同的IP。任何人都可以建议我必须提供什么名称才能获得 PPP 适配器的 IP。
  • 但是它只有在设置为静态时才会显示 IP 地址,它不会显示 dhcp 分配的 IP。
  • 而如果你想找出一个名字,你可以使用netsh interface show interface
【解决方案2】:

以下是我如何获取特定网络适配器的 IP 地址:

for /f "tokens=3 delims=: " %i  in ('netsh interface ip show config name^="Ethernet" ^| findstr "IP Address"') do echo Your IP Address is: %i

有关其工作原理的说明,请在此处查看我的相关答案:https://stackoverflow.com/a/59004409/2684661

【讨论】:

    【解决方案3】:

    ipconfig /all 应该可以解决问题。

    【讨论】:

    • 这不能回答问题。 OP 想要获得一个特定的适配器,这只会列出所有的适配器。
    猜你喜欢
    • 2012-04-09
    • 1970-01-01
    • 2018-04-26
    • 2014-01-10
    • 2023-04-08
    • 1970-01-01
    • 2015-12-19
    • 2017-02-11
    • 2020-06-10
    相关资源
    最近更新 更多