自动获取ip和自定义ip和DNS服务器的批处理

将一下内容做成.cmd批处理文件即可实现自动获取ip和自定义ip和DNS服务器的批处理小程序。

其中修改对应的内容可以设置成您要修改的ip地址,网关和DNS服务器。

@echo off
@echo 0. 自动获取ip地址
@echo 1. 修改ip为192.168.1.4
@echo 2. 修改ip为168.8.101.35
@echo 认修改ip为192.168.1.4[直接回车]
@echo 请选择
set selc=1
set /p selc=
@echo 正在设置...
IF %selc%==1 goto HomeIp
IF %selc%==2 goto CMPIp

:AUTOIP
@echo 自动获取ip地址
netsh int ip set add name="本地连接" source=dhcp
@echo 自动获取DNS服务器
netsh int ip set dns name="本地连接" source=dhcp
exit

:HomeIp
@echo 设置为192.168.1.4
netsh int ip set add "本地连接" static 192.168.1.4 255.255.255.0 192.168.1.1 1
@echo 正在设置DNS服务器:192.168.1.1
netsh int ip set dns name="本地连接" source=static 192.168.1.1
exit

:CMPIp
@echo 正在设置ip地址:168.8.101.35
netsh int ip set add "本地连接" static 168.8.101.35 255.255.255.0 168.8.101.1 1
@echo 正在设置DNS服务器:168.8.80.28
netsh int ip set dns name="本地连接" source=static add=168.8.80.28
@echo 正在添加DNS服务器:168.8.80.29
netsh int ip add dns name="本地连接" add=168.8.80.29 index=2
exit

发布了2 篇原创文章 · 获赞 5 · 访问量 1056

猜你喜欢

转载自blog.csdn.net/fxh_2009/article/details/7788138