电脑ip地址用批处理自动更改的实现方法。

来源:互联网 发布:伊朗革命卫队 知乎 编辑:程序博客网 时间:2024/05/17 06:53

嵌入式开发过程中,实验板和电脑有时候会需要进行通讯,比如使用nfs。而且,虚拟机里面的linux系统里面的文件经常需要更改,我想使用ftp方式把更改了的单个文件再写回去。就会面临着频繁更改本机ip地址的尴尬局面,为了方便,参考网上的资料写了一个批处理文件。

@echo offtitle ip地址自动设置器:startclsecho/   echo/   echo/   echo/   echo/               --------------------------------------------echo                             请回复下面命令的编号echo                             1、设置为自动获取ipecho                             2、设置静态上网ip用于与实验板通讯echo                             3、设置静态上网ip用于上网echo                             4、查看当前网络配置信息echo                             5、退出echo/               --------------------------------------------set /p b=if %b% equ 1 goto autogetipif %b% equ 2 goto setstaticipforenif %b% equ 3 goto setstaticipforinternetif %b% equ 4 cccccif %b% equ 5 exit:cccccclsipconfigpausegoto start:autogetip::netsh interface ip set address name=本地连接 source=static addr=202.102.224.1 mask=255.255.255.0 gateway=202.102.224.254 ::netsh interface ip set address name=本地连接 source=static addr=202.102.224.1 mask=255.255.255.0 gateway=202.102.224.254 ::设置为自动获取ipclsecho 正在设置 ...netsh interface ip set address name=本地连接 source=dhcpecho 正在设置 ......netsh interface ip set dns name=本地连接 source=dhcpecho 命令执行完成pausegoto start::设置静态上网ip::修改dns:setstaticipforinternetclsecho 正在设置 ...netsh interface ip set dns name=本地连接 source=static addr=210.44.176.1::修改ip 子网掩码 默认网关echo 正在设置 ...netsh interface ip set address name=本地连接 source=static addr=10.6.66.173 mask=255.255.255.0 gateway=10.6.66.10echo 命令执行完成pausegoto start:setstaticipforenclsecho 正在设置 ...::netsh interface ip set dns name=本地连接 source=static addr=210.44.176.1::修改ip 子网掩码 默认网关echo 正在设置 ......netsh interface ip set address name=本地连接 source=static addr=192.168.12.15 mask=255.255.255.0::netsh interface ip set dns name=本地连接 source=dhcpnetsh interface ip set dns name=本地连接 source=static addr=echo 命令执行完成pausegoto startipconfigpause
通过这个批处理程序,可以方便的实现本机ip地址的更改。

0 0
原创粉丝点击