加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

如何在Windows bat中获取某些适配器的默认网关?

发布时间:2020-12-14 00:32:23 所属栏目:Windows 来源:网络整理
导读:请参阅下面的 windows中的ipconfig输出. C:ipconfigWindows IP ConfigurationEthernet adapter Local Area Connection 11: Connection-specific DNS Suffix . : Link-local IPv6 Address . . . . . : fe80::4149:4c25:692d:dfec%91 IPv4 Address. . . . . .
请参阅下面的 windows中的ipconfig输出.
C:>ipconfig

Windows IP Configuration


Ethernet adapter Local Area Connection 11:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::4149:4c25:692d:dfec%91
   IPv4 Address. . . . . . . . . . . : 10.252.26.84
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . :

Wireless LAN adapter Wireless Network Connection 15:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Ethernet adapter Local Area Connection 10:

   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Wireless LAN adapter Wireless Network Connection 14:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::79a2:afc8:7cd0:79ac%72
   IPv4 Address. . . . . . . . . . . : 192.168.10.9
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.10.1

我想在bat文件中找到无线网络连接的默认网关14,然后将其存储在varient中以便稍后使用

我知道我可以“findstr”,但我不知道如何获得该NIC的默认网关.

谢谢!

验证接口名称:
netsh interface ip show address

并尝试这样的事情:

@echo off

for /f "tokens=2 delims=:" %%g in ('netsh interface ip show address 
"Wireless Network Connection 14" ^| findstr "Default"') do 
set DefaultGateway=%%g
echo %DefaultGateway%
pause

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读