首页
/
每日頭條
/
科技
/
win系統下dns默認地址配置文件
win系統下dns默認地址配置文件
更新时间:2025-04-16 17:41:16
概述

一鍵快速修改windows系統的IP和DNS采用執行xx.bat文件方式,那麼xx.bat文件該如何編寫呢?本期文章向各位小夥伴總結分享。

實戰演練——如何通過命令修改windows系統的IP和DNS

第1步:采用管理員權限打開命令提示符(CMD),如下圖所示(windows10操作系統);

win系統下dns默認地址配置文件(一鍵快速修改windows系統的IP和DNS)1

第2步:在命令提示符中輸入“netsh”,然後,輸入“interface ip”,如下所示;

­C:\Users\007>netsh

netsh>

netsh>interface ip

netsh interface ipv4>

第3步:在“netsh interface ipv4>”視圖中,輸入命令“show interface”查詢系統的可用的網卡信息從而獲取網卡的名稱,如下圖所示;

win系統下dns默認地址配置文件(一鍵快速修改windows系統的IP和DNS)2

第4步:在“netsh interface ipv4>”視圖中,輸入命令set address "Ethernet0" dhcp和set dns "Ethernet0" dhcp,配置網卡Ethernet0自動獲取IP地址和DNS地址,默認情況下,永久保存。如下圖所示;

win系統下dns默認地址配置文件(一鍵快速修改windows系統的IP和DNS)3

第5步:查看網卡IP地址和DNS地址的配置效果,在“netsh interface ipv4>”視圖中,輸入命令show address "Ethernet0"和show dns "Ethernet0",如下圖所示;

win系統下dns默認地址配置文件(一鍵快速修改windows系統的IP和DNS)4

以上是關于windows系統自動獲取IP和DNS的配置方式,那麼如何配置靜态的IP地址和DNS地址呢?

Windows系統配置靜态IP地址和DNS地址的方式,如下圖所示;

win系統下dns默認地址配置文件(一鍵快速修改windows系統的IP和DNS)5

備注:

Windows10系統提供的示例——IP地址配置方式:

set address name="Wired Ethernet Connection" source=dhcp

set address "Wired Ethernet Connection" static 10.0.0.9 255.0.0.0 10.0.0.1 1

Windows10系統提供的示例——DNS地址配置方式:

set dnsservers name="Wired Ethernet Connection" source=dhcp

set dnsservers "Wired Ethernet Connection" static 10.0.0.1 primary

實戰演練——如何一鍵修改windows系統的IP和DNS一鍵修改Windows系統的IP和DNS——DHCP自動獲取

把以下兩條命令複制到文本文檔中,并另外為dhcp.bat。(管理員權限運行dhcp.bat)

Ethernet0是系統網卡名稱,需要通過命令netsh interface ipv4 show interface提前查詢獲得。

netsh interface ipv4 set address "Ethernet0" dhcp

netsh interface ipv4 set dns "Ethernet0" dhcp

另存為dhcp.bat方式,如下圖所示;

win系統下dns默認地址配置文件(一鍵快速修改windows系統的IP和DNS)6

一鍵修改Windows系統的IP和DNS——靜态配置

把以下兩條命令複制到文本文檔中,并另外為static.bat。(管理員權限運行static.bat)。其中,IP地址:192.168.1.100、掩碼:255.255.255.0、網關:192.168.1.254、DNS地址:223.5.5.5。

netsh interface ipv4 set address "Ethernet0" static 192.168.1.100 255.255.255.0 192.168.1.254

netsh interface ipv4 set dns "Ethernet0" static 223.5.5.5

總結

以上是一鍵快速修改windows系統的IP和DNS的總結分享,不足之處,歡迎各位小夥伴留言多多指正。

,
Comments
Welcome to tft每日頭條 comments! Please keep conversations courteous and on-topic. To fosterproductive and respectful conversations, you may see comments from our Community Managers.
Sign up to post
Sort by
Show More Comments
Copyright 2023-2025 - www.tftnews.com All Rights Reserved