How-To Geek

How to change your ip address from the command prompt in windows.

It's easy enough to change an IP address on your PC using Control Panel, but did you know you can also do it from the Command Prompt?

Quick Links

Launch command prompt as admin to use netsh, view your network information with command prompt, change your ip address, subnet mask, and default gateway, change your dns settings in command prompt, key takeaways.

  • You must launch Command Prompt, PowerShell, or Terminal as admin to use netsh.
  • Use the "netsh interface ipv4 show config" command to find the full name of the network interface you want to change.
  • Modify your IP address, subnet mask, and default gateway using the command "netsh interface ipv4 set address". You can also change DNS settings using "netsh interface ipv4 set dns".

Changing your IP address with the Control Panel interface isn't difficult, but it does require clicking through a number of different windows and dialog boxes. If you're a fan of the Command Prompt, though, you can get it done more quickly using the netsh command, which is just one of the great network utilities built into Windows .

We're going to use the netsh command, but it requires that Command Prompt be launched as administrator to work. The netsh command allows you to configure just about any aspect of your network connections in Windows.

To launch Command Prompt (or PowerShell) as Admin, open up the Start Menu, search "cmd," hover over the result, then click "Run as Administrator."

In Windows 10 or Windows 11, you can also right-click the Start menu (or press Windows+X on your keyboard) to open the Power User Menu and choose "PowerShell (Admin)."

You can (and should ) use PowerShell for this instead.

Before you change your IP address and related information, you'll need to find the full name of the network for the interface you want to change. To do this, type the following command:

netsh interface ipv4 show config

Scroll down until you see the interface you're looking for. In our example, we're going to modify the Wi-Fi interface, which on our machine is just named "Wi-Fi." You'll also see other default names that Windows assigns to interfaces, such as "Local Area Connection," "Local Area Connection* 2," and "Ethernet." Just find the one you're looking for and make note of the exact name. You can also copy and paste the name to Notepad and then back into Command Prompt later to make things easier.

With the interface name in hand, you're ready to change the IP Address, subnet mask, and gateway. To do this, you'll issue a command using the following syntax:

netsh interface ipv4 set address name="YOUR INTERFACE NAME" static IP_ADDRESS SUBNET_MASK GATEWAY

So, for example, your command might look something like the following:

netsh interface ipv4 set address name="Wi-Fi" static 192.168.3.8 255.255.255.0 192.168.3.1

Where the info is replaced by whatever you want to use. In our example, the command does the following:

  • Uses the interface name "Wi-Fi"
  • Sets the IP address to 192.168.3.1
  • Sets the subnet mask to 255.255.255.0
  • Sets the default gateway to 192.168.3.1

And if you're using a static IP address but want to switch to using an IP address assigned automatically by a DHCP server — such as your router — you can use the following command instead:

netsh interface ipv4 set address name="YOUR INTERFACE NAME" source=dhcp

You can also use the netsh command to change the DNS servers used by a network interface. Third-party DNS servers — like Google Public DNS and OpenDNS —can be faster and more reliable than the DNS servers provided by your ISP. Whatever your reason for changing your DNS server , you can do it either at the router so it affects all the devices that get their information from the router or at the individual device. If you want to change the DNS servers for just one PC, it's easy to do with the netsh command.

You'll need to use the command twice: once to set your primary DNS server and once to set your secondary, or backup, DNS server. To set your primary DNS server, use the following syntax:

netsh interface ipv4 set dns name="YOUR INTERFACE NAME" static DNS_SERVER

