9

When I run ipconfig and I get the following:

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 . . . . . . . . . :

Is there a command that prints only the my_lab(VPN) IP address, ie 10.2.251.41?

0

3 Answers 3

5

You can use the netsh command:

For Vista/7:

netsh interface ipv4 show addresses "PPP adapter my_lab"

And one of these for XP:

netsh interface ip show config "PPP adapter my_lab"

Where PPP adapter my_lab can be replaced by the name of any one of your adapters.

4
  • On XP, wouldn't it be netsh interface ip show address "PPP adapter my_lab"?
    – Snark
    Feb 25, 2010 at 17:09
  • Yes, updated accordingly
    – heavyd
    Feb 25, 2010 at 17:10
  • These commands give good information, but not "only the my_lab(VPN) IP address, ie 10.2.251.41"
    – Snark
    Feb 25, 2010 at 17:36
  • And simply netsh interface ip show config (with no name) will give all configs.
    – Jellicle
    Sep 8, 2021 at 21:10
1

Do you know the ip range of the my_lab VPN?

If you do, a batch file like this will do the trick:

@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%

But, as it was suggested by heavyd, if you know only the name of the PPP adapter it's better to use the netsh command.

@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% 

-Updated

2
  • thanks for your reply. Unfortunatelly, no. I don't know the range.
    – cateof
    Feb 25, 2010 at 11:44
  • +1 for the first script. My VPN does not even show up in the listing when I run 'netsh int ip show address', so the second script does not work for me (using Windows XP). I think I know the range though so this solves my problem.
    – Ergwun
    Jun 25, 2011 at 2:11
0

Run: ipconfig /all will show the VPN addresses.

You must log in to answer this question.