Terminal in macOSTerminal in macOS

In some trickier network situations, your computer may be assigned an IP but need an entirely different IP address to access certain network resources. You might be wondering, how on earth do you have two IP addresses at once on the same Mac? The answer; Create an IP Alias!

Using an IP alias allows your Mac to have more than one IP address at the same time, this can allow you to have multiple IP addresses that reference the same machine.

While this is fairly advanced topic, you will find that creating an IP alias is easy to do with the powerful Mac OS X command line utility ifconfig.

To get started, open the command line via Terminal app or your terminal of choice.

How to Create an IP Alias on the Mac via Command Line

Type the following at the command line prompt, this will alias the new IP of 192.168.0.101 to your existing subnet mask, on the en0 network interface:

sudo ifconfig en0 alias 192.168.0.101 255.255.255.0

The syntax therefore for creating an IP alias is as follows:

sudo ifconfig INTERFACE alias new.ip.address subnet.mask.address

You will need to use sudo which requires the root/admin password.

How to Remove the IP Alias

If you want to get rid of the alias, just type:

sudo ifconfig en0 -alias 192.168.0.101

This removes the specified alias at the specified network interface.

There are many uses for this great trick, give it a try yourself if you need multiple LAN IP references to the same machine.

Source

Follow Me:
Top Best Sellers!!