So, for example, your command might look something like the following (in which we set it to Google's primary public DNS server, 8.8.8.8):

netsh interface ipv4 set dns name="Wi-Fi" static 8.8.8.8

To set your secondary DNS server, you'll use a very similar command:

netsh interface ipv4 set dns name="YOUR INTERFACE NAME" static DNS_SERVER index=2

So, continuing our example, you might set your secondary DNS as the Google Public DNS secondary server, which is 8.8.4.4:

netsh interface ipv4 set dns name="Wi-Fi" static 8.8.4.4 index=2

And just like with the IP address, you can also change it so that the network interface grabs its DNS settings automatically from a DHCP server instead. Just use the following command:

netsh interface ipv4 set dnsservers name"YOUR INTERFACE NAME" source=dhcp

And there you have it. Whether you like typing at the command prompt better or just want to impress your coworkers, now you know all the command line magic you need for changing your IP address settings.

StackHowTo

  • How To Set Static IP Address in Windows 10 using CMD

I n this tutorial, we are going to see how to set static IP address in Windows 10 using CMD . There are several methods to set a static IP address in Windows 10. In this tutorial, we will see together how to set a static IP address from the Command Prompt.

In Windows 10, setting a static IP address for your device is an essential configuration that may be required in a number of scenarios. For example, if you plan to share files or a printer on a local network, or when you try to set up port forwarding.

Using CMD may seem difficult for some users, yet it is one of the fastest ways to assign a static IP address in Windows 10.

assign ip using cmd

  • IPv4 address
  • Subnet mask
  • Default gateway
  • DNS servers

assign ip using cmd

  • Types of Ethernet Cable
  • How to Install CAB File in Windows 10 using Command Line
  • How to Change Multiple File Extensions at Once in Windows 10 Using PowerShell
  • How to Make Taskbar Buttons Smaller in Windows 10
  • How to Run AutoHotKey Script on Startup Windows 10
  • How to Remap Keyboard Keys in Windows 10
  • How to Search Files by Size in File Explorer on Windows 10
  • How to Check Internet Data Usage in Windows 10
  • How to Change Folder Background Color in Windows 10
  • How to Turn off Location on Laptop Windows 10
  • How to Disable Sleep Option from Windows 10 Start Menu
  • How to Wake Up Computer From Sleep Mode in Windows 10 with Mouse
  • How to Wake Up Computer From Sleep Mode in Windows 10 with Keyboard
  • Batch File To Display Popup Message in Windows 10
  • How to Display Popup Reminder in Windows 10
  • How to See PC Startup and Shutdown History in Windows 10
  • How to Record Your Screen with VLC on Windows 7/8/10
  • How to Change Paging File Size in Windows 10
  • How to Display Full Path in Title Bar of File Explorer on Windows 10
  • How to Cancel Shutdown on Windows 10
  • How to Schedule Auto Shutdown in Windows 10
  • How to Schedule a Scan in Windows Defender
  • How to Calculate Total Duration of Multiple Video Clips in Windows 10
  • How to Fix Drag and Drop Problems in Windows 10
  • How to Disable Power Throttling in Windows 10
  • How to Run Program as Administrator Without Password Prompt in windows 10
  • How to Limit Windows Defender CPU Usage
  • How to Check if Windows 10 is Activated
  • How to Fix Right Click on Desktop Not Working in Windows 10
  • Image Resizer on Right-click for Windows 10
  • How to Change Computer Name in Windows 10
  • How to Change Account Picture in Windows 10
  • How to Zoom in and out in CMD and PowerShell
  • How to Lock Screen After Inactivity on Windows 10
  • How to Sync Computer Time With Internet in Windows 10
  • Command To Check Open Ports in Windows
  • How to Keep a Window Always On Top on Windows 10
  • How to Increase Font Size in Windows 10
  • How to Change Cursor Color in Windows 10
  • How to Change Cursor Size in Windows 10
  • How to Change Default PDF viewer on Windows 10
  • How to Disable Security Questions in Windows 10
  • How to Pin Specific Settings to the Start Menu in Windows 10
  • How to Format USB Device When FAT32 Option is Not Available
  • How to Automatically Open a Web Page at a Specific Time
  • How to Restart explorer.exe in Windows 10 Using CMD
  • How to Restart Explorer.exe in Windows 10 [2 Methods]
  • How to Add Program Shortcut to Start Menu in Windows 10
  • Hibernate Option Not Showing In Windows 10
  • How To Delete Previous Version of Windows in Windows 10
  • How to Add Print Option in Right-Click Menu
  • How to Delay Startup Programs in Windows 10/8/7
  • How to Disable Task Manager on Windows 10
  • How to Turn on Network Discovery in Windows 10
  • How to Check if Virtualization is Enabled in Windows 10
  • How to Password Protect a Zip File on Windows 10
  • How To Change User Folder Name in Windows 10
  • How to Restore Drivers in Windows 10
  • How to Backup Drivers using PowerShell Command in Windows 10
  • How to Add Store Apps to Startup in Windows 10
  • How to Enable Fingerprint in Windows 10
  • How to Enable Autocorrect and Predictive Text in Windows 10
  • How To Open a Second File Explorer Window in Windows 10
  • How to Block Websites On Your Computer
  • Check Disk Command in Windows 10
  • How to Activate a Window by Hovering Over it with the Mouse in Windows 10
  • How to Control Volume for Individual Programs in Windows 10
  • How to Schedule Restart in Windows 10
  • How to Change Microsoft Store Region in Windows 10
  • How to Hide the Clock From Windows 10 Taskbar
  • How to Enable Number Pad on Keyboard Windows 10
  • How to Turn Off Taskbar Thumbnail Previews in Windows 10
  • How Can I See All Drives in CMD
  • How to Show All Drives in Windows 10 File Explorer
  • Windows 10 Privacy Settings to Turn Off
  • How to Change Desktop Icons in Windows 10
  • How to Force a Program to Open in Full Screen in Windows 10
  • How to Delete Temporary Files in Windows 10
  • How to Enable Startup Sound in Windows 10
  • How to Reset All Default Apps in Windows 10
  • How to Change Default Action on Connecting a USB Device Windows 10
  • How to Remove Old Drivers From Windows 10
  • Where is the Drivers Folder in Windows 10
  • How to Reset Windows Update in Windows 10
  • How to Format USB Using CMD on Windows 10
  • How To Check WiFi Signal Strength on Windows 10 Using CMD
  • How to Remove “Show Desktop” Button on Windows 10
  • How to Enable Remote Desktop on Windows 10
  • How To Open File Explorer To “This PC”
  • How to Stop the Screen From Turning Off on Windows 10
  • How to Change Default Folder Name in Windows 10
  • How to Display Day of Week in Windows 10 Taskbar
  • How To Display Windows 10 Start Menu in Full Screen

How to Create a New Library in Windows 10

  • How to Reset the Settings App in Windows 10
  • How To Disable Startup Programs in Windows 10
  • How to Enable Registry Backup in Windows 10
  • How to Remove Password at Windows 10 Startup
  • How to Reset Windows 10 To Factory Settings
  • How To Enable or Disable Night Light in Windows 10
  • How to Add Clocks to Start Menu on Windows 10
  • How to Disable Bing Web Search Results in Windows 10 Start Menu
  • How to check Bluetooth battery level on Windows 10
  • How To Find Out If a Program is 32 or 64-bit Windows 10
  • How To Check Bios Firmware Version in Windows 10
  • How To Activate Windows 10
  • How to enter UEFI (BIOS) on Windows 10
  • How to Boot From a USB Drive on Windows 10
  • How to Reinstall Microsoft Store in Windows 10

How to Enable Ultimate Performance Mode in Windows 10

  • How to Stop Apps From Running in the Background on Windows 10
  • How to Change Another User’s Password in Windows 10
  • How to Delete Local User Account using PowerShell in Windows 10
  • How to Create Local User Account using PowerShell in Windows 10
  • How to Disable User Account Control (UAC) in Windows 10
  • How to Block Inappropriate Websites on Windows 10
  • How to Set Up a Child Account in Windows 10?
  • How to Download Windows 10 ISO file (32 bits and 64 bits)
  • How to Change the Default Save Location in Windows 10
  • How to Add Open Command Prompt Here to right-click Menu in Windows 10
  • Add Open PowerShell Window Here as Administrator in Windows 10
  • How to Mount ISO Images on Windows 10
  • How to Clear DNS Cache on Windows 10
  • How to Change DNS Server in Windows 10
  • How to Change Temp Folder Location in Windows 10
  • How to Reduce the Size of the Search Bar in Windows 10
  • How to Force Close a Program on Windows Without Task Manager
  • How to Force Close a Program with Task Manager
  • How to Speed Up Windows 10 Startup
  • How to Enable Sandbox in Windows 10
  • How to Disable Automatic Installation of Suggested Apps in Windows 10
  • No Sounds on Windows 10? Here’s How to Fix It
  • No Audio Output Device Is Installed in Windows 10 Fix
  • Where is the Location of Startup Folder in Windows 10?
  • How to Create a Windows 10 Bootable USB
  • How To Run Computer Performance Test in Windows 10
  • How To Tell If Your Computer Is 32 Or 64-bit Windows 10
  • How to Remove Recycle Bin From Desktop on Windows 10
  • How to Show My Computer, Recycle Bin Icon on Windows 10
  • How To Enable Screen Saver In Windows 10
  • How to Enable or Disable Updates For Other Microsoft Products on Windows 10
  • How to Disable Windows 10 Startup Delay
  • How To Open Emoji Keyboard on Windows 10
  • How to Turn On File and Printer Sharing in Windows 10
  • How To Optimize Windows 10 For Gaming
  • How to Add Shortcuts to the “Send to” Menu in Windows 10
  • How to Change the Screen Refresh Rate of Your Monitor in Windows 10
  • How to Make a Program Run on Startup in Windows 10
  • How to Turn Off SmartScreen in Windows 10
  • How to Disable Telemetry in Windows 10
  • How to Disable Windows 10 Tracking
  • How to Disable Windows 10 Data Collection
  • How to Free Up Disk Space in Windows 10
  • Fast Way to Delete a Large Folder in Windows 10
  • How to Create a Printer Shortcut on Desktop Windows 10
  • How to Change Audio Output Device Per Application on Windows 10
  • How to Format a Hard Drive or SSD in Windows 10
  • How to Switch Between Windows in Windows 10 using Keyboard
  • How to Download and Install Windows Media Player for Windows 10
  • How to Create a Shortcut on Desktop Windows 10
  • How to Block reopening of Programs on startup Windows 10
  • How To Limit Windows Update Bandwidth in Windows 10
  • How to remove the 3D Objects folder from This PC in Windows 10
  • How to Remove Old User Account Pictures in Windows 10
  • How to Delete the Hibernation File hiberfil.sys
  • How to Show Seconds in System Clock in Windows 10
  • How to Open Files and Folders with Single Click in Windows 10
  • How to Reset Your Microsoft Account Password for Windows 10
  • How to Fix Corrupted Files in Windows 10
  • How To Export And Import Start Menu Layout In Windows 10
  • How to Stop Automatic Restart After Updating Windows 10
  • How to Remove Ads From the Start Menu in Windows 10
  • How to Create a Homegroup Network in Windows 10
  • How to Disable ads in File Explorer in Windows 10
  • How To Fix gpedit.msc Group Policy Editor Missing in Windows 10
  • How to Change the Network Connection Priority in Windows 10

How to Watch Videos While Working on Other Tasks on Windows 10 Computer

  • How to Create a System Repair Disk in Windows 10
  • How to Customize the Taskbar in Windows 10
  • How to Change Taskbar Icons in Windows 10
  • How to Show the Control Panel in File Explorer on Windows 10
  • How to Uninstall Updates in Windows 10
  • How to reset all Local Group Policy on Windows 10
  • How To Turn Windows 10 Computer Into a Wi-Fi Hotspot
  • How to Reset Network Settings in Windows 10 Using CMD
  • How to Disable the Game Bar in Windows 10
  • How to Clear Windows 10 Update Cache
  • How to Create an Invisible Folder without Any Name in Windows 10
  • How to Add Open With to Right-click Menu in Windows 10
  • How to Change Default Apps on Windows 10
  • How to Prevent Copying Files From USB to PC
  • How to Find Your WiFi Password on Windows 10
  • How to Hide Your Name and Email Address on Windows Login
  • How to Speed Up File Transfer in Windows 10
  • How to Remove Power or Shutdown Button from Lock Screen in Windows 10
  • How to Start Windows 10 in Safe Mode
  • How to Stop Lock Screen ads in Windows 10
  • How to Enable Guest Account in Windows 10 using CMD
  • How to Restore Windows 10 Image Backup From Hard Drive
  • How to Create a System Image in Windows 10
  • How to Disable Automatic Update on Windows 10
  • How to Stop Programs From Automatically Updating in Windows 10
  • How to Take a Screenshot on Windows 10
  • Windows 10: Start Menu And Taskbar Not Working
  • How to Rebuild a Broken Icon Cache in Windows 10
  • How to Turn Off Windows Security Notifications in Windows 10
  • How to Preview a File Without Opening it in Windows 10
  • How to Permanently Disable Windows Defender on Windows 10
  • How to Disable the Action Center in Windows 10
  • How To Reinstall Microsoft Edge In Windows 10
  • How to Uninstall Microsoft Edge in Windows 10
  • How to Change Start Menu and Taskbar Color in Windows 10
  • How to Get Windows 7 Start Menu on Windows 10 with Classic Shell
  • Why the Start Menu is Slow to Open in Windows 10
  • How to Change Login Screen Background on Windows 10
  • How to Restore Windows Photo Viewer in Windows 10
  • How to Fix Screen Flickering in Windows 10
  • How to Remove Windows 10’s Built-in Apps
  • How to Fix Black Screen on Windows 10
  • How to Remove Search Bar From Taskbar on Windows 10
  • How to Disable Windows 10 Peer-to-Peer Updates
  • How to Downgrade to Windows 7 From Windows 10
  • How to Fix Windows 10 Start Menu And Cortana Not Working
  • How to Backup and Restore Registry in Windows 10
  • How to Change the Default Installation Location on Windows Using Regedit
  • How to Force Restart Windows 10 with Keyboard
  • How to Remove Shortcut Arrow from Desktop Icons on Windows 10
  • How to Find Computer Specs on Windows 10
  • How To Move Your Libraries To Another Drive in Windows 10
  • How to Enable Numlock at Windows Startup
  • How to Change CMD Color in Windows 10
  • How To Increase Font Size In CMD
  • How To Assign Letter To Drive In CMD
  • How To Get MAC Address In CMD
  • How to Open File Explorer Using CMD on Windows 10
  • How To Run Batch File On Windows Startup
  • How To Run EXE From A Batch File
  • How To Run A Python Script From A Batch File
  • How to Run PowerShell Script From A Batch File
  • How to Run Multiple Batch Files From One Batch File
  • Batch File To Copy All Files From One Folder To Another
  • How To Compare Strings In Batch Files
  • How To Concatenate Variables In Windows Batch File
  • How To Clear A Variable In A Batch File
  • For Loop Counting From 1 To N in a Batch File
  • How to Run Batch File Automatically Every X Minutes
  • Batch File To Get and Set System Date
  • Batch File To Set Default Programs in Windows 10
  • Batch File To Get Computer Name
  • Batch File To Get Current Directory
  • Batch File To Get Input From User
  • Batch File To Get IP Address
  • Batch File To Get MAC Address
  • How to Add a Registry Key in a Batch File
  • Batch File To Create Local User Accounts
  • Batch File To Create a Text File
  • Batch File To Create a Folder
  • Batch File To Create Folders From a List
  • Batch File To Write Ping Results To a Text File
  • Batch File To Write Variable To a Text File
  • Batch File To Write To a Text File
  • Batch File To Read XML File
  • Batch File To Read CSV / XLS
  • Batch File To Read Text File Line By Line into A Variable
  • Batch File To List Folder Names
  • Batch File To List Folders and Subfolders
  • Batch File To List Filenames in a Specified Folder
  • Batch File to List All Files in a Folder and Subfolders
  • How to Check Internet Connection using Batch File
  • How to Check the Size of a File in a Windows Batch Script
  • How To Check Batch File Error
  • Batch File To Check If Folder Exists
  • How to Check If a Path is File or Directory using Batch
  • Batch File To Delete Folders Older Than N Days
  • Batch File To Delete All Files in Folder Older Than N Days
  • Batch File To Delete All Files In Folder
  • Batch File To Delete A File If Exists
  • Batch File To Check If Multiple Files Exist
  • Batch File To Check If File Exists
  • Batch File Commands List With Examples
  • 8 Batch File Commands You Should Know
  • How to Create a Batch File in Windows
  • How to Run Batch File in CMD
  • How to Run EXE File in CMD
  • How to Change the MAC Address on Windows 10
  • How to Create a Website Shortcut on Desktop In Windows 10
  • 29 Run Commands in Windows You Should Know
  • How to Ping IP Address in CMD
  • How to Get IP Address Using Ipconfig in CMD
  • How to Delete Folder Using CMD in Windows 10
  • CMD Commands List You Should Know
  • How to Change Lock Screen in Windows 10
  • How to Show My Computer Icon on Desktop in Windows 10
  • How to Change Compatibility Mode in Windows 10
  • How to Uninstall Internet Explorer in Windows 10
  • How to Add or Change Desktop Theme in Windows 10
  • How to Disable Transparency Effects in Windows 10
  • How to Delete and Uninstall Fonts in Windows 10
  • How to Install New Fonts in Windows 10
  • How to Disable Lock Screen on Windows 10 Using Registry
  • How to Customize Action Center in Windows 10
  • How to Disable Cortana in Windows 10 using Registry
  • Battery Icon Missing From Taskbar in Windows 10 [Solved]
  • How to Change Desktop Background in Windows 10
  • How to Increase Battery Life of Windows 10 Laptop
  • How to Turn off Notifications in Windows 10
  • How to Create Keyboard Shortcuts in Windows 10
  • How to Change Desktop Icon Size in Windows 10
  • How to Turn On Dark Mode on Opera
  • How to Turn On Dark Mode on Mozilla Firefox
  • How to Turn On Dark Mode on Google Chrome
  • How to Turn On Dark Mode on Microsoft Edge
  • How to Enable Dark Mode in Windows 10
  • How to Increase Mouse Sensitivity in Windows 10
  • How to Find Which Programs are Slowing Down Your Boot Time in Windows 10
  • How to Defrag the Hard Drive in Windows 10
  • How to Copy and Paste Into Command Prompt in Windows 10
  • How to Enable the On-Screen Keyboard in Windows 10
  • How to Check Laptop Battery Health in Windows 10
  • How to Use Offline Maps in Windows 10
  • How to Calibrate Your Monitor in Windows 10
  • How to Enable God Mode in Windows 10
  • How to Increase Processor Speed in Windows 10
  • How to Pin a Folder to Taskbar in Windows 10
  • How to Pin a Website to Taskbar in Windows 10
  • How to Switch Between Desktops in Windows 10
  • How to Make Windows 10 Boot Faster
  • How to Stop Windows 10 From Sleeping
  • How to Set an Alarm Clock on Windows 10
  • How to Go Directly to Desktop in Windows 10
  • How to Create a New Folder on Windows 10
  • How to Reduce Blue Light on Computer Screen on Windows 10
  • How to Turn on Speech Recognition in Windows 10
  • How to Sync My Settings in Windows 10
  • How to Change the Screen Resolution on Windows 10
  • How to Create a New User on Windows 10
  • How to Turn Off Tablet Mode in Windows 10
  • How to Uninstall a Program on Windows 10
  • How To Change Password In Windows 10
  • Top Keyboard Shortcuts in Windows 10
  • How to Speed Up Windows 10 Shutdown
  • How to Change Default Browser in Windows 10
  • How to Disable the Lock Screen in Windows 10
  • How to disable User Account Control in Windows 10
  • How to Hide File Extensions in Windows 10
  • How to Show Hidden Files and File Extensions in Windows 10
  • How to Create a Restore Point with System Protection Enabled in Windows 10
  • How to Delete Browsing History on Firefox in Windows 10
  • How to Delete Browsing History on Microsoft Edge in Windows 10
  • How to Delete Browsing History on Google Chrome in Windows 10

You May Also Like

How to Watch Videos While Working on Other Tasks on Windows 10 Computer

Leave a Reply Cancel reply

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

Save my name, email, and website in this browser for the next time I comment.

How to Configure Windows 10 IP Address with CMD?

' data-src=

Configuring IP address in a Windows with CMD performed using netsh command line utility. The network shell ( netsh ) is a set of commands that help you configure any Windows operating system IP address, Network Interfaces, and Windows Firewall. The usage of the command line is for pro level Windows users. Those who are playing the network infrastructure configuration. But using the command line as normal Windows user indicate your expertise to Windows environment. If you are new to Windows command line, this article “configure IP address with command prompt in Windows 10” will help you begin using command line interface.

Configuring Windows IPv4 Networking with Netsh or Network Shell. Netsh is a command-line utility included in Microsoft’s Windows NT line of operating systems beginning with Windows 2000. It allows local or remote configuration of network devices such as the NICs.

Configure IP Address with Command Prompt in Windows 10

Before setting IP address with cmd in Windows 10, you need to know how to find your IP address on Windows 10. So before everything, you must know the network IP address configuration on your system.

Let’s learn the process of IP configuration step by step. I am going to explain it with an easy pictorial guide. If you don’t understand some part, just kindly comment us and ask your questions.

The process of Changing Windows 10 IP Address with Command Prompt: 

  • Find your IP address in Windows 10.
  • View network interfaces card.
  • Change IP address on Windows 10.
  • Change DNS IP address with the command line.
  • Reset IP address with Command Prompt.

How to Find your IP Address on Windows 10?

There are many options for finding IP address on Windows 10. The easy one is “ ipconfig ” command. To find your IP address on Windows 10, just type “ ipconfig ” in command prompt. To do this process:

  • Press Windows+R keys to open the Run .
  • Type “ cmd ” in the run and press enter.
  • Now type “ ipconfig ” to show the IP address.

The “ ipconfig ” command shows everything about your computer network interfaces. You might have many physical or virtual network interface card.

How to Find Your IP Address on Windows 10 - Technig

Here, I just have one network interface on my Windows 10 computer. The result of ipconfig command shows that the IP 169.254.29.130 with the mask of 255.255.255.0 is my current Windows IP address.

This is a class C “autoconfiguration IPv4”. When your system doesn’t find any DHCP Server or manual IP address, it obtains auto IP address. So let’s change it.

How to C hange  IP Address with  Command Prompt?

For change IP address, open command prompt or PowerShell. Both works the same and you can run all command prompt commends on Powershell as well. Ok, run cmd or Powershell as administrator. Netsh work in both command prompt and Powershell. I’m using Windows Powershell to change IP address on Windows 10 completely. Becuase the user interface and color’s of Powershell is better than Command prompt.

  • Type “ Powershell ” in Windows 10 search box to run Windows Powershell.
  • You need to run Powershell as administrator. Just press Windows+Shift the press enter to run Powershell as administrator. Or right-click the Powershell and click Run as administrator .

PowerShell Guide in Windows 10

To find the network interface with the command line, type the following command on Powershell.

Netsh Command to Check Network Adapter in Windows 10

The result shows two network interfaces. The Loopback and the Ethernet. The Loopback is Windows builtin network loopback interface, but our pointed network interface is the ethernet.

To find your IP address in Windows 10 with netsh command, just type the following command.

How to Find Your IP Address on Windows 10 with Netsh Command - Technig

It displays all the network interface configuration. The output result is clear and better than output result of “ ipconfig ” command on Command prompt. So to find an exact information of the network interface, just add the index ID of the network interface at the end of the command.

How to Find Windows 10 IP address with Command Line - Technig

That’s good. Let’s configure and change Windows 10 IP address with the command line. The command is bit long but easy to understand. No need to remember, just try to understand the netsh command structure.

To change the IP address of the “Ethernet0” network interface, type the following command.

Change IP Address in Windows 10 using Command Line - Technig

Once the command executed successfully, check the result with “ netsh interface ipv4 show config 2 ” command. Yes, the output result shows the exact IP address has set on the “ Ethernet0 ” network interface. Now the Windows IP address is 200.100.10.5 with the mask of 255.255.255.0 and default gateway is 200.100.10.1.

Note : You can’t change the default gateway separately with the following command. It will remove the IP address and just set the default gateway address.

That’s good and enough for IP address configuration in Windows 10 with the command line. Let’s change DNS IP address from the command line.

  • Related :  MCSA Lab Manual Articles .

How to Change DNS IP address from Command Prompt?

DNS IP address is the unique address in the network that resolves computer name to IP address and IP address to the computer name. In the network, finding a computer with a name is easy than 32-bit IPv4 address. To set or change the DNS IP address, just simply do it with the following command.

How to Change DNS IP address from Command Prompt - Technig

You might see some error on a simple local network, because of not having a DNS server. When you don’t have a DNS server, it’s not necessary to set DNS IP address on your computer.

Configure IP Address with command prompt in Windows - Technig

Finally, recheck the result with “ netsh interface ipv4 show config 2 ” command. The output netsh command should be displayed with DNS IP address.

Final World

Configure IP address with command prompt in Windows has tow benefits. The first benefit of working with Windows command line helps get you improve your skills in Windows environment. The second benefit is command line is faster than GUI. If you work with the command line, you will understand the power of command line.

The Windows command line interface has improved a lot in Windows 10. Now you can find some Linux commands that run in Windows 10 and works the same on Linux. Finally, hope you learn how to configure IP address with Command Prompt in Windows operating systems. If you don’t understand, please ask us about how to configure IP address with command prompt in Windows 10?

' data-src=

How to Restore Backup in Windows Server 2022

How to change DNS zone settings in Windows Server 2022?

How to Share Files Over Network (Share Permissions) on Windows 11

Deny Users Access to PC Settings and Control Panel using Group Policy

' data-src=

I am thankful to you for your articles.

' data-src=

i changed my ip address and need it back

' data-src=

You are the greatest! I have been banging my head trying to find information on how to do this. 2 days and the only information I changed was “connected” to “not connected”, thank you so much

Your email address will not be published.

Save my name, email, and website in this browser for the next time I comment.

TECHNIG is proudly powered by WordPress

Welcome, Login to your account.

Recover your password.

A password will be e-mailed to you.

WindowsLoop

How to Change IP Address in Command Prompt (Renew IP)

To renew or change the IP address, you can use the netsh command. Here’re the steps to change the IP address in Command Prompt in Windows 10.

When connected to a network, the Windows computer will automatically get a new IP address as long as it is configured to “ Obtain an IP address automatically “. Generally, having the IP address auto-assigned is pretty helpful as you don’t have to configure any extra settings to connect to a network. For instance, you can just plug-in the ethernet cable or connect to a WiFi network and you are ready to go thanks to the auto-config option in Windows 10.

Though Windows can automatically obtain an IP address without any hassle, there might times where you need a specific IP address. For example, to share files in your local network, having a static IP address is really helpful. This eliminates the need to reconfigure the IP address every time you want to access the network drive. In these kinds of cases, you need to change the IP address in Command Prompt .

Thankfully, with just a couple of commands, you change the IP address from Command Prompt. Here are the exact steps you should follow.

Steps to Change IP Address in Command Prompt

To change the IP address from the Windows Command Prompt, there are two major steps. First, you need to know the network interface name and then use it to set the IP address. It is pretty easy. Follow the steps as shown below and you will be good.

  • First, press the Windows key to open the Start menu .
  • Now, type “ Command Prompt ” in the search bar.
  • Right-click on the Command Prompt and select the “ Run as administrator ” option.
  • Execute the below command to get the network interface name. netsh interface ipv4 show config

Change-ip-address-in-command-prompt-040920

  • Once you have the interface name, execute the below command while replacing “IP_Address”, “Subnet_Mask”, and “Gateway” with the actual IP address you want to assign, subnet mask, and gateway respectively. netsh interface ipv4 set address name="Interface_Name" static IP_ADDRESS SUBNET_MASK GATEWAY
  • After assigning the IP address, close the command prompt window .

That is all. It is that simple to change the IP address in the command prompt.

Note: You can get the subnet mask and gateway addresses from the router or from your ISP.

If you want the IP address to be assigned automatically, execute the below command. This will set the network interface from Static IP to DHCP. DHCP will automatically get a new IP address from the router.

That is all. I hope that helps. If you are stuck or need some help comment below and I will try to help as much as possible. If you like this article, check out how to change the network name in Windows 10 .

About The Author

Avatar for Bashkarla

Leave a Comment Cancel Reply

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

Save my name, email, and website in this browser for the next time I comment.

assign ip using cmd

How to configure a static IP on Windows 10 or 11

Do you need to switch from a dynamic to a static IP address configuration on Windows 11 or 10? Here's how.

Windows 11 static IP

  • Windows 11 static IP
  • Windows 10 static IP

On Windows, the router's Dynamic Host Configuration Protocol (DHCP) server is (usually) responsible for assigning a dynamic Transmission Control Protocol/Internet Protocol (TCP/IP) configuration to every device in the network, including to your computer running Windows 11 or Windows 10.

Although a dynamic IP address is the recommended configuration for most situations, you may need to change to a static IP address if you're thinking about setting up a printer or file sharing, or you have to configure port forwarding on the router to your computer.

The reason is that a dynamic network configuration can change at any time after the lease from the DHCP expires and if the address changes, network resources you may have configured will stop working. Setting a static IP address will always stay the same on the computer, allowing a more reliable experience sharing resources in the network or forwarding ports.

Whatever the reason, on Windows 10 and 11, you have many ways to configure a static TCP/IP address, including using the Settings app and Command Prompt.

This guide will walk you through the different ways to configure a static network configuration on Windows 11 and 10.

How to set a static TCP/IP network configuration on Windows 11

On Windows 11, you can change your computer's dynamic IP configuration to static in at least two ways through the Settings app or commands.

Configure IP from Settings app

Get the Windows Central Newsletter

All the latest news, reviews, and guides for Windows and Xbox diehards.

To assign a permanent TCP/IP configuration on Windows 11, use these steps:

  • Open  Settings .
  • Click on  Network & internet .
  • (Optional) Click on Advanced network settings .
  • Under the "More settings" section, click on Hardware and connection properties.
  • Note the current IPv4 ,  Subnet mask ,  Default Gateway , and  DNS server addresses to determine the new configuration, as it has to be in the same network scope.
  • Click the  Ethernet  or  Wi-Fi  page on the right side from the "Network & internet." page.

Ethernet settings

  • Quick note:  If you select the Wi-Fi page, you need to click on the connection properties to access the network settings.
  • Click on the  Edit  button for the "IP assignment" setting.

IP assignment

  • Select the  Manual  option from the drop-down menu.
  • Turn on the  IPv4  toggle switch.
  • Confirm the IP address for the computer – for example, 10.1.4.90.
  • Confirm the subnet mask for the configuration – for example, 255.255.255.0.
  • Confirm the default gateway address (usually your router's IP) – for example, 10.1.4.1.
  • Confirm the preferred DNS address – for example, 10.1.4.1.

Static IP configuration

  •   Quick note:  In a home network, you may also be able to use the router's IP address for the DNS configuration. You can also use third-party DNS services like Google Public DNS, Cloudflare, Cisco's OpenDNS, and others. 
  • (Optional) Select the  "On (automatic template)"  option for the "DNS over HTTPS" setting and leave the  "Fallback to plaintext"  option disabled unless you want to encrypted as well as unencrypted traffic or you're troubleshooting connectivity.
  • Quick note:  DNS over HTTPS (DoH) is a feature that encrypts the DNS queries over the HTTPS protocol to improve security and privacy on the internet. You only want to enable this feature if the DNS server supports this feature.
  • Confirm the alternate DNS address (if applicable).
  • (Optional) Select the  "On (automatic template)"  option for the "DNS over HTTPS" setting and leave the  "Fallback to plaintext"  option disabled.
  • Click the  Save  button.

Once you complete the steps, the computer will start using the static network configuration. If everything has been configured correctly, you should be able to open the web browser to access the internet.

If you entered an address (such as the DNS address) and then changed it, you probably won't be able to save the settings. If this is the case, cancel the configuration, start over, enter the correct configuration, and then try to save the settings.

Configure IP from Command Prompt

To set a static TCP/IP configuration on Windows 11, use these steps:

  • Open  Start .
  • Search for  Command Prompt , right-click the top result, and select the  Run as administrator  option.
  • Type the following command to see your current networking configuration and press  Enter : ipconfig /all
  • Confirm the name of the adapter and the networking configuration, including the IPv4 , Subnet mask , Default Gateway , and DNS Servers .

ipconfig command

  • Type the following command to configure a static TCP/IP address and press  Enter :  netsh interface ip set address name= "ADAPTER-NAME" static IP-ADDRESS SUBNET-ADDRESS DEFAULT-GATEWAY-ADDRESS

In the above command, replace  ADAPTER-NAME  with the name of your network adapter. Change  IP-ADDRESS SUBNET-ADDRESS    DEFAULT-GATEWAY-ADDRESS  with the device IP address, subnet mask, and default gateway addresses you want. For example, this command sets the 10.1.4.90, 255.255.255.0, 10.1.4.1 configuration:  netsh interface ip set address name="Ethernet 10Gb" static 10.1.4.90 255.255.255.0 10.1.4.1

Command Prompt configure IP address

  • Type the following command to set a DNS server address and press  Enter :  netsh interface ip set dns name="ADAPTER-NAME" static DNS-ADDRESS  

In the command, change  ADAPTER-NAME  with your adapter's name and  DNS-ADDRESS  with the DNS server address of the network. For example, this command sets the local router as the DNS server:  netsh interface ip set dns name="Ethernet 10Gb" static 10.1.4.1

  • Type the following command to set an alternate DNS server address and press  Enter :  netsh interface ip add dns name="ADAPTER-NAME" DNS-ADDRESS index=2

In the command, change  ADAPTER-NAME  with the adapter's name and  DNS-ADDRESS  with an alternate DNS server address. For example, netsh interface ip add dns name="Ethernet 10Gb" 1.1.1.1 index=2

After you complete the steps, the commands will set a static network configuration on Windows 11.

How to set a static TCP/IP network configuration on Windows 10

On Windows 10, you can also use the Settings app and Command Prompt to set up a static IP network configuration.

To assign a permanent TCP/IP configuration on Windows 10, use these steps:

  • Click on  Ethernet  or  Wi-Fi .
  • Click on the active connection on the right side.

Network properties

  • Click the  Edit  button for the "IP assignment" setting.

Windows 10 IP assignment

  • Select the  Manual  option.
  • Confirm the subnet prefix length (subnet mask) for the configuration – for example, 24 to specify the 255.255.255.0 subnet mask.

Windows 10 static IP address

  • Quick tip:  It's important to use the number that represents the network instead of the subnet mask. Otherwise, the configuration won't save. If you don't know the subnet prefix length for your subnet mask, you can use any  online subnet calculator  to find out.

Once you complete the steps, Windows 10 will start using the static IP configuration. If you lose network connectivity, restart the computer to regain access to the local network and internet.

To change from dynamic to static IP address with commands on Windows 10, use these steps:

In the command, change  ADAPTER-NAME  with your adapter's name and  DNS-ADDRESS  with the DNS server address of the network. For example, this command sets the local router as the DNS server:  netsh interface ip set dns name=" Ethernet 10Gb" static 10.1.4.1

In the command, change  ADAPTER-NAME  with the adapter's name and  DNS-ADDRESS  with an alternate DNS server address. For example, netsh interface ip add dns name="Ethernet0" 1.1.1.1 index=2

After you complete the steps, the network configuration will switch from dynamic to static on Windows 10.

Mauro Huculak

Mauro Huculak is technical writer for WindowsCentral.com. His primary focus is to write comprehensive how-tos to help users get the most out of Windows 10 and its many related technologies. He has an IT background with professional certifications from Microsoft, Cisco, and CompTIA, and he's a recognized member of the Microsoft MVP community.

  • 2 The deluxe edition of FromSoftware's best action game of 2023 is on sale for less $36
  • 3 Windows on ARM FAQ: What it is, how ARM processors differ from CPUs, ARM history, and more
  • 4 How to get the new Freedom Mask in The Division 2
  • 5 The Windows PC is about to get GOOD, and you can thank Windows on Arm for that

assign ip using cmd

site logo

Change IP Address and DNS Servers using the Command Prompt

Just because it's more fun

Author avatar

The Command Prompt application, sometimes referred to as command shell, is found in most Windows NT-based operating systems. Its purpose is to execute specific commands for troubleshooting or solving specific Windows issues, performing advanced administrative functions, and automating tasks via batch files and scripts.

That said, you can also use it to change your IP address when you want to spoof it to bypass geoblocks or online bans on sites that impose such restrictions on their content, or change your Domain Name System (DNS) servers for troubleshooting reasons or to make surfing more secure and faster.

Change IP Address and DNS Servers using the Command Prompt image 1

In this guide, we’re going to show you how to change your IP address and DNS servers using the Command Prompt in Windows 10.

How To Change IP Address Using Command Prompt

An IP address holds information about your device, location, your internet service provider (ISP), and browser information.

Changing it is useful when you have a malfunctioning router that’s providing addresses used by a different computer on the network or an invalid address is accidentally configured.  It’s also helpful when you want to install a new router and reconfigure your home network to use the default IP address range.

Change IP Address and DNS Servers using the Command Prompt image 2

The first step to changing your IP address is to find the network name for the interface you want to change. 

  • Open an elevated Command Prompt by typing CMD in the search bar and clicking on Run as Administrator .

Change IP Address and DNS Servers using the Command Prompt image 3

  • Next, type netsh interface ipv4 show config in the command prompt window, press Enter, and scroll down to the interface you want.

Change IP Address and DNS Servers using the Command Prompt image 4

In our case, we’ll be modifying the WiFi interface, but you can pick the correct interface for your case. Make note of the interface name.  

  • To change the IP address, type this command: netsh interface ipv4 set address name=”YOUR INTERFACE NAME” static IP_ADDRESS SUBNET_MASK GATEWAY

In our example, this command would look like this: netsh interface ipv4 set address name=”Wi-Fi” static 192.168.0.173 255.255.255.0 192.168.0.0

Change IP Address and DNS Servers using the Command Prompt image 5

This command will use the Wi-Fi interface, set the IP address to 192.168.0.173, set the subnet mask to 255.255.255.0 and set the default gateway to 192.168.0.0.

If you want to switch to using an IP address automatically assigned by a DHCP server instead of a static IP address, use the netsh interface ipv4 set address name=”YOUR INTERFACE NAME” source=dhcp command.

How To Change DNS Servers Using Command Prompt

 A DNS server holds public IP addresses and related hostnames in a database, and is used to resolve or translate the hostnames to IP addresses. The server does this by running special software to communicate with other servers through special protocols based on certain requests from the computer. 

The conversion process is thoroughly vetted and verified, and it happens quickly behind the scenes so as to obtain information corresponding to the server that the computer is looking for, and then tells the original connecting computer where to go so that it can connect to that server.  

Change IP Address and DNS Servers using the Command Prompt image 6

There are several reasons why you’d want to change your default DNS server , but the main ones are:

  • Boost your privacy when getting around a firewall, bypassing geoblocks or ISP blocks on a website
  • Increase security
  • Parental controls like blocking websites from your router
  • Speed your surfing, which your own ISP’s DNS servers may not offer because they’re not always reliable or up-to-date

Note : You can change DNS servers individually for your home network on your router or on computers, smartphone, and Chromebook, among other devices

How To Change DNS Servers With Command Prompt

Follow the steps below to learn how to change DNS servers using Command Prompt.

  • Open an elevated Command Prompt by typing CMD in the search bar, and clicking Run as Administrator .

Change IP Address and DNS Servers using the Command Prompt image 7

  • Type netsh and press Enter .

Change IP Address and DNS Servers using the Command Prompt image 8

  • Next, type interface ip show config and press Enter .

Change IP Address and DNS Servers using the Command Prompt image 9

  • Find the network interface whose DNS server you want to change, and enter the netsh interface ipv4 set dns name=”YOUR INTERFACE NAME” static DNS_SERVER . This will set your primary DNS server.

From our example above, we changed the IP address for the “Wi-Fi” interface, so we’ll use the same example to change DNS servers. 

For purposes of this guide, we’ll use Google’s primary public DNS server, 8.8.8.8. The command will look something like this: netsh interface ipv4 set dns name=”Wi-Fi” static 8.8.8.8

Change IP Address and DNS Servers using the Command Prompt image 10

  • Next, type the netsh interface ipv4 set dns name=”YOUR INTERFACE NAME” static DNS_SERVER index=2 command to set the secondary DNS server. Again, we’ll use Google’s public DNS secondary server, 8.8.8.8  as an example, which will look like this: netsh interface ipv4 set dns name=”Wi-Fi” static 8.8.4.4 index=2.

Change IP Address and DNS Servers using the Command Prompt image 11

Note : You can use the netsh interface ipv4 set dnsservers name”YOUR INTERFACE NAME” source=dhcp command if you want the network interface to automatically pick DNS settings from a DHCP server. Continuing with our example, this command would look like this: netsh interface ipv4 set dnsservers name”Wi-Fi” source=dhcp

Command Prompt is a great tool to use when you want to change IP addresses and DNS servers. It’s faster and saves you the hassle of having to click through several windows and dialog boxes from the Control Panel interface just to get to the IPv4 Properties dialog box to do the same thing. 

Was this guide helpful? Let us know by dropping your comment in the section below.

' src=

Elsie is a technology writer and editor with a special focus on Windows, Android and iOS. She writes about software, electronics and other tech subjects, her ultimate goal being to help people out with useful solutions to their daily tech issues in a simple, straightforward and unbiased style. She has a BCom degree in Marketing and currently pursuing her Masters in Communications and New Media. Read Elsie's Full Bio

Read More Posts:

assign ip using cmd

Leave a Reply

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

How to Set a Static IP Address on a Windows PC

You can learn how to set up a static IP address on your computer. Here's how.

While most of the internet runs on dynamic addresses these days, static addresses are sometimes helpful to use as well. Whether you need to run a server of your own, set up external devices or services, or are just simply looking to explore, before you get your hands dirty, you need to know your way around and be super careful while setting up an IP address.

Moreover, there's more than one way to go about this. So, one by one, let's look at all the ways you can easily set up a static IP address on your Windows.

Static IP Addresses: The Whys and Hows

An IP address of a computer that stays the same over time is known as a Static IP address . This is in contrast to a dynamic IP Address, which is an address that can tweak over time.

Today, most devices use a dynamic IP address because of their ease of use and management. However, in rare cases, Static IP addresses can become handy. Some of those cases include:

  • When you have external devices that you can only connect to your network through your IP address.
  • When you connect to other networks through a VPN.
  • Static IP addresses can make hosting a server somewhat easier.

Because of a slew of such benefits, using a Static IP address can make your life super easy in some situations. So, now let's look at the different methods you can use to set up a static IP address for yourself.

How to Set a Static IP Address on Windows 11

Like most things on Windows, you have multiple ways to do this. Let's look at the most straightforward method first, which is using Windows Settings.

Here's how you can set a static IP Address using the Windows settings:

  • Head to the Start menu search bar, type in 'settings,' and select the best match. Alternatively, press the Windows Key + I to launch the Settings menu.
  • Then head to Network & internet settings .
  • Look for the Properties button. It's right next to your connection settings.
  • Scroll down and look for the IP assignment section. Then click on Edit .
  • In the new Edit IP settings dialog box, click on the scroll-down menu and select Manual .
  • Toggle on the switch for the IPv4 button.
  • Fill in all the network details here, including the IP address , Subnet mask , Gateway , and then click on Save .

Follow the above steps meticulously, and your Windows 11 will have a new static IP address from here on.

How to Set Up a Static IP Address on Windows 10

The basics of setting up an IP Address in Windows 10 are similar. Even though the implementation of steps might differ here and there, you have to follow a pattern that's pretty much the same. Here's how:

  • Open the Windows 10 Settings.
  • Click on Network & Internet .
  • Depending on how you are connected to the Internet, select Wi-Fi or Ethernet .
  • Select the current network connection.
  • Toggle on the IPv4 switch.
  • Set up the static IP address here and fill in other relevant information, such as the Preferred DNS , Default Gateway , etc.
  • Click on Save .

After you are done, you will have a new static IP address on your PC from here on.

How to Set Up a Static IP With Command Prompt

The above method, using the Settings GUI, is only one of the ways to tweak your IP address settings. For those of you who tilt more towards a command line rather than a simple click-and-play GUI, luckily, alternatives exist. For instance, you can also use the Command prompt, and set up the address with just a few commands.

To change up your IP address through your Command Prompt, follow the below steps:

  • Head to the Start menu search bar, type in 'cmd,' and launch the cmd as administrator.
  • Type in the following command in the cmd and hit Enter : ipconfig /all
  • Subnet mask
  • Default Gateway
  • DNS Servers
  • Type in the following command to assign static IP address on your Windows and hit Enter : netsh interface ip set address name= "Ethernet1" static 10.1.4.220 255.255.255.0 10.1.4.1 In the above command, replace Ethernet1 with the name of your adapter, and change 10.1.4.220 255.255.255.0 10.1.4.1 with the device IP address, subnet mask, and default gateway address corresponding to your network configuration
  • Now type the following command to set up a DNS server address and hit Enter : netsh interface ip set dns name= "Ethernet1" static 10.1.4.1

That's it. Your new static IP address will be set up from here.

How to Set Up a Static IP Address With PowerShell

PowerShell is another tool primarily handy for power users, designed to give them more control and management capabilities through task automation. If any of the above methods fail, you can also use PowerShell to set up the Static IP Address. Here’s how you can get started:

  • Head to the Start menu search bar, type in ‘powershell,’ and run it as administrator.
  • Type the following command to view your current network configuration and press Enter : Get-NetIPConfiguration
  • InterfaceIndex
  • IPv4Address
  • IPv4DefaultGateway
  • Type in the following command to set up a static IP address and hit Enter : New-NetIPAddress -InterfaceIndex 10 -IPAddress 10.1.4.119 -PrefixLength 24 -DefaultGateway 10.1.4.1
  • Here, replace all values of information. Replace the InterfaceIndex number (10) with the number assigned to your adapter. Similarly, replace the above IPAddress with a static IP address that you want to set.
  • Finally, type in the following command to assign the DNS server address and hit Enter : Set-DnsClientServerAddress -InterfaceIndex 10 -ServerAddresses 10.1.4.1

Again, replace the InterfaceIndex number (10) with your network’s corresponding number. Also, replace the ServerAddress with the DNS IP address.

You will have a new static IP address as soon as you finish all the above steps.

Setting up a Static IP Address on a Windows PC

Setting up your static IP address doesn't have to be complicated. If you follow the above methods we have laid out above, you should be done without any significant difficulties.

And while static IP address has their uses, dynamic addresses are undoubtedly necessary. So, before you make an important switch, ensure you understand their significant differences well.

Itechtics

How to set static IP address and DNS Server using Command Line in Windows 10

Configure Static IP address and DNS Server using PowerShell in Windows 10

Repeatedly having to change your Static IP address when shifting from one network to another can be a pain in the neck. The process is lengthy on Windows 10 and a bit irritating. If you are the person who needs to switch between IP addresses, then this article is for you.

Here we shall show you how you can configure your system’s IP address directly through the command line interface on your Windows 10 platform. It is very less time consuming and can be done in a few steps.

Table of Contents

The IP address is a unique identifier of your machine that lets every other component on the network know where the packets need to be routed to. Since it is unique, it cannot conflict with another IP address on the same network.

Configure Static IP address and DNS Server using PowerShell in Windows 10

You can manage your IP address by both the Command Prompt and the PowerShell, which shall be discussed further in the article.

How to check Interface Index using PowerShell

The Interface Index is a unique number assigned to either a physical or virtual networking port. Each port is assigned a number that is used to address the respective port on the machine. For example, if there are 5 different networking adapters on a computer, each one would have its own Interface Index.

To check the associated Interface Index for each, run the following command in PowerShell with administrative privileges :

get index

In the example above, the “ifIndex” is identified as the Interface Index. Note that the ports are repeated as the first half represents IPv6, while the 2nd half represents IPv4 configuration. Nonetheless, the Interface Indexes of the same ports are the same.

Note down the associated Interface Indexes as they will be required when assigning static IPs through PowerShell.

How to set static IP address using Command Prompt

These commands are relatively easier with the Command Prompt when compared with PowerShell . You can change the IP address of your computer using this quick command.

Launch the Command Prompt with administrative privileges and then use the command below to assign the desired IP address configuration:

In the above command, you need to place the information according to your requirement. Replace NameOfPort with the alias name of the network adapter you wish to set the IP of. Also, replace [IP address] with the IP address of the port you wish to assign, replace [Subnet mask] with its subnet, and replace [Default gateway] with the gateway of the adapter.

Here is an example:

Since the name of my port is “Ethernet,” entering the command above would result in the following configuration:

ip set

How to set DNS address using Command Prompt

As you may have noticed above, we did not set up the DNS. This is because you need to enter a separate command to configure the DNS, which is as below:

This will set the first DNS entry as 8.8.8.8. Note that this will only occur if the port can communicate with the DNS. Else it will throw an exception.

The above command would result in something like this:

dns 1 set

To change the second DNS server, use the following command:

dns 2 set

Remember to change the port name, IP address, gateway, and subnet mask according to your requirement.

Each time you need to switch between your IPs and DNSs, use these commands, and it will automatically overwrite the previous entering.

How to set static IP address using PowerShell

Although the PowerShell command lines are more complex than those of the Command Prompt, they also offer more parameters to be addressed. However, we will try and keep it as plain and simple as possible.

Before we proceed further, you need to understand some terms to enter the correct parameters. Below are a few arguments and their descriptions used in PowerShell to set static IPs and DNS entries.

Now, modify the following command according to your needs, launch Windows PowerShell with administrative privileges and enter the command:

PS 1

Note that we determined the correct Interface Index using the command we had discussed earlier in the article. This is what the IP configuration of the port would look like after running the command above:

PS ip set

How to set DNS address using PowerShell

You can also use PowerShell to assign DNS addresses as well quickly. In the example below, we have assigned both the primary and the secondary DNS addresses to our port simultaneously.

PS set dns

You may repeatedly use these commands in PowerShell to overwrite new IP address, subnet mask, gateway and DNS entries of any network port you want on your PC.

Closing words

Now you do not need to worry about switching from one network to another. You can make the process even quicker by saving the respective IP configuration on your PC and copy-pasting it to the command line when required to switch.

If, however, you run into a problem associated with your computer network, you may use this guide to reset the TCP/IP stack .

  • How to Check Public IP Address Using Command Line In Windows 10/Windows 11
  • Check VPN Connection Status From Command Line In Windows

assign ip using cmd

Pradip Shah

I have been using netsh for more than 10 years now to switch between 2 ISP’s services. My only problem was the jokers at MS kept changing command line switches with every version of Windows. XP -> 7 -> 10. Why is something beyond me.

Forgot to mention that I religiously avoid using power shell & work only with “Take Command” from JPSoft.

(Cancel Reply)

Notify me of follow-up comments by email.

Notify me of new posts by email.

Get Updates in Your Inbox

Sign up for the regular updates and be the first to know about the latest tech information

Email Address

assign ip using cmd

Sign up for our daily newsletter

  • Privacy Policy
  • Advertise with Us

How to Set a Static IP Address on Windows

Meenatchi Nagasubramanian

A dynamic IP address is the recommended configuration for most Windows PC users. However, a static IP address is required when a computer provides a service for other PCs. This tutorial walks you through how to quickly set a static IP address on your computer.

Good to know : check out how to find the IP address of a network printer .

Why Do You Need a Static IP Address

1. set static ip address using settings, 2. using command prompt, 3. using powershell.

A static IP address could be useful in various cases, including:

  • Hosting : if you’re hosting a website, having a dynamic IP address can be a hassle. It’s best to have a static IP address to avoid the need to manually change the router settings every time the computer gets a new IP address.
  • File server : is your computer configured as an FTP or a web server? It is highly recommended to use a static IP address, as your device can be easily accessed by others to download files.
  • Remote access : if you plan on accessing your Windows PC remotely, having a static IP address can provide faster and more reliable access. In contrast, dynamic IP addresses are constantly changing and can create difficulties connecting with remote devices.

You don’t need to be a pro user to set a static IP address, as you can do that easily with the Settings app on your Windows computer.

  • Click the Start menu, and launch the Settings app.

Opening Settings app from Star menu.

  • Click “Network & Internet” in the left pane. Click “Properties” next to your Wi-Fi network on the right.

Clicking

  • Scroll down and click the “Edit” button next to “IP assignment.”

Clicking

  • Click the drop-down box in the “Edit network IP settings” dialog, and select “Manual.”

Clicking drop-down box to select

  • Select the IPv4 or IPv6 format to set the static IP address. In this example, we are selecting IPv4.

Selecting the option IPv4 in

  • Fill in all the required details, such as IP address, Subnet mask, and Gateway, and click “Save.”

Fill all the required values of IPv4 and click Save

  • When entering the IP address, make sure it is a private IP address that can be used on home and other private networks. According to the Internet Assigned Numbers Authority (IANA) , the addresses reserved for private networks are as follows:
  • Class A : 10.0.0.0 to 10.255.255.255
  • Class B : 172.16.0.0 to 172.31.255.255
  • Class C : 192.168.0.0 to 192.168.255.255
  • For any private network that needs to use IP addresses internally, it is permissible to use any address within the specified ranges. These addresses are unique only within the given private network.
  • Typically, networks with a significant number of total hosts utilize Class A addresses, while medium- to large-sized networks opt for Class B, and small local area networks use Class C.
  • To fill the Subnet Mask and Gateway fields, make sure you are using the same values that are currently assigned to your router. To find those values, launch the Command Prompt, type the following command, and press Enter . Also, note the “DNS Servers” address, as you’ll need it later.

enter ipconfig /all to get the details of network configuration

Tip : learn how to manage and control wireless networks via the Command Prompt .

You can also configure the static IP address from the Command Prompt if you prefer the command line.

  • Right-click on the Start menu, and click “Run” from the list of options.

Selecting

  • Type cmd.exe in the box, then press Ctrl + Shift + Enter to launch the Command terminal in admin mode.

Typing

  • To set a static IP address, use the following command and press Enter . Make sure you replace “X” with the name of your network adapter, as well as [IP address], [Subnet Mask], and [Default Gateway], each with your specific address. The values correspond to Subnet Mask and Default Gateway that you identified using ipconfig in the previous section.

Enter the netsh command to set static ip address

Note : to find the name of the network adapter, navigate to “Control Panel -> Network and Internet -> Network and Sharing Center,” and jot down the name next to “Connections.”

  • To set the DNS server address, use the following command and press Enter . Replace “X” with the name of your network adapter and [DNS server address] with the DNS server address of the network you found earlier using ipconfig .

Setting a DNS server address via Command Prompt.

  • You will not see a success message but can run the ipconfig command again to check the new configuration.

Typing ipconfig on Command Prompt to view the modified network configuration.

Tip : need the IP address of your router ? Learn how to find it.

Alternatively, use the PowerShell tool to set a static IP address for your Windows PC.

  • Press Win + X on your keyboard, and click Terminal (Admin) in the menu to launch PowerShell.

Pressing Win + X and select

  • To view the details of your current network configuration, type the following command and press Enter . From the results displayed, jot down the values for the following fields: InterfaceIndex, IPv4Address, IPv4DefaultGateway, and DNSServer.

Entering command on PowerShell to get network configuration.

  • Type the following command to set a static IP address and press Enter . Before executing the command, don’t forget to add the values for InterfaceIndex, IPAddress, and DefaultGateway. As for the PrefixLength, in most cases, it should be set to “24.” The parameter defines the local subnet size or subnet mask. For example, for a subnet mask such as “255.255.255.0,” the prefix length is 24 bits, while a subnet mask of “255.255.0.0” has a prefix length of 16 bits.

Enter command to set Static IP Address using PowerShell.

  • To set the DNS server address, use the following command and press Enter . Make sure to add the values for InterfaceIndex and ServerAddresses (DNSServer).

Enter command to set Dns Address using Powershell

Tip : unable to launch PowerShell? Try these fixes.

Static IP Is Sometimes Handy

Businesses have more use for static addresses than home networks. It’s completely safe to use a static IP address, as errors like “ Your IP has been temporarily blocked ” happen mostly with dynamic IP addresses. Plus, it is not complicated to set a static IP address if you follow the instructions outlined in this tutorial. Check out our post to troubleshoot Wi-Fi-related issues if you experience any problems with your Internet connection.

Image credit: Unsplash . All screenshots by Meenatchi Nagasubramanian .

Our latest tutorials delivered straight to your inbox

Meenatchi Nagasubramanian

Meenatchi is always passionate about learning new technological advancements and would love to try out new gadgets, software, and apps. After quitting her career as an Embedded Software Developer in 2009, she took up a career in content writing.

Featured Image of Microsoft Net Framework Error; Woman on Lenovo ThinkPad Source Pixabay

How to Set up an IP Address using CMD: A Step-by-Step Guide

Setting up an ip address using command prompt (cmd) can be a powerful tool for troubleshooting network issues or configuring network settings. in this step-by-step guide, we will walk you through the process of setting up an ip address using cmd..

How to Set up an IP Address using CMD: A Step-by-Step Guide

Prerequisites

Before we begin, make sure you have administrative access to your computer or network device. Additionally, ensure that you have a basic understanding of the Windows Command Prompt.

Step 1: Open the Command Prompt

To start, launch the Command Prompt. You can do this by pressing the Windows Key + R on your keyboard, then typing “cmd” and hitting Enter. Alternatively, you can search for “Command Prompt” in the Start Menu.

Step 2: Identify available network interfaces

Once the Command Prompt is open, you need to identify the network interface for which you want to set up the IP address. To do this, type the following command and press Enter:

A list of network interfaces will be displayed. Look for the one that corresponds to your network adapter or device.

Step 3: Release the current IP address (optional)

If your network interface already has an assigned IP address that you want to change, you can release it before proceeding. To release the current IP address, type the following command and hit Enter:

ipconfig /release

Step 4: Set up a new IP address

Next, you need to set up a new IP address for the network interface. To assign a specific IP address, type the following command, replacing “X.X.X.X” with the desired IP address:

netsh interface ipv4 set address name="YOUR_INTERFACE_NAME" static X.X.X.X subnetmask Y.Y.Y.Y gateway Z.Z.Z.Z

Replace “YOUR_INTERFACE_NAME” with the name of the network interface (e.g., “Ethernet” or “Wi-Fi”). Set “X.X.X.X” as the desired IP address, “Y.Y.Y.Y” as the subnet mask, and “Z.Z.Z.Z” as the gateway IP address. Press Enter to execute the command.

Step 5: Verify the new IP address

To verify that the IP address has been successfully set, type the following command and press Enter:

The Command Prompt will display the network interface details, including the newly assigned IP address. Check if the IP address matches the one you set up in the previous step.

Step 6: Test the connection

Finally, test your network connection to ensure that the new IP address is functioning as expected. Open a web browser or use any network-dependent application to verify internet connectivity. If the connection is successful, congratulations – you have successfully set up an IP address using CMD!

Setting up an IP address using CMD can be a useful skill for troubleshooting network issues or configuring specific network settings. By following this step-by-step guide, you should now be able to easily set up an IP address using Command Prompt on your Windows device. Remember, understanding and experimenting with these commands can provide valuable insights into your network configuration.

How helpful was this article?

How to set a static IP address on Windows 11

Here are the steps to set a static IP address on Windows 11 with Command Prompt, PowerShell, Control Panel, and Settings.

Avatar for Mauro Huculak

UPDATED 7/21/2023: On Windows 11, a static IP address is a network configuration that never changes, making it the preferred option to share files , a printer on a local network , or configure port forwarding.

Usually, when a computer connects to the network, it receives a dynamic IP address assigned by the local Dynamic Host Configuration Protocol (DHCP) server. The only problem is that this configuration can change at any time, as soon as you restart the computer or after the settings expire, and this can cause services like port forwarding and remote desktop to stop working. A static network configuration always maintains the same settings, making it ideal for hosting services that other users can access through the network.

This guide will teach you how to set a static IP (version 4) address on Windows 11 . (See also this video tutorial with the steps to complete this task.)

Assign static IP address on Windows 11 from Command Prompt

Assign static ip address on windows 11 from powershell, assign static ip address on windows 11 from settings, assign static ip address on windows 11 from control panel.

To set a static IP address on Windows 11 with Command Prompt, use these steps:

Open Start on Windows 11.

Search for Command Prompt , right-click the top result, and select the Run as administrator option.

Type the following command to see your current networking configuration and press Enter :

Under the network adapter, note the name of the adapter as well as the following information in these fields:

  • Subnet mask
  • Default Gateway
  • DNS Servers

Windows 11 ipconfig all command

Type the following command to assign a static IP address on Windows 11 and press Enter :

In the above command, replace “Ethernet0” with the name of your network adapter. Change “10.1.4.119 255.255.255.0 10.1.4.1” with the device IP address, subnet mask, and default gateway address corresponding to the local area network.

Type the following command to set a DNS server address and press Enter :

In the command, make sure to change “Ethernet0” with your adapter’s name and “10.1.4.1” with the DNS server address of the network.

Type the following command to set an alternate DNS server address and press Enter :

In the command, change “Ethernet0” with the adapter’s name and “8.8.8.8” with an alternate DNS server address.

Windows 11 netsh command to set static IP address

After completing the steps, you can use the ping command (for example ping google.com ) to see if the configuration works correctly.

You can use PowerShell with the “NetTCPIP” module to manage networking settings, including changing the IP address settings to a static configuration.

To set a static IP address with PowerShell, use these steps:

Open Start .

Search for PowerShell , right-click the result, and select the Run as administrator option.

Type the following command to view your current network configuration and press Enter :

Get-NetIPConfiguration

Confirm the following network information: 

  • InterfaceIndex
  • IPv4Address
  • IPv4DefaultGateway

Type the following command to set a static IP address and press Enter :

PowerShell assign static IP address

In the command, replace the “InterfaceIndex” number (10) with the corresponding number of your adapter. Change “IPAddress” with the static IP address you want to assign to your device. Change “PrefixLength” (subnet mask) with the correct bit number if necessary. Typically, on a home network, the setting is “24.” Also, change the “DefaultGateway” option with the default gateway address of the network.

Type the following command to assign a DNS server address and press Enter :

PowerShell assign static DNS address

If you need to set a secondary DNS server address, use a comma to use the same command with another address. For example:

In the command, replace the “InterfaceIndex” number (10) with your network adapter’s corresponding number. Also, change “ServerAddresses” with the DNS IP address.

Once you complete the steps, the new network configuration will apply to the computer.

Regardless of your chosen method, always assign a TCP/IP address in the network range and outside of the DHCP server scope to allow proper connectivity and avoid configuration conflicts. The reason is that multiple computers sharing the same address will cause problems, preventing them from connecting to the internet.

On Windows 11, you can set a static IP address configuration from the Settings app for wireless and wired adapters.

Set static IP address on Wi-Fi adapter

To assign a static IP address configuration to a Wi-Fi adapter, use these steps:

Open Settings on Windows 11.

Click on Network & Internet .

Click the Wi-Fi tab.

Open Wi-Fi settings

Select the current network connection.

Open wireless properties

Under the “IP settings” section, click the Edit button.

Windows 11 edit IP address

Select the Manual option.

Static IP enable option

Turn on the IPv4 toggle switch.

Set a static IP address for Windows 11 – for example, 10.1.4.119 .

Settings app set static IP address

Specify a Subnet mask  – for example, 255.255.255.0 .

Specify a Default Gateway address.

Specify a Preferred DNS address (required).

(Optional) Specify an “Alternate DNS” address.

Use the “DNS over HTTPS” drop-down menu and select the Off option for the preferred and alternate addresses, but you can enable DoH with these options:

  • Off: Transmits all DNS traffic without encryption.
  • On (automatic template): Sends all DNS traffic with encryption.
  • On (manual template): Allows you to specify a specific template. It is only required if the DNS service doesn’t work automatically or has a template that works as expected.

Turn off the “Fallback to plaintext” toggle switch (if you enable DoH).

Click the Save button.

Once you complete the steps, the static network configuration will apply to the computer. You can test the new settings by opening the web browser and loading a website.

Set static IP address on Ethernet adapter

To assign a static IP address to an Ethernet (wired) adapter on Windows 11, use these steps:

Open Settings .

Click the Ethernet  tab.

Open Ethernet settings

After you complete the steps, you can test your settings using your web browser to open a website.

On Windows 11, you can still use Control Panel to change the IP settings for Ethernet or Wi-Fi adapters.

To assign a static IP configuration through the Control Panel, use these steps:

Open Control Panel .

Click on Network and Internet .

Click on  Network and Sharing Center .

Click the Change adapter settings option on the left navigation pane.

Open Change adapter settings

Right-click the network adapter and select the Properties option.

Select the “Internet Protocol Version 4 (TCP/IPv4)” option.

Click the Properties button.

Control Panel open TCP/IPv4 properties

Select the “Use the following IP address” option.

Assign the static IP address – for example, 10.1.4.119 .

Set static IPv4 address in Control Panel

Specify a Subnet mask . Typically, on a home network, the subnet mask is 255.255.255.0 .

Specify a Default gateway address – for example, 10.1.4.1 (Usually, your router’s address).

Under the “Use the following DNS server addresses set Preferred DNS server” section, set the “Preferred DNS server address,” which is usually your router’s IP address or server IP address providing DNS resolutions (for example, 10.1.4.1 ).

(Optional) Specify an “Alternative DNS server,” which the computer will use if it cannot reach the preferred DNS server.

Click the OK button.

Click the Close button again.

Once you complete the steps, you can open the web browser and load a website to see if the configuration works.

If you want to revert the changes, you can use these instructions to remove the static settings to configure a dynamic IP address on Windows 11.

Avatar for Mauro Huculak

Mauro Huculak is a Windows How-To Expert who started Pureinfotech in 2010 as an independent online publication. He has also been a Windows Central contributor for nearly a decade. Mauro has over 14 years of experience writing comprehensive guides and creating professional videos about Windows and software, including Android and Linux. Before becoming a technology writer, he was an IT administrator for seven years. In total, Mauro has over 20 years of combined experience in technology. Throughout his career, he achieved different professional certifications from Microsoft (MSCA), Cisco (CCNP), VMware (VCP), and CompTIA (A+ and Network+), and he has been recognized as a Microsoft MVP for many years. You can follow him on X (Twitter) , YouTube , LinkedIn and About.me . Email him at [email protected] .

  • How to delete network folder with thumbs.db file on Windows 10
  • How to enable new energy and battery usage settings on Windows 11

We hate spam as much as you! Unsubscribe any time Powered by follow.it ( Privacy ), our Privacy .

  • Trending Now
  • Foundational Courses
  • Data Science
  • Practice Problem
  • Machine Learning
  • System Design
  • DevOps Tutorial

Setting IP Address Using ipconfig Command

  • Setting IP Address Using GUI
  • Setting IP Address Using DHCP Server
  • How to Find Your IP Address in Linux | ifconfig Command
  • Perl | Extract IP Address from a String using Regex
  • addresses Command in Linux with Examples
  • Setting Static IP Address in Windows
  • How to Get Local IP Address of System using PHP ?
  • Spoofing IP address when web scraping using Python
  • Configure IP Address For an Interface in Cisco
  • Structure and Types of IP Address
  • IP address finder app using ReactJS
  • Validate an IP address using Python without using RegEx
  • Extract IP address from file using Python
  • Cisco Switch Configuration basic commands
  • How To See the IP Address of a URL?
  • Working with IP Addresses in Python
  • How to find IP address information using R
  • Pinging an IP address in Java | Set 1
  • Python program to find IP Address

Setting up an IP address using the ipconfig command is a simple process that can be performed from any computer with an internet connection. This article aims to provide a step-by-step guide on setting up an IP address using the default gateway and the DNS server. This can be useful if you cannot access the internet or need to change your IP address. It is also useful if you are unsure of what your current IP address is.

Steps to Configure IP address in devices using ipconfig command in Cisco packet tracer:

Step 1: Open the Cisco packet tracer desktop and create a network topology peer-to-peer connection between two PCs as shown below:

assign ip using cmd

Step 2: Configure PC0 and PC1 using the ipconfig command:

  • First, click on PC0 and go to the command prompt terminal.
  • Then, type the ipconfig command and configure the PC0 as shown below the image.
  • and verify the IP address by again typing only ipconfig in the terminal.

assign ip using cmd

Similarly with PC1:

  • First, click on PC1 and go to the command prompt terminal.

assign ip using cmd

Step 3: Verifying connection by pinging the IP address of PC1 in the PC0 terminal:

assign ip using cmd

Please Login to comment...

Similar reads.

author

  • CCNA IP Addressing

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

Stack Exchange Network

Stack Exchange network consists of 183 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

How to change IP address using script on Windows?

I need fixed IP in three wireless networks I log in frequently.

It is a pain to set those IP and gateway everytime I change networks.

I am willing to write a script to change my IP and gateway between those 3 fixed IPs and a choice to make it get IP automatically (when I´m in another network).

A plus feature to my script would be if it could discover the wireless network I am logged in and decide the IP automatically.

Is it even possible?

Diogo's user avatar

  • possible duplicate of How can I switch between multiple sets of network configurations on Windows XP? –  Breakthrough Nov 24, 2011 at 12:43

5 Answers 5

ipconfig /renew to get a new IP address or default gateway The NETSH command does this. check this .

See this example for setting DNS address manually via netsh command:

configure your NIC to dynamically obtain its DNS settings ( * Obtain DNS server address automatically ):

and to set the * Obtain an IP address automatically setting:

More info: read this Configure TCP/IP from the Command Prompt and How to change IP address from command prompt .

This is assuming 3 things.

1) The network adapter you're trying to change the IP for is "local area connection". It could also be "local area connection 2" or "wireless network connection". Look in your control panel for the correct name.

2) The IP you want to set is 192.168.0.101, change this to whatever IP to want to use.

