Simple netsh script to assign Multiple IPs, DNS, Gateway, etc..

Batch script to assign static IP/DNS/Gateway/Subnet mask. Nothing fancy here but there is some syntax difference in adding a second dns “ip set vs ip add” etc. Pasting it here in case i need to reference it at some point.

netsh interface ip set address name="Local Area Connection" static 192.168.11.8 255.255.255.0 192.168.11.1
netsh interface ip add address name="Local Area Connection" 192.168.11.12 255.255.255.0
netsh interface ip add address name="Local Area Connection" 192.168.11.13 255.255.255.0
netsh interface ip add address name="Local Area Connection" 192.168.11.17 255.255.255.0
netsh interface ip set dns name="Local Area Connection" static 192.168.11.6
netsh interface ip add dns name="Local Area Connection" 192.168.11.7 INDEX=2
netsh int ip show config
Here is what IPconfig /all looks like after running the above:

Ethernet adapter Local Area Connection:

   IPv4 Address. . . . . . . . . . . : 192.168.11.8(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   IPv4 Address. . . . . . . . . . . : 192.168.11.12(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   IPv4 Address. . . . . . . . . . . : 192.168.11.13(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   IPv4 Address. . . . . . . . . . . : 192.168.11.17(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.11.1

   DNS Servers . . . . . . . . . . . : 192.168.11.6
                                       192.168.11.7
This entry was posted in Microsoft, Scripting and tagged , . Bookmark the permalink.

One Response to Simple netsh script to assign Multiple IPs, DNS, Gateway, etc..

  1. me says:

    netsh interface ip set dns “Local Area Connection” static 8.8.8.8
    netsh interface ip add dns name=”Local Area Connection” addr=1.1.1.1

Leave a Reply to me Cancel reply

Your email address will not be published. Required fields are marked *