How to create an IP Alias in Mac OS X using ifconfig

Aug 5, 2009 - 8 Comments

In some trickier network situations, you may be assigned an IP but need an entirely different IP address to access certain network resources, but how on earth do you have two IP addresses at once? Create an IP Alias! It’s easy to do with the Mac OS X command line utility ifconfig.

Type the following at the command line prompt to alias the new IP of 192.168.0.101 to your existing subnet mask
sudo ifconfig en0 alias 192.168.0.101 255.255.255.0

If you want to get rid of the alias, just type:
sudo ifconfig en0 -alias 192.168.0.101

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Command Line, How to, Mac OS X, Tips & Tricks

8 Comments

» Comments RSS Feed

  1. CrackTheMac says:

    Great tip especially with my screwy LAN but this is what worked for me:

    sudo ifconfig en0 alias 192.168.1.101 netmask 255.255.255.255

    might be a version thing so if the above doesn’t work try that (depending on your IP and netmask)

  2. This is so cool. Thanks for the tip.

  3. […] This post was Twitted by berneau25 […]

  4. Terrence Brown says:

    What do “trickier network situation” and “certain network resources” mean? Do they mean, “trickier network situation where you should be denied access but that won’t stop us from helping you access certain network resources normally forbidden to you because you either haven’t paid or haven’t the clearance?”

  5. Fox Mulder says:

    @Terrence Brown

    IP aliasing is the ability to add more than one IP address to a network interface or resource allowing a node on a network to have multiple connections to a network. For example, if a client or network resource uses DHCP and therefore has a dynamic (changing) IP address, another machine can connect to that client consistently by using an IP alias that will act as a static IP. This makes it so you adjust settings to connect to something like 10.0.0.10 reliably, rather than manually reentering the newly assigned and randomized dynamic address (10.0.0.7 etc). To an average computer user, you could call that a ‘trickier network situation,’ as you say.

    There’s nothing to pay for with IP Aliasing, it’s a free technology that’s been around in the networking and UNIX world for decades. It’s also widely used by Systems Administrators and IT professionals, which is why Apple has included it in their operating system.

  6. […] How to create an IP Alias in Mac OS X using ifconfig – create an IP Alias to make your LAN administration and general networking life easier […]

  7. Sean Wong says:

    Please note, this is a one time shot, not persistent. Should the server reboot/lose power you’ll have to do this again.

    The recommended way is to modify /etc/IPAliases.conf

    for any clarification, please man IPAliases.conf

    • Will says:

      That would be ideal, but as far as I can tell IPAliases.conf is only in Snow Leopard Server by default. I’m sure you could manually create the appropriate file and enable ipaliases in /etc/hostsconfig though I haven’t tested this.

      – Will

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates