1

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?

0

2 Answers 2

2

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.

5
  • There are also two other ways (Loopback and GUI) but I figured you were looking for the command since you sited the iOS command. Nov 22, 2017 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, 2017 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. Nov 22, 2017 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, 2017 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). Nov 22, 2017 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:

2
  • 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, 2017 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. Nov 22, 2017 at 18:16

Not the answer you're looking for? Browse other questions tagged .