我对.bat了解不多 现在想实现的是 在办公室多加一个内网IP 备用IP 不用DNS和网关 172开头

发布时间:2024-05-14 03:33 发布:上海旅游网

问题描述:

我的电脑因为白天在办公室用 晚上拿到宿舍玩游戏或者看电影 ~

办公室外网是公司接的网通光纤, 主要是上学查东西和学习, 192开头

内网是172 主要用于连接服务器 数据库` 还有远程操作,

宿舍是我新装的网通ADSL, 因为每次回家和回办公室都要改一次IP 很麻烦
所以在网上找了一个批处理 修改了一下 大致是
在办公室执行:

echo off
netsh interface ip set address "本地连接" static 192.168.0.98 255.255.255.0
netsh interface ip set address name="本地连接" source=static gateway=192.168.0.1 gwmetric=1

Netsh interface IP Set dns "本地连接" static 192.168.0.1 primary
echo 命令执行成功!请验证!
ipconfig /all >c:\ipconfig.txt

在宿舍用:

@echo off
echo 现在开始设置本机网络地址!

echo 现在开始设置本机IP
netsh interface ip set address "本地连接" source = dhcp
echo 现在开始设置本机DNS
netsh interface ip set dns "本地连接" source = dhcp
echo 命令执行成功!请验证!
ipconfig /all >c:\ipconfig.txt

我对.bat了解不多 现在想实现的是 在办公室多加一个内网IP 备用IP 不用DNS和网关 172开头

求达人给解

问题解答:

在办公室执行:
@echo off
::记得此IP不要与别人的冲突
netsh interface ip set address "本地连接" static 192.168.0.98 255.255.255.0
::请确认此网关地址没问题
netsh interface ip set address name="本地连接" source=static gateway=192.168.0.1 gwmetric=1
::内网设置,DNS与网关相同
Netsh interface IP Set dns "本地连接" static 192.168.0.1 primary
echo 设置完毕!请验证!
ipconfig /all
pause>nul
×××××××××××××××××××××
在宿舍用:
@echo off
::现在开始设置本机网络IP与DNS全部自动获取
netsh interface ip set address "本地连接" source = dhcp
netsh interface ip set dns "本地连接" source = dhcp
echo 设置完毕!请验证!
ipconfig /all
pause>nul

热点新闻