How to Assign Static IP Address From Command Prompt?

Published by: Alex George on April 30, 2023

No device can communicate over a network without a valid IP address. Usually, the DHCP server provides IP ( Internet Protocol ) addresses to devices connected to the network.

Sometimes we must assign a static IP address to a PC while troubleshooting the network.

We use Static IP Address to fix APIPA (Windows IP Configuration).

There are different ways to assign it to a PC, but the easiest method is the DOS method.


There is a DOS prompt command to set a static IP address on a Windows computer.

This tutorial explains how to configure a static IP address from Command Prompt and explains the procedure with a practical example.

At the end of this tutorial, you can see how to perform the same procedure on Mac.





Steps to Assign Static IP To Any Interface From Command Prompt

  1. Start MS-DOS as Administrator

    You must start the command prompt as administrator to set a static Internet Protocol number (IP) on your computer from the command prompt.

    Press the Windows key and S together to open the Search box.

    Type cmd on the Windows Search and right-click the Command Prompt icon.


    cmd set ip address static

    Tap on the Run as Administrator to open Command Prompt with administrative privileges.

    To learn more about it, visit the link below.


  2. Set Static IP Address Command Line

    Type the following command on the DOS window.


    netsh interface ip set address name="[Interface Name]" static [IP Address] [Subnet Mask] [Default Gateway]


  3. Press the Enter key.


It is the theoretical explanation of configuring a logical address on a laptop without the help of a DHCP server.

Now let us check a practical example to learn it.





A Practical Guide to Set Static IP From Command Line

Here I assign a Static IP Address 192.168.42.1 to my computer with default gateway 192.168.42.129 and subnet mask 255.255.255.0.

We need to find the Ethernet Adapter name ( Interface name) to execute the DOS command to set a static IP address.

So, follow the steps carefully.


  1. Check the Current IP Address and The Interface Name

    Type ipconfig on the Command Line and Press the Enter key.

    You can see the IP address and the respective Ethernet adapter name (Interface name).


    ipconfig configure static

    The Interface name is Local Area Connection 2.


  2. Execute the Static IP Command

    Type the following command on the DOS window.


    netsh interface ip set address name="Local Area Connection 2" static 192.168.42.1 255.255.255.0 192.168.42.129

    Press the Enter key to execute the command.



  3. Check the Static IP Address From the Command Prompt

    Type ipconfig on the Command Line and press the enter key.


    netsh interface ip set address

    We have successfully assigned the static IP address 192.168.42.1 to this Windows 11 laptop from the Command Line.





How to Release Static IP From Command Prompt

You cannot release and renew a static IP address by using ipconfig/release.

There is another DOS Prompt command to remove the static IP address set on a computer.

netsh interface ip set address connected adapter name dhcp

Have a look at the screenshot below and find the Ethernet adapter name.


Assign Static IP Address to a Windows 11 Dell laptop

In our case, the adapter name is Local Area Connection 2.

So, to release the static IP address we assigned, use the following command on the DOS prompt.

netsh interface ip set address Local Area Connection 2 dhcp

You can read more about it from the link below.

Configure Automatic IP Addressing From Command Prompt

1 comment:

  1. Just don't forget, if you mentioned GW in syntax, you should also fill in [metric] parameter!!

    ReplyDelete

Newer Post Older Post Home