Y
Y
Yuri Yerusalimsky2016-04-28 17:50:57
Computer networks
Yuri Yerusalimsky, 2016-04-28 17:50:57

How to change the IP address of a given, active Internet connection through the command line (CMD)?

I only realized that I need to dig in the direction of the netsh utility, or rather netsh set address . The problem is that you need to explicitly specify the name of the network connection for which the IP address changes, and the script itself should read it automatically. How then to do it? I think that somewhere in the registry you need to read some key value that stores the name of the current network connection.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Evgeny Ferapontov, 2016-04-28
@e1ferapontov

netsh interface ip set address name=”Local Area Connection” static 192.168.0.1 255.255.255.0 192.168.0.254

You can find out the current connection using ipconfig
Or do you want to do something else?

S
sh7, 2016-04-28
@sh7

set "wmic=wmic path Win32 networkadapter where NetConnectionStatus="2" get NetConnectionID /value"
for /f "tokens=2 delims==" %%a in (' "%wmic%" ') do set IfName=%%a
netsh int ip set address name="%IfName%" static 192.168.0.1 255.255.255.0 192.168.0.254

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question