3) The default gateway and dns are the same IP. If you are using some kind of router they usually are. Change this to match your network config found with the command ipconfig /all

Here is example of batch file that I have created for your problem solutions: just change the command after the con1: type labels

How to create batch file: paste this code in notepad and save it as "test.bat"

Note: Change your connection names "local area connection" to your "wireless connection" name

Hope this help you.. for more reference check this Set Your IP Address Via Batch File

David d C e Freitas's user avatar

  • I get Adapter is not enabled for DHCP when trying ipconfig /renew "Wireless Network Connection" –  Hrvoje T Mar 28, 2018 at 8:10
  • I used this netsh interface ip set address "Wireless Network Connection" dhcp and this for auto dns netsh interface ip set dns "Wireless Network Connection" dhcp –  Hrvoje T Mar 28, 2018 at 8:26
  • 1 To set dns manualy, I had to use netsh interface ipv4 add dnsserver "Wireless Network Connection" address=8.8.8.8 index=1 from here stackoverflow.com/questions/18620173/… –  Hrvoje T Mar 28, 2018 at 9:10

You can make a .bat script file that contains the configuration commands based on "netsh" command, for example :

This changes the IP address and Default Gateway: "netsh int ip set address "local area connection" static {192.168.0.101} 255.255.255.0 {192.168.0.254} 1" This changes DNS: "netsh int ip set dns "local area connection" static {192.168.0.254} primary"

Community's user avatar

I know this is very old thread but still it can be useful to many like me.

As per the op asked for WiFi, I have created a batch script for Wi-Fi. It will fetch current Wi-Fi connected and based on that set Static IP or DHCP.

Here is the script -

You should save this a batch file and run that batch file as %% in for command will not work in command prompt.

TIP: You can also add this in Task Scheduler with Trigger as below and Action with above batch path

In Windows 10 & 11, you can set the IP configuration as well as DHCP / Static settings for each Saved WiFi network also.

Sachin's user avatar

Run this on CMD as admin:

back to dhcp:

"Local Area Connection" can be different in your case

Toto's user avatar

in this cmd how to set dns netsh interface ip set address name = "Local Area Connection" static 192.168.1.1 255.255.255.0

vijaiprabu's user avatar

  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center . –  Community Bot Nov 23, 2021 at 10:08

You must log in to answer this question.

Not the answer you're looking for browse other questions tagged windows-7 ..

  • The Overflow Blog
  • OverflowAI and the holy grail of search
  • The Good, the Bad, and the Disruptive: Let us know where you stand in the...
  • Featured on Meta
  • Our Partnership with OpenAI
  • What deliverables would you like to see out of a working group?

Hot Network Questions

  • Why do electric arcs rise?
  • Freewheel removal
  • API Generator for Python
  • депутат followed by a feminine name
  • Will the NTSB be involved in the investigation of the crash that killed the President of Iran?
  • Movie where the only survivor from a space colony or expedition is found and recovered by a ship. He turns out to be infected and turns evil
  • Does Dragonskin Armor Affect Ranger's Dual Wield?
  • Do particle & anti-particle pairs belong to the same field?
  • Extrusion of a parametric surface with different face and boundary colours
  • Does FIDE allow viewing how many IM/GM norms a player has?
  • What does an inclination of 0 degrees mean?
  • Clarification needed about my Schengen visa (CZ, DE, SK)
  • My other Mac mini's clipboard history has my laptop's clipboard history and it's freaking me out
  • Integral's computation does not match WolframAlpha result
  • Polarizing paper "almost good enough", but no revision offered
  • What happens to the ring singularities when two Kerr black holes merge?
  • Cubic splines in Cox model
  • I am a US citizen, my wife is Belgian. We intend to spend 6+ months in Italy. Do I need a visa?
  • Stellar Mass Black Holes and the companion star dynamics
  • Can I say "Rolex watches are astronomical", "astronomical" in the sense of "expensive"?
  • Can this 1930s box support a ceiling fan?
  • The older, the smarter. Is the wisdom of time a scientifically proven fact or just human prejudices?
  • Is it a problem to have a washing machine plugged into a GFCI outlet?
  • What pro-french paramilitary forces exist on New Caledonia?

