1

This question already has an answer here:

On Mac there is this command

sudo ifconfig lo0 alias 10.10.10.10

I need the equivalent in Windows.

What would it be? What do I need to look for exactly?

marked as duplicate by BrunoLM, Community Nov 22 '17 at 18:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

You need to do this from an elevated console, since Windows does not have a sudo:

netsh interface ip add address "Local Area Connection" 10.10.10.10 255.255.255.0

"Local Area Connection" may be different for you. To find the name you'll need to run:

ipconfig

And pull the network interface's name.

  • There are also two other ways (Loopback and GUI) but I figured you were looking for the command since you sited the iOS command. – Ian Pringle Nov 22 '17 at 13:32
  • When I run that it disables DHCP and changes my IP, which makes me lose internet connection. Is there a way I can keep DHCP and just this extra IP? What I want is for 10.10.10.10 to point to localhost. – BrunoLM Nov 22 '17 at 15:17
  • 1
    If your DHCP assigns IP addresses statically, then you will just need to add the assigned IP back. So if your system's local IP was 192.168.0.5, after assigning 10.10.10.10, then use the same command to assign your system 192.168.0.5 If it isn't static, you will need to update it when it reassigns. – Ian Pringle Nov 22 '17 at 16:45
  • That makes sense. I tested and it worked. However I think the unix command I posted doesn't require the user to add his own IP, they can just run the alias and have this extra IP... – BrunoLM Nov 22 '17 at 18:36
  • 1
    Since netsh is Windows specific it's not going to function the same as the alias does in *nix. The netsh command is disabling the DHCP, so you need to tell the PC what to look for. The *nix function might not disable, which would be why that isn't needed. Another option, though not built into Windows, would be to look and see if Cygwin has support for the *nix ipconfig. If it does, then you should be able to use the same command in Windows (after installing Cygwin). – Ian Pringle Nov 22 '17 at 18:47
0

You can do this from an elevated Command Prompt with the netsh utility:

netsh int ipv4 add address "Local Area Connection" 10.10.10.10 255.255.0.0

You need to replace "Local Area Connection" with the name of the network adapter and 255.255.0.0 with the appropriate subnet mask. You can view the system's network adapter names by running ipconfig.

More Information:

  • When I run that it disables DHCP and changes my IP, which makes me lose internet connection. Is there a way I can keep DHCP and just this extra IP? What I want is for 10.10.10.10 to point to localhost. – BrunoLM Nov 22 '17 at 15:16
  • You cannot mix static and dynamically (DHCP) address assignments on the same interface. However, your comment that you want to point localhost to an IP makes it appear you did not ask about the actual problem, but rather your proposed solution to the problem. You cannot change your existing question to correct this because it already has answers (that would not be correct for your new question). You should ask a new question, and of course it's fine to say "I tried using netsh like this... but it did not work" and reference this question. – Twisty Impersonator Nov 22 '17 at 18:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.