windows xp中如何通过命令获取特定适配器的ip地址

发布于 2024-10-08 04:58:13 字数 73 浏览 1 评论 0原文

我的系统中有多个适配器,我想知道特定适配器的 IP。在Windows中可以通过命令实现吗,在Linux中很容易吗?或者有其他办法吗?

I have more than one adapter in my system and I want to know the IP of particular adapter. Is it possible through a command in Windows, in Linux it's easy? Or any other way?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

未蓝澄海的烟 2024-10-15 04:58:13

以下命令将让您指定一个适配器(ipconfig 似乎不会执行此操作):

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

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

The following will let you specify an adapter (something ipconfig doesn't appear to do):

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

You can add | findstr "IP Address" to the end of that command to only show the IP address line.

农村范ル 2024-10-15 04:58:13

以下是我如何获取特定网络适配器的 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

Here's how I was able to get my IP Address for a specific network adapter:

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

For an explanation of how this works, see my related answer here: https://stackoverflow.com/a/59004409/2684661

死开点丶别碍眼 2024-10-15 04:58:13

使用 Powershell

Get-NetIpInterface
ifIndex InterfaceAlias                  AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp     ConnectionState PolicyStore
------- --------------                  ------------- ------------ --------------- ----     --------------- -----------
56      vEthernet (WSL)                 IPv6                  1500              15 Enabled  Connected       ActiveStore
17      vEthernet (Default Switch)      IPv6                  1500              15 Enabled  Connected       ActiveStore
7       Local Area Connection* 2        IPv6                  1500              25 Enabled  Disconnected    ActiveStore
21      Ethernet 2                      IPv6                  1348              25 Enabled  Connected       ActiveStore
26      Local Area Connection* 1        IPv6                  1500              25 Disabled Disconnected    ActiveStore
25      Ethernet                        IPv6                  1500               5 Enabled  Disconnected    ActiveStore
12      Wi-Fi                           IPv6                  1500              35 Enabled  Connected       ActiveStore
1       Loopback Pseudo-Interface 1     IPv6            4294967295              75 Disabled Connected       ActiveStore
56      vEthernet (WSL)                 IPv4                  1500              15 Disabled Connected       ActiveStore
17      vEthernet (Default Switch)      IPv4                  1500              15 Disabled Connected       ActiveStore
7       Local Area Connection* 2        IPv4                  1500              25 Enabled  Disconnected    ActiveStore
21      Ethernet 2                      IPv4                  1348               1 Disabled Connected       ActiveStore
26      Local Area Connection* 1        IPv4                  1500              25 Enabled  Disconnected    ActiveStore
25      Ethernet                        IPv4                  1500               5 Enabled  Disconnected    ActiveStore
12      Wi-Fi                           IPv4                  1500              35 Enabled  Connected       ActiveStore
1       Loopback Pseudo-Interface 1     IPv4            4294967295              75 Disabled Connected       ActiveStore

识别您的接口并记下 ifIndex,然后运行

Get-NetIpAddress -AddressFamily IPv4 -InterfaceIndex  21|findstr IPAddress
IPAddress         : 172.55.23.43

​​获取 IPv4 地址。

With Powershell

Get-NetIpInterface
ifIndex InterfaceAlias                  AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp     ConnectionState PolicyStore
------- --------------                  ------------- ------------ --------------- ----     --------------- -----------
56      vEthernet (WSL)                 IPv6                  1500              15 Enabled  Connected       ActiveStore
17      vEthernet (Default Switch)      IPv6                  1500              15 Enabled  Connected       ActiveStore
7       Local Area Connection* 2        IPv6                  1500              25 Enabled  Disconnected    ActiveStore
21      Ethernet 2                      IPv6                  1348              25 Enabled  Connected       ActiveStore
26      Local Area Connection* 1        IPv6                  1500              25 Disabled Disconnected    ActiveStore
25      Ethernet                        IPv6                  1500               5 Enabled  Disconnected    ActiveStore
12      Wi-Fi                           IPv6                  1500              35 Enabled  Connected       ActiveStore
1       Loopback Pseudo-Interface 1     IPv6            4294967295              75 Disabled Connected       ActiveStore
56      vEthernet (WSL)                 IPv4                  1500              15 Disabled Connected       ActiveStore
17      vEthernet (Default Switch)      IPv4                  1500              15 Disabled Connected       ActiveStore
7       Local Area Connection* 2        IPv4                  1500              25 Enabled  Disconnected    ActiveStore
21      Ethernet 2                      IPv4                  1348               1 Disabled Connected       ActiveStore
26      Local Area Connection* 1        IPv4                  1500              25 Enabled  Disconnected    ActiveStore
25      Ethernet                        IPv4                  1500               5 Enabled  Disconnected    ActiveStore
12      Wi-Fi                           IPv4                  1500              35 Enabled  Connected       ActiveStore
1       Loopback Pseudo-Interface 1     IPv4            4294967295              75 Disabled Connected       ActiveStore

Identify your interface and note the ifIndex and then run

Get-NetIpAddress -AddressFamily IPv4 -InterfaceIndex  21|findstr IPAddress
IPAddress         : 172.55.23.43

To get the IPv4 address.

伴梦长久 2024-10-15 04:58:13

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

ipconfig /all should do the trick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文