Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

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.

share|improve this answer
    
On XP, wouldn't it be netsh interface ip show address "PPP adapter my_lab"? –  Snark Feb 25 '10 at 17:09
    
Yes, updated accordingly –  heavyd Feb 25 '10 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 '10 at 17:36

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

share|improve this answer
    
thanks for your reply. Unfortunatelly, no. I don't know the range. –  cateof Feb 25 '10 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 '11 at 2:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.