assign ip using cmd

Tecmint: Linux Howtos, Tutorials & Guides

How to Use IP Command in Linux [24 Useful Examples]

Brief: In this guide, we will discuss some practical examples of the ip command. By the end of this guide, users will be able to perform networking tasks efficiently in Linux from the command line interface.

System administrators often need to perform networking tasks on Linux servers. There are a variety of graphical and command-line tools available in the market. However, most Linux users prefer to use the ip command due to its simplicity and rich functionality.

The ip command is a new networking command-line utility that is used to assign an IP address to a network interface or configure/update useful network variables on a Linux system.

It is a part of the iproute2 package and offers several network administration tasks such as bringing up or down network interfaces, assigning and removing IP addresses and routes, managing ARP cache, and much more.

The ip command is much similar to the old ifconfig command , but it is greatly more powerful with more functions and capabilities added to it.

[ You might also like: Deprecated Linux Networking Commands and Their Replacements ]

The ifconfig command has been deprecated and replaced by the ip command in all modern Linux distributions. However, the ifconfig command is still works and available for most Linux distributions .

[ You might also like: ifconfig vs ip: What’s Difference and Comparing Network Configuration ]

Table of Contents

Note: Please take a configuration file backup before doing any changes.

1. Permanently Configure Static IP Address in Linux

