Get the App
SLTechnology News&Howtos  ›  Development  › 

How to modify IP address and DNS by CMD and vbs

Shulou Source: shulou.com Published: 2022-06-03 06:53:21 11月14日 Update

This article is about how CMD and vbs modify IP addresses and DNS. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Modify IP

Cmd / c netsh interface ip set address name= "Local connection" source=static addr=211.82.56.253 mask=255.255.255.0 gateway=211.82.56.1 gwmetric=1

Modify DNS

Cmd / c netsh interface ip set dns name= "Local connection" source=static addr=202.99.192.66

Configure or update the IP address:

Wmic nicconfig where index=0 call enablestatic ("192.168.1.5"), ("255.255.255.0"); index=0 description is to configure network interface 1.

Configure the gateway (default route):

Wmic nicconfig where index=0 call setgateways (192.168.1.1), (1)

Vbs

Const T_GATEWAY = "211.82.56.1" 'Gateway

Const T_NEWDNS1 = "202.99.192.66" 'DNS1

Const T_NEWDNS2 = "60.221.248.43" 'DNS2

StrWinMgmt= "winmgmts: {impersonationLevel=impersonate}"

Set NICS = GetObject (strWinMgmt) .InstancesOf ("Win32_NetworkAdapterConfiguration")

For Each NIC In NICS

If NIC.IPEnabled Then

NIC.SetDNSServerSearchOrder Array (Thousand NEWDNS2)

NIC.SetGateways Array (T_GATEWAY)

End If

Next

Thank you for reading! This is the end of the article on "how CMD and vbs modify IP address and DNS". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Tags: Address configuration content more article gateway good practical interface article read knowledge network routing reference help update related Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Information Shulou Tech Info Huawei Redmi