I need to create an alias for my network interface such that it can be accessed locally with either 127.0.0.1 or 33.33.33.33.
In *nix I would do this:
sudo ifconfig en1 inet 33.33.33.33/32 alias
It appears that the netsh
tool may be able to do the same thing. If so, how? I've seen some examples that seem close, but I don't understand the options provided.
The motivation for this is to run two instances of JBossAS on the same machine without port offsets. Thus, they would need to use the same port numbers without conflicting.
You'd be correct. Also, you can add multiple addresses without touching the command line using the advanced interface properties screen.
netsh interface ip add address "Local Area Connection" 33.33.33.33 255.255.255.255
It may depend on which version of Windows you have, but here are some steps from my Windows 7 machine. You want to get to your "local adapter settings". There are probably 1000 ways to do this, but here is one.
Another approach is to add the Microsoft Loopback adapter as a network device. This lets you set up a virtual network adapter on your machine. This can be useful for network testing from your own machine. See http://social.technet.microsoft.com/Forums/en-US/w7itpronetworking/thread/259c7ef2-3770-4212-8fca-c58936979851/ for more info.
There is a comment about how to add alias while still using DHCP for the main one. I have similar problem.
The solution is:
(1) Add Microsoft Loopback Adapter as a network device (taken from here):
From that point on it's the same approach as under Vista, i.e.:
(2) To see the newly added network interface, and specify an IP address:
go to C:\Windows\System32\drivers\etc\hosts on windows and add a new entry as below
eg: 106.200.247.101 abc.com
Then you will be able to refer to using given hostname
As pointed out above, when using a static IP address, the GUI provides a suitable way to achieve this. However...
You cannot add an alias in the GUI when using DHCP to get an address. The "netsh" command, however, is helpful to achieve this:
EDIT: The above statement used to be true, but at some point Microsoft quietly fixed the issue by adding a new setting. All credit to this answer.
Setting the property dhcpstaticipcoexistence
to enabled
solves the issue.
e.g. (Using a cmd or powershell as a user with local admin rights)
netsh interface ipv4 set interface interface="Interface Name" dhcpstaticipcoexistence=enabled
netsh interface ip add address "Interface Name" 192.168.2.2 255.255.255.0
This has to be done as an administrator.
Use "ipconfig" to check what the network interface is called. In my case it is "Local Area Connection".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With