cmd修改ip地址,启用、禁用上网代理等

内外网切换,内部设置ip、禁用代理;外网ip设置自动,启用代理。

=========================start==============================

echo off
cd /d C:\Windows\System32
set netswitch="c:\chruan.txt"
if exist c:\chruan.txt goto waiwang
if not exist c:\chruan.txt goto neiwang

:neiwang
echo "内网"
netsh interface ip set address name="本地连接" source=static addr=1.1.1.139 mask=255.255.255.0 gateway=128.128.1.1
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
echo >c:\chruan.txt
exit

:waiwang
echo "外网"
netsh interface ip set address name="本地连接" source=dhcp
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f
del c:\chruan.txt
exit
echo on

=========================end==============================

更多的设置,可以看下面的资料

 

用netsh命令做一个批处理文件:(+++上面为手动获取,下面为自动获取,数字根据你的实际情况来吧)

@echo off

netsh interface ip set address name="本地连接" source=static address=192.168.3.47 gateway=192.168.3.1
netsh interface ip set address name="无线网络连接" source=static address=192.168.3.66 gateway=192.168.3.1
netsh interface ip set dnsservers name="本地连接" source=static address=218.2.135.1
netsh interface ip set dnsservers name="无线网络连接" source=static address=218.2.135.1

echo on
+++++++++++++++++++++++++++++++++++++++++++++++++++++++


@echo off
netsh interface ip set address name="本地连接" source=dhcp
netsh interface ip set address name="无线网络连接" source=dhcp
netsh interface ip set dnsservers name="本地连接" source=dhcp
netsh interface ip set dnsservers name="无线网络连接" source=dhcp

echo on

 


rem echo 正在清空代理服务器设置……
rem reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f
rem reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "" /f
rem reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d 0 /f
rem echo 代理服务器设置已经清空
echo 正在设置代理服务器……
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settin gs" /v ProxyEnable /t REG_DWORD /d 1 /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "172.16.2.14:8080" /f
reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyOverride /t REG_SZ /d "" /f
echo 正在设置DNS……
netsh interface ip set dns 本地连接 static 110.85.11.99 primary
netsh interface ip add dns 本地连接 110.85.11.98 index=2
netsh interface 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值