找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 31426|回复: 4

[网络连接] 批处理如何获取VPN的域名(IP)?

[复制链接]
发表于 2011-3-11 11:56:29 | 显示全部楼层 |阅读模式
网络连接里有2个连接:
1个是本地连接,
另1个是虚拟专用网络连接,也就是VPN
请问,如何获取到VPN的域名:118.108.168.26
发表于 2011-3-11 12:06:34 | 显示全部楼层
本机没有vpn,所以请楼主将你的ipconfig /all的结果贴出来
 楼主| 发表于 2011-3-11 12:52:45 | 显示全部楼层
没连VPN之前:


Windows IP Configuration



        Host Name . . . . . . . . . . . . : ACE

        Primary Dns Suffix  . . . . . . . :

        Node Type . . . . . . . . . . . . : Mixed

        IP Routing Enabled. . . . . . . . : No

        WINS Proxy Enabled. . . . . . . . : No



Ethernet adapter 本地连接:



        Connection-specific DNS Suffix  . :

        Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller

        Physical Address. . . . . . . . . : 00-30-67-17-33-A8

        Dhcp Enabled. . . . . . . . . . . : No

        IP Address. . . . . . . . . . . . : 192.168.199.199

        Subnet Mask . . . . . . . . . . . : 255.255.255.0

        Default Gateway . . . . . . . . . : 192.168.1.1

        DNS Servers . . . . . . . . . . . : 202.101.224.68

                                            202.101.224.69

----------------------------------------------------------------------------------------------------------------
连上了VPN之后:



Windows IP Configuration



        Host Name . . . . . . . . . . . . : ACE

        Primary Dns Suffix  . . . . . . . :

        Node Type . . . . . . . . . . . . : Mixed

        IP Routing Enabled. . . . . . . . : No

        WINS Proxy Enabled. . . . . . . . : No



Ethernet adapter 本地连接:



        Connection-specific DNS Suffix  . :

        Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller

        Physical Address. . . . . . . . . : 00-30-67-17-33-A8

        Dhcp Enabled. . . . . . . . . . . : No

        IP Address. . . . . . . . . . . . : 192.168.199.199

        Subnet Mask . . . . . . . . . . . : 255.255.255.0

        Default Gateway . . . . . . . . . : 192.168.1.1

        DNS Servers . . . . . . . . . . . : 202.101.224.68

                                            202.101.224.69



PPP adapter 虚拟专用网络连接:



        Connection-specific DNS Suffix  . :

        Description . . . . . . . . . . . : WAN (PPP/SLIP) Interface

        Physical Address. . . . . . . . . : 00-57-58-00-00-00

        Dhcp Enabled. . . . . . . . . . . : No

        IP Address. . . . . . . . . . . . : 169.254.18.24

        Subnet Mask . . . . . . . . . . . : 255.255.255.255

        Default Gateway . . . . . . . . . : 169.254.18.24

        DNS Servers . . . . . . . . . . . : 213.141.138.33

                                            213.141.138.34

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ipconfig/all里看不出VPN的域名
发表于 2011-3-12 17:49:41 | 显示全部楼层

回复 3楼 的帖子

这样行不?
  1. @echo off
  2. rem rasphone.pbk不是ANSI格式

  3. set "filename=%allusersprofile%\application data\microsoft\network\connections\pbk\rasphone.pbk"

  4. for /f "tokens=1 delims=:" %%a in ('type "%filename%" ^| findstr /I /N "type=2"') do set /a num=%%a+77

  5. for /f "tokens=2 delims==" %%a in ('more +%num%^<"%filename%" ^| findstr "\<PhoneNumber\>"') do set ip=%%a

  6. echo.IP Address: %ip%

  7. pause
复制代码
 楼主| 发表于 2011-3-13 08:18:08 | 显示全部楼层
原帖由 lxzzr 于 2011-3-12 17:49 发表
这样行不?
@echo off
rem rasphone.pbk不是ANSI格式

set "filename=%allusersprofile%\application data\microsoft\network\connections\pbk\rasphone.pbk"

for /f "tokens=1 delims=:" %%a in ('type "%fi ...


L版的代码很强大啊!!!
你的代码是获取现在正在连接使用的IP域名
如果我的网络连接里有N个VPN,但我还要获取名字为“虚拟专用网络连接”这个名字的IP域名呢?
不管他是连接还是未连接状态,这个貌似有点难度
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-20 09:43 , Processed in 0.017436 second(s), 8 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表