1. 程式人生 > >使用批處理命令設定windows系統的ip地址和dns

使用批處理命令設定windows系統的ip地址和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
確定。

相當於操作: