To change your IP address using the command line (cmd) on a Windows system, you typically use the netsh
command. This command allows you to configure almost any aspect of your network settings, including setting a static IP address. Here’s a general guide on how to do it:
-
Open Command Prompt with Administrative Rights:
- You can do this by searching for “cmd” in the Start menu, right-clicking on “Command Prompt”, and selecting “Run as administrator”.
-
Check Your Current Network Configuration:
- Type
ipconfig /all
and press Enter. This will display all your network configuration details. Note the name of the network adapter you want to configure.
- Type
-
Set a Static IP Address:
- Use the following command structure to set a new IP address:
netsh interface ip set address "Adapter Name" static IP_Address Subnet_Mask Default_Gateway
- For example:
netsh interface ip set address "Ethernet" static 192.168.1.100 255.255.255.0 192.168.1.1
- Replace “Ethernet” with the name of your network adapter, and adjust the IP address, subnet mask, and default gateway according to your network requirements.
- Use the following command structure to set a new IP address:
-
Set DNS Servers (optional):
- If you want to specify DNS servers, use:
netsh interface ip set dns "Adapter Name" static Primary_DNS
- To add a secondary DNS server:
netsh interface ip add dns "Adapter Name" Secondary_DNS index=2
- For example:
netsh interface ip set dns "Ethernet" static 8.8.8.8 netsh interface ip add dns "Ethernet" 8.8.4.4 index=2
- If you want to specify DNS servers, use:
Note: Make sure to replace the placeholder values with the actual values suitable for your network. Also, using a static IP address requires ensuring that the IP address is not in use and fits within your network's IP address range. You might need to consult with your network administrator if you're part of a larger network (like a company or an educational institution) to avoid any conflicts.
If you're looking to simply renew your IP address (to change your DHCP-assigned IP), you can release and renew your IP address using the following commands:
- Release the current DHCP configuration:
ipconfig /release
- Renew the IP configuration:
ipconfig /renew
These commands work with DHCP servers to automatically assign a new IP address to your machine.