使用批处理命令设置windows系统的ip地址和dns附图,dns附图
使用批处理命令设置windows系统的ip地址和dns附图,dns附图
找到对应的网卡名称使用命令:ipconfig
ipconfig/all
Windows IP Configuration
Host Name . . . . . . . . . . . . : D501-4-3
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter 本地连接:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Marvell Yukon 88E8057 PCI-E Gigabit
Ethernet Controller
Physical Address. . . . . . . . . : 44-37-E6-1D-5B-F1
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 192.168.1.111
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
DNS Servers . . . . . . . . . . . : 8.8.8.8
我们现在需要设置的网卡名称为"本地连接",ip地址为192.168.1.111,子网掩码为255.255.255.0,dns地址为8.8.8.8
将ip和dns设置为自动获取
使用命令:
netsh interface ip set address "本地连接" dhcp
netsh interface ip set dns "本地连接" dhcp
netsh interface ip set address "本地连接" dhcp
确定。
netsh interface ip set dns "本地连接" dhcp
确定。
相当于操作:
将ip和dns设置为固定的值
使用命令:
netsh interface ip set address "本地连接" static [ip地址] [子网掩码] [网关] [网关跳远点数:一般填1]
netsh interface ip set dns "本地连接" static [dns地址]
netsh interface ip set address "本地连接" static 192.168.1.111 255.255.255.0 192
.168.1.1 1
确定。
netsh interface ip set dns "本地连接" static 8.8.8.8
确定。
相当于操作:
【批处理设置静态IP】********** 复制以下内容保存为bat
netsh interface ip set address name="本地连接" source = static addr = 172.10.38.90 mask=255.255.0.0
netsh interface ip set address name="本地连接" gateway = 172.10.38.1 gwmetric =0
netsh interface ip set dns name="本地连接" source = static addr = 219.150.150.150 register=PRIMARY
netsh interface ip add dns name="本地连接" addr = 222.88.88.88 index=2
【批处理自动获取IP】********** 复制以下内容保存为bat
netsh interface IP set address name="本地连接" source=dhcp
netsh interface ip set dns name="本地连接" source=dhcp
参考资料:zhidao.baidu.com/question/55642136.html
@echo off
color a
echo.
echo.
set /p name=请输您的计算机名:
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName" /v ComputerName /t reg_sz /d %name% /f
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v "NV Hostname" /t reg_sz /d %name% /f
reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters" /v Hostname /t reg_sz /d %name% /f
cls
echo 我们再进行设置IP吧。
@echo off
set slection1=
set/p slection1=请输入IP地址:
netsh interface ip set address name="本地连接" source=static addr=%slection1% mask=255.255.255.0
set slection2=
set/p slection2=请输入网关地址:
netsh interface ip set address name="本地连接" gateway=%slection2% gwmetric=0
set slection3=
set/p slection3=请输入主dns地址
netsh interface ip set dns name="本地连接" source=static addr=%slection3% register=PRIMARY
set slection4=
set/p slection4=请输入备份dns地址
netsh interface ip add dns name="本地连接" addr=%slection4%
netsh interface ip set wins name="本地连接" source=static addr=none
pause
评论关闭