How to change your IP address from the command line

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on reddit
Share on whatsapp


In Windows, it is quite easy to change your local IP address from the Control Panel. But in the GUI version, this manipulation involves an unnecessary amount of clicks and validations. There is a much more elegant way to change your IP, completely from the command line!

You probably already know how to change your local IP address. But to modify this parameter, it is necessary to go in the meanders of the network parameters which is not always practical. Especially if you often change location, and juggle between static and dynamic IP configurations.

Obviously, if you ask Bob, your computer friend, to do the same thing, he’ll probably open a Command Prompt window, type in some incomprehensible words, and voila. We will teach you in this tutorial to do like him.

Change your network settings from the command prompt

Any of these settings can be changed from the command prompt. But not under any condition. It is indeed necessary to launch cmd.exe with administrator privileges.

  • Type cmd in the menu search bar Start. Right click on Command Prompt and select execute as administrator.
  • Once in the command prompt, we will first use the command Ipconfig to display the current IP address. Type ipconfig to see your network settings and the name of the interface whose settings you want to change – you should see a screen like this:

How to change your IP address from the command line in Windows

We are going to change the IPv4 address of the Ethernet interface from 10.211.55.5 to 10.211.55.8 making it the same static, without touching the subnet mask and the default gateway. Here’s a template for the command, which you can use to change each of these parameters:

netsh interface
ipv4 set address name="NOM DE L'INTERFACE"
static IP_SOUHAITEE MASQUE_DE_SOUS_RESEAU PASSERELLE

In this command, replace the interface name, IP, subnet mask and bridge by your settings. If you only want to change the IP, copy the current parameters into the rest of the command. It is also possible to replace ipv4 with ipv6 if you want to touch the ipv6 settings.

Static means you are going to a fixed IP. To return to an automatic IPv4 configuration, the command looks like this:

netsh interface
ipv4 set address name="NOM DE
L'INTERFACE
" source=dhcp

  • In our case, to switch to the fixed IP 10.211.55.8, you must type:

netsh interface
ipv4 set address name="Ethernet" static 10.211.55.5 255.255.255.0
10.211.55.1

  • You can verify that the settings have been updated by typing again ipconfig
  • If I want to go back to a DHCP configuration, I can type the following command:

netsh interface
ipv4 set address name="Ethernet" source=dhcp

It wasn’t that complicated, was it? So obviously it’s not always super mnemonic. In a future tutorial, we’ll teach you how to associate DOSKEY aliases with these commands, which allow you to run them later with a minimum number of keystrokes.



Source link

Leave a Reply

Table of Contents