To permanently configure a static IP address in Linux, you need to update or edit the network configuration file to assign a static IP address to a system. You must be a superuser with a su (switch user) command from the terminal or command prompt.

Set Static IP Address in RHEL Systems

Open and edit the network configuration files for ( eth0 or eth1 ) using your favorite text editor . For example, assigning IP Address to eth0 interface as follows on RHEL-based distributions .

Configure Static IP in RHEL Systems

Set Static IP Address in Debian Systems

To configure the permanent static IP address, you need to modify your network interface configuration file /etc/network/interfaces to make permanent changes as shown below for Debian-based distributions .

Configure Static IP in Debian Systems

Next, restart network services after entering all the details using the following command.

[ You might also like: How to Configure Network Connection Using ‘nmcli’ Tool ]

2. Temporary Configure Static IP Address in Linux

For temporary network configurations, you can use the ip command to assign an IP address to a specific interface ( eth2 ) on the fly.

Note: Unfortunately all these settings will be lost after a system restart.

3. How to Display All Network Interfaces

In ip command , the link object represents the network interface. We can use the show command with it to display all network interfaces.

Now, let’s display all network interfaces using the following command:

Check IP Addresses of Network Interfaces

The above output shows the details of all network interfaces, such as interface name, flags, status, link address, broadcast address, etc.

4. How to Check an IP Address of a Specific Network Interface

To get the depth information of your individual network interface like IP Address, and MAC Address information, use the following command as shown below.

Check IP Address of Network Interface

So far, we used the link object shows detailed information about the network interfaces. However, it doesn’t show the IP address associated with the network interface. To overcome this limitation, we can use the addr object with the ip command.

Let’s understand this with an example.

Check IP Address of Interface

Here, we can see that, now output shows the IP addresses of all network interfaces along with other details.

To display the IP address of the individual network interface, just need to provide the network interface name as an argument to the command.

5. How to Display IP Address in Colored Output

The ip command shows detailed information about the network objects. However, sometimes we need to take a look at the limited information. In such cases, we can enable the colored output. This option highlights important details in different colors.

Let’s use the --color option of the command to display the output in different colors:

Show IP Address in Color Output

In the above output, we can see that the interface name, ethernet address, and state are highlighted in different colors.

6. How to Display IP Address in JSON Format

In the previous examples, we saw that the ip command shows meaningful information. However, it is not an easy task to parse the raw output and extract meaningful information using rudimentary scripts. In such cases, we can instruct the ip command to generate the output in a JSON format.

So, let’s use the -j option with the command to display the same output in a JSON format:

Show IP Address in JSON Format

This method comes in handy while doing automation because JSON is a widely accepted format and there are many JSON parser libraries/tools available in various programming languages.

7. How to Make JSON Output More Readable

In the previous example, we used the -j option to display output in a JSON format. This default JSON format is compact and space efficient. However, the output is not easy to read due to a lack of indentation.

To overcome this limitation, we can use the -p option which makes the output more readable by indenting it. Let’s understand this with the below example:

Show IP Address in Readable Format

Here, we can see that the same output is much more readable as compared to the previous examples.

8. How to Remove an IP Address From the Network Interface

In the previous example, we used the add sub-command to assign an IP address. In a similar way, we can use the del sub-command to remove a particular IP address.

The following command will remove an assigned IP address from the given interface ( eth2 ).

Now, let’s verify that the IP address has been removed:

Remove Network IP Address in Linux

In the above output, we can see that the now eth2 network interface has only one IP address.

9. How to Enable the Network Interface

The “ up ” flag with interface name ( eth2 ) enables a network interface. For example, the following command will activate the eth2 network interface.

Now, let’s check the updated status:

Enable Network Interface in Linux

10. How to Disable the Network Interface

The “ down ” flag with interface name ( eth2 ) disables a network interface. For example, the following command will De-activates the eth2 network interface.

Now, let’s check the status of the eth2 network interface:

Disable Network Interface in Linux

The above output shows the modified state of the network interface.

11. How to Flush IP Addresses of Network Interface

In the previous example, we saw how to use a del sub-command to remove an IP address. However, sometimes we need to remove all IP addresses of the particular network interface. In such cases, we can use the flush sub-command.

First, use the flush sub-command to remove all the IP addresses of the eth2 network interface:

Now, let’s check that all IP addresses of the eth2 network interface have been removed:

Flush Network IP Addresses in Linux

In the above output, the addr_info field shows the empty JSON array. This indicates there isn’t any IP address associated with the eth2 network interface.

12. How Do I Check Routing Table

A routing table stores the necessary information to forward a network packet to the correct destination. We can use the route object of the ip command to display the routing rules.

Let’s use the below command to list the all rules of the routing table:

Check Network Routing Table

In the above output, the first column represents the destination whereas the last column represents the source IP address.

13. How Do I Add New Static Route

Why do you need to add static routes or manual routes, because the traffic must not pass through the default gateway? We need to add static routes to pass traffic from the best way to reach the destination.

Now, let’s verify that the entry has been added successfully:

Add Network Route in Linux

15. How to Remove Static Route

The del sub-command removes a particular entry from the routing table. For example, the below command removes the entry of the eth2 device route:

Now, let’s verify that the entry has been removed successfully:

Remove Network Route in Linux

16. How Do I Add Permanent Static Routes

