2

I would like to change an IP address in a Wireless network connection with a cmd line. I have tried:

Netsh -c "interface ipv4" set address name=”Wireless Network Connection” static 192.168.168.6 255.255.255.0 192.168.168.168

*Note The above cmd belongs all on one line

I'm getting an error saying: the filename directory name or volume label syntax is incorrect

The second question I have is, I would like to know how to set the secondary DNS. I think this cmd is working for the primary DNS:

netsh interface ipv4 set dnsservers "Wireless Network Connection" static 8.8.8.8 primary validate=no

I'm working in Win7 Ultimate 32bit

1
  • 1
    Why are you using smart quotes?
    – DavidPostill
    Commented Jun 10, 2016 at 12:02

1 Answer 1

1

Your syntax does not appear to be correct. Try:

netsh interface ipv4 set address "Wireless Network Connection" static 192.168.168.6 255.255.255.0 192.168.168.168

and to add secondary DNS:

netsh interface ipv4 add dns "Wireless Network Connection" 8.8.4.4 index=2
5
  • Thank you answering this. The static IP worked great. The second DNS is giving me an error saying "The parameter is incorrect.". The help for Netsh doesn't have "index" as a option in Win7.
    – Docfxit
    Commented Jun 10, 2016 at 18:48
  • Index is invalid only in Windows XP. On 7, it's a valid option: " index (from /? help) - Specifies the index (preference) for the specified DNS server address." Looks like the word 'static' is no longer needed in case of secondary+ entries. Try without 'static' and it will work. I've updated the main reply.
    – Overmind
    Commented Jun 14, 2016 at 5:55
  • Thank you very much for resolving the issue. The cmd line does work great. Silly me the word add really does add the DNS. What I really need is replace the DNS. If there is something in the secondary DNS I would like to remove it and then replace it with a new DNS.
    – Docfxit
    Commented Jun 17, 2016 at 2:33
  • What I really need is replace the DNS. If there is something in the secondary DNS I would like to remove it and then replace it with a new DNS.
    – Docfxit
    Commented Jul 3, 2016 at 23:40
  • netsh interface ipv4 delete dns - this can remove it, you can use index, just like for adding.
    – Overmind
    Commented Jul 4, 2016 at 5:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .