Changing IP address via command line on Windows XP
Asked Answered
S

2

12

I'm trying to change a machine IP address via cmd.exe with this code:

netsh int ip set address name="Local Area Connection" source=static addr=???.???.???.??? mask=255.255.255.0

The problem that the IP doesn't change (checked by ipconfig) but doesn't not changed on the DHCP. Thus when I restart the machine, the IP is returned to DHCP.

I need a way to change the IP permanently via command line.

Any ideas?

Southard answered 26/3, 2012 at 7:14 Comment(1)
Please clarify logic in the part below netsh code.Aldwon
O
20

You can use the command below:

netsh interface ip set address name="Local Area Connection" static 192.168.0.100 255.255.255.0 192.168.0.1 1

where

  • the 192.168.0.100 is the IP address
  • the netmask is 255.255.255.0
  • and the gateway is 192.168.0.1

You can also have the DNS configured automatically by DHCP using following command:

netsh interface ip set dns "Local Area Connection" dhcp
Odysseus answered 27/3, 2012 at 14:21 Comment(2)
use ipconfig to list the gateway and netmaskSacculate
i get The requested operation requires elevationCoraciiform
C
1

If you are looking for change it regularly here is a trick :)

netsh interface ip set address name="Wi-Fi" static 192.168.1.140 255.255.255.0 192.168.1.1 // this change IP
netsh interface ip add dns name="Wi-Fi" 8.8.8.8 index=2 //this change DNS
pause

type above in notepad and save as ip.bat.
run the file as administrator

Civility answered 14/12, 2015 at 8:47 Comment(1)
This one actually works if you set the address name=“Wi-Fi” instead of “Local Area Connection”.Sherlynsherm

© 2022 - 2024 — McMap. All rights reserved.