All the above routes will be lost after a system restart. To add a permanent static route, edit file /etc/sysconfig/network-scripts/route-eth2 (We are storing static route for ( eth2 ). By default, the route-eth2 file will not be there and need to be created.

Set Permanent Route in RHEL Systems

and add the following lines and save and exit.

Set Permanent Route in Debian Systems

Open the file /etc/network/interfaces and at the end add the persistence static routes. IP Addresses may differ in your environment.

17. How Do I Add the Default Gateway

In networking, the default gateway plays an important role. It gets used when the routing table doesn’t contain any information about the destination.

The default gateway can be specified globally or for interface-specific config files. The advantage of the default gateway is that we have more than one NIC present in the system. You can add the default gateway on the fly as shown below the command.

First, let’s add an eth0 network interface as a default gateway:

Now, let’s verify the default gateway setting using the following command:

Add Network Gateway in Linux

Please note that we have executed this command on a test machine. Be careful while using this command in the production environment.

18. How to Remove a Default Gateway

We can use the following command to remove the default gateway:

Now, let’s list the routing table to verify the default gateway has been removed:

Remove Network Gateway in Linux

19. How to Display ARP Cache

ARP stands for the Address Resolution Protocol , which is used to find the MAC address associated with the particular IP address.

We can use the neigh object with the ip command to display the ARP cache:

Check ARP Cache in Linux

In the above command, the neigh represents neighboring objects.

20. How to Add an ARP Entry

To create a new ARP entry, we can use the add sub-command with the neigh object.

Now, let’s list the ARP cache entries:

Add ARP Cache in Linux

In the above output, we can see the new entry for the eth2 network interface.

21. How to Remove an ARP Entry

Like other network objects, we can use the del sub-command to remove the ARP entry. For example, the below command removes the ARP entry of the eth2 network interface:

Now, let’s verify that the entry has been removed by listing the ARP cache:

Remove ARP Cache in Linux

22. How to Flush the ARP Entries

We can use the flush sub-command to remove multiple ARP entries. To understand this, first, add a few ARP entries with the STALE state:

Next, verify that the new entries have been added successfully:

Then, flush all the entries using the below command:

Finally, verify that all the entries have been removed:

Flush ARP in Linux

23. How to Set MTU for Network Interface

MTU stands for Maximum Transmission Unit , which represents the largest packet size that can be transmitted in a single transaction. We can manipulate the MTU size as per our performance requirements.

First, let’s find the MTU of the eth2 network interface:

Next, update the MTU size of the eth2 network interface to 3000 :

Finally, verify that the MTU has been updated successfully:

Set Network MTU in Linux

24. How to Change the Network Mac Address

The ip command allows us to change the MAC address of the network interface. To achieve this, we can use the set sub-command with the link object:

First, list the current MAC address of the eth2 network interface:

Next, change the MAC address of the network interface using the below command:

Finally, verify that the MAC address has been changed:

Change Network MAC Address in Linux

Please refer manual page doing man ip from the terminal/command prompt to know more about IP Command.

In this article, we discussed some common examples of the ip command . One can use these examples in day-to-day life to perform network administration.

Do you know of any other best example of the ip command in Linux? Let us know your views in the comments below.

Previous article:

Next article:

Photo of author

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Related Posts

Send Mail From Linux Terminal

Mutt – A Command Line Email Client to Send Mails from Terminal

dpkg Command Examples

15 Useful ‘dpkg’ Commands for Debian/Ubuntu Users

Advance Commands for Linux Experts

Sysadmins & DevOps: 20 Must-Know Advanced Linux Commands

Unmount USB Drive in Linux

How to Safely Eject a USB Drive in Linux

Make File and Directory Undeletable in Linux

How to Make File and Directory Undeletable, Even By Root in Linux

Understanding Different Linux Shell Commands

5 Different Types of Shell Commands and Their Usage in Linux

36 Comments

I have Debian buster on my laptop. It defaults to nm. But I used network/interfaces years ago.

Calm down. Netplan is not in charge yet here, in Ubuntu 18 bionic beaver desktop. We may also run into trouble with resolvconf.

grep ‘^ *renderer: *NetworkManager’ /etc/netplan/01-network-manager-all.yaml && { [do stuff] } || echo netplan has superseded NetworkManager here\, \”man netplan\”

Your info is deprecated. For example:

There is netplan in Ubuntu now.

To add permanent Static route, edit file /etc/sysconfig file. There is no /etc/sysconfig directory at all.

Do you know why Ubuntu has implemented netplan? Is it across all Debian distro’s?

We are quite rapidly heading towards 2 distinct branches of Linux; RH based for enterprise, and Ubuntu/Debian for developers.

I think you should ask Canonical about this but not me. I’m usually remove this and configuring network by networkd.

September 9, 2018, Ubuntu bionic beaver desktop, netplan is not in charge here:

grep ‘^ *renderer: *NetworkManager’ /etc/netplan/01-network-manager-all.yaml && { sudo /etc/init.d/networking stop sudo ip addr add 192.168.1.1/24 dev $eth1

} || echo netplan may be in charge\, \”man netplan\”

A big thank’s

Problem with setting static IP.

Done static route through GUI and on reboot I get no WAN. Also my “ eth0 ” shows up as “ enp2s0 ” not sure how it got that way. (wired only, wireless off, set IPv6 as Link Local Only) Does Linux Mint 18.3 require IPv6 to connect to WAN ? The only way to restore my network is set to Auto DHCP and restart.

Thank you .

Your process was clean and tidy and it worked.

May I ask: I have taken over a slightly mis-configured system in my new position, and found some ifcfg-*** files that have quotation marks around some of the parameters.

I am wondering if these quotes have an affect on the system, or if they are simply one persons preference?

Please see below:

I don’t find any problem with the quotes but wonder why they are there.

Thanks it’s really a useful tutorial. May I ask, how can i config wireless network in red hat 6?

Thanks for this great post, but may I have two questions, not related directly to your article, but I think you can help me.

1. How to change IP address to another IP “Say I am from Egypt and I need ip from USA”

2. Is there any way to know the current speed of my internet connection.

Looking for your reply, Mohamed Elhosary

Most welcome to ask any queries, we love to help you out, regarding your first question.

1. I didn’t understand what you mean here? I think you want to change IP address of the server? if yes read this article:

How to Set Static IP Address in Linux

2. There are tons of online speed test tools, one the most popular one is: http://www.speedtest.net/

Thanks for this, any chance you could write something to show how to set up home network, for noobs, when you are trying to access shares from a win 7 machine from a Linux machine?

Hi That was so practical and useful, thank you.

in my centos 6.5, I am using two interfaces. eth0 for public ip and eth1 private ip. I have made default gateway to public ip. But for other purpose, I need private ip for connetion to other system.

I have added static routes but they are lost when system reboots. So I add persistent route

# vi /etc/sysconfig/network-scripts/route-eth1 192.168.20.0/24 via 192.168.50.100 dev eth1

when I save this , then the system indicates that eth1 is disconnected. Any suggestion?

To keep this route at system boot you should add this entry to /etc/rc.local file, this file executes when system boots so whatever you add this will auto start at system reboot..

Very good article. Could you please suggest me on the following ?

I have a requirement where I have a Ubuntu system and many devices wants to talk to this and this system wants to talk to them. Some are having different subnet though they are connected to same layer-2 switch. I am in dilemma, whether to use ip aliasing or vlan. Any suggestion please.

Thanks, Subbarao

@Venkata, Better I suggest you to assign same network range to all machines or either do a routing..

Hi Sir! i have follow by your command line successful , i’m so thank you so much !! :D

Very usefull post ;-)

Compact size tutorial – good work! I used it once already. Thanks.

great tutorial

Very good article with simple steps

hello, thank you for tutorial that you & your team made they are so good please i have a problem i have already a public @ IP assigned to my dedicated server but i bought another failover @ip please how can i add it to my dedicated server so i can assign to it a domain name

Best regards,

PS: my interface file : # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5).

# The loopback network interface auto lo iface lo inet loopback

# The primary network interface auto em1 iface em1 inet dhcp

Ubuntu 14.04.1

In your instructions above, the first time you mention to restart the network services you have:

# /etc/init.d/networking restart

$ sudo /etc/init.d/networking restart

This should be

# /etc/init.d/network restart

$ sudo /etc/init.d/network restart

like you have near the end of the article.

I noticed that these two commands behave differently:

ip link set eth0 down & ip link set dev eth0 down

When dev is not used, the link state is brought down and stays down. Otherwise it will come up again soon after executing the command. The difference between the commands does not appear to be documented anywhere. Would you happen to know exactly what happens when running the commands and where the difference in behaviour stems from?

great article as always

but quick question thou what’s the difference between ifup and ip link set ???

Bro, ifup command is used to up network interface and ip command is used to assign IP address, Netmask, Gateway etc..

hello, can we tweak keyboard keys at user level. we use Redhat 5.9 64 bit workstations. For example i want Num Lock as Tab & so on…..

Thanks in advance

Nice one…

Okk if some one change my ip address ,subnet mask or try to play with it can i view the trail logs or anything simillar ????

Use history command to view last executed commands.

My static ipv4 address was not showing on eth0 but it is showing on ifconfig… I want to change my ip address how it is possible without eth0.

Superb article……

Great article first of all !

This command is very much similar to “IFCONFIG”. “sudo ifconfig eth1 up” replaced by “sudo ip link set eth1 up”.

That’s really cool !

provide tips for gcov and lcov in linux

Never heard about these tools, but we do try our best to provide you an how-to soon. Please stay updated..

Got Something to Say? Join the Discussion... Cancel reply

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.

Save my name, email, and website in this browser for the next time I comment.

  • Skip to content
  • Skip to search
  • Skip to footer

Support & Downloads

  • Worldwide - English
  • Arabic - عربي
  • Brazil - Português
  • Canada - Français
  • China - 简体中文
  • China - 繁體中文 (臺灣)
  • Germany - Deutsch
  • Italy - Italiano
  • Japan - 日本語
  • Korea - 한국어
  • Latin America - Español
  • Netherlands - Nederlands">Netherlands - Nederlands
  • Helpful Links
  • Licensing Support
  • Technology Support
  • Support for Cisco Acquisitions
  • Support Tools
  • Cisco Community

assign ip using cmd

To open or view a case, you need a service contract

Get instant updates on your TAC Case and more

Login Required

Contact TAC by Phone

800-553-2447 US/Canada

866-606-1866 US/Canada

  • Returns Portal

Products by Category

  • Unified Communications
  • Networking Software (IOS & NX-OS)
  • Collaboration Endpoints and Phones

Status Tools

The Cisco Security portal provides actionable intelligence for security threats and vulnerabilities in Cisco products and services and third-party products.

Get to know any significant issues, other than security vulnerability-related issues, that directly involve Cisco products and typically require an upgrade, workaround, or other customer action.

Check the current status of services and components for Cisco's cloud-based Webex, Security and IoT offerings.

The Cisco Support Assistant (formerly TAC Connect Bot) provides a self-service experience for common case inquiries and basic transactions without waiting in a queue.

Suite of tools to assist you in the day to day operations of your Collaboration infrastructure.

The Cisco CLI Analyzer (formerly ASA CLI Analyzer) is a smart SSH client with internal TAC tools and knowledge integrated. It is designed to help troubleshoot and check the overall health of your Cisco supported software.

My Notifications allows an user to subscribe and receive notifications for Cisco Security Advisories, End of Life Announcements, Field Notices, and Software & Bug updates for specific Cisco products and technologies.

More Support

  • Partner Support
  • Small Business Product Support
  • Business Critical Services
  • Customer Experience
  • DevNet Developer Support
  • Cisco Trust Portal

Cisco Communities

Generate and manage PAK-based and other device licenses, including demo licenses.

Track and manage Smart Software Licenses.

Generate and manage licenses from Enterprise Agreements.

Solve common licensing issues on your own.

Software and Downloads

Find software bugs based on product, release and keyword.

View Cisco suggestions for supported products.

Use the Cisco Software Checker to search for Cisco Security Advisories that apply to specific Cisco IOS, IOS XE, NX-OS and NX-OS in ACI Mode software releases.

Get the latest updates, patches and releases of Cisco Software.

assign ip using cmd

TecAdmin

How to Configure Static IP Address on Ubuntu 24.04

The Ubuntu team has once again kept their promise and released a new long-term support version, Ubuntu 24.04 (Noble Numbat), which comes with many great features. After installing it, setting up the network interface is an important first step for users. Usually, the system automatically gets an IP address from DHCP, but sometimes you might need to set up a static IP address. A static IP address does not change even when the system restarts, which is very helpful for managing networks and running servers.

This guide will show you how to set up a static IP address on Ubuntu 24.04, whether you are using the desktop environment or managing servers using the command line.

Introduction

A static IP address is set up manually on a computer to make sure it stays the same, unlike dynamic IP addresses that a DHCP server assigns and can change. Static IPs are commonly used for servers, network printers, and other devices that need to be consistently reachable over the network.

Requirements

  • A machine running Ubuntu 24.04 (Noble Numbat).
  • Basic familiarity with the system’s terminal and network configuration files.
  • Administrative (sudo) privileges.

Setting Up a Static IP in Ubuntu 24.04 Desktop Environment

Ubuntu 24.04 continues to use GNOME as its default desktop environment, which provides an intuitive interface for managing network settings. Follow the below steps to configure static IP address on your Ubuntu desktop system.

Step 1: Access Network Settings

  • Click on the icons at the top right corner of the screen.

Setting Up IP Address on Ubuntu 24.04

Step 2: Configure IP address

  • In the settings menu, go to the IPv4 tab.
  • Toggle the IPv4 Method to Manual.
  • Enter your desired IP address, netmask (often 255.255.255.0), and gateway.
  • Add DNS servers if necessary.

Setting Up IP Address on Ubuntu 24.04

Step 3: Apply Configuration

Click Apply button to save your settings. This will automatically update your system ip address. Wait for a to apply the changes. Then you can check updated IP address in details tab.

Setting Up a Static IP in Ubuntu 24.04 using Command Line Interface

If you like using the command line or need to set up a server without a graphical interface, the command line method is easy and effective.

Step 1: Open Terminal

You can open the terminal by pressing Ctrl + Alt + T or by looking for ‘Terminal’ in the applications menu.

Step 2: Identify Your Network Interface

Type the command ip link to see all network interfaces.

Find the interface you want to set up, like eth0 for a wired connection or wlan0 for wireless.

Step 3: Edit Netplan Configuration

Ubuntu 24.04 uses Netplan to manage network settings. Find the Netplan configuration files in /etc/netplan/. Open a file with a text editor, for example, type:

Step 4: Configure Static IP

Change the file to add your static IP details. For instance:

Switch eth0 with your network interface and adjust the IP settings as needed.

Step 5: Apply Changes

Save the file and update the changes with sudo netplan apply.

Check the new settings with ip addr show or by pinging another device.

Whether you like a graphical interface or the command line, setting up a static IP address in Ubuntu 24.04 (Noble Numbat) is easy. This setup can make your network more reliable and easier to access. Always test your settings to make sure the network works as you expect.

