如何在 Windows 中找到我的 VPN 客户端 IP

7 windows ip-address command-line

当我跑步时ipconfig,我得到以下信息:

C:\Documents and Settings\grmsrh14>ipconfig

Windows IP Configuration

Ethernet adapter Wireless Network Connection:

        Media State . . . . . . . . . . . : Media disconnected

Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 112.25.2.222
        Subnet Mask . . . . . . . . . . . : 255.255.254.0
        Default Gateway . . . . . . . . . : 112.25.2.1
        DHCP Class ID . . . . . . . . . . : rise

Ethernet adapter Local Area Connection 2:

        Media State . . . . . . . . . . . : Media disconnected

PPP adapter my_lab:

        Connection-specific DNS Suffix  . :
        IP Address. . . . . . . . . . . . : 10.2.251.41
        Subnet Mask . . . . . . . . . . . : 255.255.255.255
        Default Gateway . . . . . . . . . :
Run Code Online (Sandbox Code Playgroud)

是否有仅打印 my_lab(VPN) IP 地址的命令,即10.2.251.41

hea*_*vyd 5

您可以使用以下netsh命令:

对于 Vista/7:

netsh interface ipv4 show addresses "PPP adapter my_lab"
Run Code Online (Sandbox Code Playgroud)

XP的其中之一:

netsh interface ip show config "PPP adapter my_lab"
Run Code Online (Sandbox Code Playgroud)

其中PPP 适配器 my_lab可以替换为任何一个适配器的名称。


flu*_*ndu 1

您知道 my_lab VPN 的 IP 范围吗?

如果你这样做,像这样的批处理文件就可以解决问题:

@echo off
FOR /F "tokens=2 delims=:" %%a in ('IPCONFIG ^|FIND "IP" ^|FIND "10.2"') do set _IP=%%a
set IP=%_IP:~1%
echo %IP%
Run Code Online (Sandbox Code Playgroud)

但是,正如 Heavyd 所建议的,如果您只知道 PPP 适配器的名称,最好使用 netsh 命令。

@echo off
FOR /F "tokens=1-6 delims=:. " %%a in ('netsh int ip show address "my_lab" ^|find "IP Address"') do set IP=%%c.%%d.%%e.%%f
echo %IP% 
Run Code Online (Sandbox Code Playgroud)

-更新