Related Posts

How to clone git tags, how to resolve error 1040 (08004): too many connections in mysql.

Ubuntu 24.10 (Oracular Oriole)

Ubuntu 24.10 Codename and What It Means

Save my name, email, and website in this browser for the next time I comment.

Type above and press Enter to search. Press Esc to cancel.

Change the hostname of your AL2 instance

When you launch an instance into a private VPC, Amazon EC2 assigns a guest OS hostname. The type of hostname that Amazon EC2 assigns depends on your subnet settings. For more information about EC2 hostnames, see Amazon EC2 instance hostname types in the Amazon EC2 User Guide for Linux Instances .

A typical Amazon EC2 private DNS name for an EC2 instance configured to use IP-based naming with an IPv4 address looks something like this: ip-12-34-56-78.us-west-2.compute.internal , where the name consists of the internal domain, the service (in this case, compute ), the region, and a form of the private IPv4 address. Part of this hostname is displayed at the shell prompt when you log into your instance (for example, ip-12-34-56-78 ). Each time you stop and restart your Amazon EC2 instance (unless you are using an Elastic IP address), the public IPv4 address changes, and so does your public DNS name, system hostname, and shell prompt.

This information applies to Amazon Linux. For information about other distributions, see their specific documentation.

Change the system hostname

If you have a public DNS name registered for the IP address of your instance (such as webserver.mydomain.com ), you can set the system hostname so your instance identifies itself as a part of that domain. This also changes the shell prompt so that it displays the first portion of this name instead of the hostname supplied by AWS (for example, ip-12-34-56-78 ). If you do not have a public DNS name registered, you can still change the hostname, but the process is a little different.

In order for your hostname update to persist, you must verify that the preserve_hostname cloud-init setting is set to true . You can run the following command to edit or add this setting:

If the preserve_hostname setting is not listed, add the following line of text to the end of the file:

To change the system hostname to a public DNS name

Follow this procedure if you already have a public DNS name registered.

For AL2: Use the hostnamectl command to set your hostname to reflect the fully qualified domain name (such as webserver.mydomain.com ).

For Amazon Linux AMI: On your instance, open the /etc/sysconfig/network configuration file in your favorite text editor and change the HOSTNAME entry to reflect the fully qualified domain name (such as webserver.mydomain.com ).

Reboot the instance to pick up the new hostname.

Alternatively, you can reboot using the Amazon EC2 console (on the Instances page, select the instance and choose Instance state , Reboot instance ).

Log into your instance and verify that the hostname has been updated. Your prompt should show the new hostname (up to the first ".") and the hostname command should show the fully-qualified domain name.

To change the system hostname without a public DNS name

For AL2: Use the hostnamectl command to set your hostname to reflect the desired system hostname (such as webserver ).

For Amazon Linux AMI: On your instance, open the /etc/sysconfig/network configuration file in your favorite text editor and change the HOSTNAME entry to reflect the desired system hostname (such as webserver ).

Open the /etc/hosts file in your favorite text editor and change the entry beginning with 127.0.0.1 to match the example below, substituting your own hostname.

You can also implement more programmatic solutions, such as specifying user data to configure your instance. If your instance is part of an Auto Scaling group, you can use lifecycle hooks to define user data. For more information, see Run commands on your Linux instance at launch and Lifecycle hook for instance launch in the AWS CloudFormation User Guide .

Change the shell prompt without affecting the hostname

If you do not want to modify the hostname for your instance, but you would like to have a more useful system name (such as webserver ) displayed than the private name supplied by AWS (for example, ip-12-34-56-78 ), you can edit the shell prompt configuration files to display your system nickname instead of the hostname.

To change the shell prompt to a host nickname

Create a file in /etc/profile.d that sets the environment variable called NICKNAME to the value you want in the shell prompt. For example, to set the system nickname to webserver , run the following command.

Open the /etc/bashrc (Red Hat) or /etc/bash.bashrc (Debian/Ubuntu) file in your favorite text editor (such as vim or nano ). You need to use sudo with the editor command because /etc/bashrc and /etc/bash.bashrc are owned by root .

Edit the file and change the shell prompt variable ( PS1 ) to display your nickname instead of the hostname. Find the following line that sets the shell prompt in /etc/bashrc or /etc/bash.bashrc (several surrounding lines are shown below for context; look for the line that starts with [ "$PS1" ):

Change the \h (the symbol for hostname ) in that line to the value of the NICKNAME variable.

(Optional) To set the title on shell windows to the new nickname, complete the following steps.

Create a file named /etc/sysconfig/bash-prompt-xterm .

Make the file executable using the following command.

Open the /etc/sysconfig/bash-prompt-xterm file in your favorite text editor (such as vim or nano ). You need to use sudo with the editor command because /etc/sysconfig/bash-prompt-xterm is owned by root .

Add the following line to the file.

Log out and then log back in to pick up the new nickname value.

Change the hostname on other Linux distributions

The procedures on this page are intended for use with Amazon Linux only. For more information about other Linux distributions, see their specific documentation and the following articles:

How do I assign a static hostname to a private Amazon EC2 instance running RHEL 7 or Centos 7?

Warning

To use the Amazon Web Services Documentation, Javascript must be enabled. Please refer to your browser's Help pages for instructions.

Thanks for letting us know we're doing a good job!

If you've got a moment, please tell us what we did right so we can do more of it.

Thanks for letting us know this page needs work. We're sorry we let you down.

If you've got a moment, please tell us how we can make the documentation better.

IMAGES

  1. How To Assign IP Address Using CMD in WIndows 10

    assign ip using cmd

  2. Assign IP address to your computer using cmd

    assign ip using cmd

  3. CMD : How to Find Your Public IP Addresses with 1 command

    assign ip using cmd

  4. Setting IP Address Using ipconfig Command

    assign ip using cmd

  5. How to Assign IP Address in your computer using CMD

    assign ip using cmd

  6. How To Assign IP Address Step by Step Using CMD (prompt) in Windows 10

    assign ip using cmd

VIDEO

  1. LoL : How to get IP using tribunal

  2. how to find local IP using CMD

  3. How to Trace ip address through cmd

  4. 🎭CMD: Know Your IP ADDRESS And NET INFO

  5. PanDrive ko CMD command se bootable kaise banaya Windows 10 me

  6. How To Manually Assign IP Adress In Windows XP

COMMENTS

  1. How to Change Your IP Address From the Command Prompt in Windows

    View Your Network Information with Command Prompt. Before you change your IP address and related information, you'll need to find the full name of the network for the interface you want to change. To do this, type the following command: netsh interface ipv4 show config. Scroll down until you see the interface you're looking for.

  2. How To Set Static IP Address in Windows 10 using CMD

    Using CMD may seem difficult for some users, yet it is one of the fastest ways to assign a static IP address in Windows 10. Step 1: There are two ways to open the command line. Click on the Start menu, type CMD in the search box, then right-click on it and select Run as administrator.

  3. How to Configure Windows 10 IP Address with CMD?

    To find your IP address on Windows 10, just type " ipconfig " in command prompt. To do this process: Press Windows+R keys to open the Run. Type " cmd " in the run and press enter. Now type " ipconfig " to show the IP address. The " ipconfig " command shows everything about your computer network interfaces.

  4. Configure TCP/IP from the Command Prompt

    In order to configure TCP/IP settings such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses and many other options you can use Netsh.exe. Netsh.exe is a command-line ...

  5. How to Change IP Address in Command Prompt (Renew IP)

    Right-click on the Command Prompt and select the " Run as administrator " option. Execute the below command to get the network interface name. netsh interface ipv4 show config. If you have multiple network interfaces, note down the interface name for which you want to change the IP address.

  6. How to change the IP address in Windows 10 and Windows 11 (4 ways)

    In both Windows 11 and Windows 10, you can also change your IP address from the Control Panel. Open the Control Panel and click or tap on "View network status and tasks" under "Network and Internet.". In the Network and Sharing Center, click or tap on your internet connection from the "View your active networks" area.

  7. How to configure a static IP on Windows 10 or 11

    To set a static TCP/IP configuration on Windows 11, use these steps: Open Start. Search for Command Prompt, right-click the top result, and select the Run as administrator option. Type the ...

  8. Change IP Address and DNS Servers using the Command Prompt

    The first step to changing your IP address is to find the network name for the interface you want to change. Open an elevated Command Prompt by typing CMD in the search bar and clicking on Run as Administrator. Next, type netsh interface ipv4 show config in the command prompt window, press Enter, and scroll down to the interface you want.

  9. How to Set a Static IP Address on a Windows PC

    Type in the following command to set up a static IP address and hit Enter: New-NetIPAddress -InterfaceIndex 10 -IPAddress 10.1.4.119 -PrefixLength 24 -DefaultGateway 10.1.4.1. Here, replace all values of information. Replace the InterfaceIndex number (10) with the number assigned to your adapter.

  10. How to set static IP address on Windows 10

    Set static IP address on Windows 10 from Settings. To assign a static IP address on Windows 10, use these steps: Open Settings on Windows 10. Click on Network & Internet. Click on "Wi-Fi" or "Ethernet.". Click on the current network connection. Under the "IP settings" section, click the Edit button. Using the drop-down menu, select ...

  11. How to Set Up a Static IP Address

    10 minutes. TOOLS. Windows 10 or 11. Step 1: Open the Command Prompt. Your first step should be to track down your computer's current IP address, subnet mask, and default gateway. Do this by ...

  12. How to set static IP address and DNS Server using Command ...

    How to set static IP address using Command Prompt. These commands are relatively easier with the Command Prompt when compared with PowerShell. You can change the IP address of your computer using this quick command. Launch the Command Prompt with administrative privileges and then use the command below to assign the desired IP address ...

  13. How to Set a Static IP Address on Windows

    Click "Properties" next to your Wi-Fi network on the right. Scroll down and click the "Edit" button next to "IP assignment.". Click the drop-down box in the "Edit network IP settings" dialog, and select "Manual.". Select the IPv4 or IPv6 format to set the static IP address. In this example, we are selecting IPv4.

  14. Configure Static IP with the Netsh Command-Line Utility

    Here's how to configure a static IP address: netsh interface ip set address "connection name" static 192.168..101 255.255.255. 192.168..1. NOTE: The default connection names are Local Area Connection for wired adapters and Wireless Network Connection for Wi-Fi adapters. The IP address order: client IP, subnet mask, and gateway IP.

  15. How to change from static to dynamic IP address on Windows 10

    To enable DHCP to obtain a TCP/IP configuration automatically on Windows 10, use these steps: Open Settings on Windows 10. Click on Network & Internet. Click on Ethernet or Wi-Fi. Click the network connection. Under the "IP settings" section, click the Edit button. Use the Edit IP settings drop-down menu and select the Automatic (DHCP) option.

  16. How to Set up an IP Address using CMD: A Step-by-Step Guide

    Step 2: Identify available network interfaces. Once the Command Prompt is open, you need to identify the network interface for which you want to set up the IP address. To do this, type the following command and press Enter: A list of network interfaces will be displayed. Look for the one that corresponds to your network adapter or device.

  17. How to set a static IP address on Windows 11

    To set a static IP address on Windows 11 with Command Prompt, use these steps: Open Start on Windows 11. Search for Command Prompt, right-click the top result, and select the Run as administrator option. Type the following command to see your current networking configuration and press Enter: ipconfig /all.

  18. Setting IP Address Using ipconfig Command

    192.168..1. Step 2: Configure PC0 and PC1 using the ipconfig command: command : ipconfig <ip address> <subnet mask> <default gateway>. First, click on PC0 and go to the command prompt terminal. Then, type the ipconfig command and configure the PC0 as shown below the image. and verify the IP address by again typing only ipconfig in the terminal.

  19. Windows IP Commands

    ping -a [IP address]:The -a switch tells the computer to try to find the hostname assigned to the specific IP address and then ping the IP. ping -6 [domain or IP]:The -6 switch tells the computer to send IPv6 packets to the target. tracert command "tracert" in Windows stands for "Trace Route". In Linux, the same command is "traceroute".

  20. How to change IP address using script on Windows?

    ipconfig /renew to get a new IP address or default gateway The NETSH command does this. check this.. See this example for setting DNS address manually via netsh command:. netsh interface ip set dns "Local Area Connection" static 192.168..200 configure your NIC to dynamically obtain its DNS settings (* Obtain DNS server address automatically):netsh interface ip set dns "Local Area Connection" dhcp

  21. 24 Useful "IP" Commands to Configure Network Interfaces

    For temporary network configurations, you can use the ip command to assign an IP address to a specific interface ( eth2) on the fly. # ip addr add 172.19.1.10/24 dev eth2. OR. $ sudo ip addr add 172.19.1.10/24 dev eth2. Note: Unfortunately all these settings will be lost after a system restart. 3.

  22. Linux Ip Command: An Ultimate Guide With Practical Examples

    The ip command is a relatively recent networking command-line utility for assigning IP addresses and modifying network variables on Linux systems. ... You can use the ip command to view the status for all network interfaces (like transferred or dropped packets, and errors). We recommend the following command in this context:

  23. Support

    Check the current status of services and components for Cisco's cloud-based Webex, Security and IoT offerings. Cisco Support Assistant. The Cisco Support Assistant (formerly TAC Connect Bot) provides a self-service experience for common case inquiries and basic transactions without waiting in a queue.

  24. How to Configure Static IP Address on Ubuntu 24.04

    Step 1: Access Network Settings. Click on the icons at the top right corner of the screen. Click the > icon next to Wired or Wireless connection. Click the (Wired) Settings option as shown in screenshot. This will show you the current IP address with other network details. Click the gear icon in front of them:

  25. Guide to Linux ip Command With Examples

    IP is the abbreviation for Internet Protocol in networking. Like the ifconfig utility, the ip command is a network utility specifically designed for managing Linux system networks.. The main goal of the ip command is to configure different network interfaces.In this tutorial, we'll use the ip command with various available options.. 2. Syntax of ip Command

  26. Change the hostname of your AL2 instance

    webserver.mydomain.com. To change the system hostname without a public DNS name. For AL2: Use the hostnamectl command to set your hostname to reflect the desired system hostname (such as webserver ). [ec2-user ~]$ sudo hostnamectl set-hostname webserver.localdomain.