24

On linux boxes it is possible to add multiple ip addresses to the same network interface.

It's achived with the following command:

ip addr add 128.133.123.83/24 dev eth0

Is there any way to to the same with OS X ?

I've tried to put multiple ip addresses (comma separated like the dns) in System Preferences / Network with no luck...

4 Answers 4

29

Yeah, it's pretty easy. Open System Preferences, go to Networking, then click the Plus sign under the left bar. Choose the interface, give a name to the adapter configuration you're creating, then press OK. You will have to provide manual configuration of IP address and DNS for the second entry -- DHCP won't work for it, because it shares the same MAC address as the original entry, so the router won't issue it another address. Click Apply when you're done, and enjoy. Your adapter now has two IP addresses.

6
  • How can it make it work with a browser? I mean, I can ping or telnet using the new address, but I can't connect using the browser...
    – yeyeyerman
    Feb 26, 2016 at 11:32
  • You can reorder adapters in order of preference by dragging and dropping them.
    – zneak
    Feb 26, 2016 at 15:19
  • 1
    OK, it works both for Ethernet and WiFi, thanks! Nov 2, 2020 at 3:25
  • Does anyone know how to do this on Ventura? My adapter setting is still working, but I am not able to adjust the IP address anymore, as the interface has changed completely.
    – Simon
    Dec 6, 2022 at 10:04
  • @Simon, it seems to me this is accessible through Network preferences, selecting your interface, then clicking the Details button.
    – zneak
    Feb 11, 2023 at 7:08
28

sudo ifconfig en0 alias 128.133.123.83/24 up

and to remove...

sudo ifconfig en0 -alias 128.133.123.83

3
  • Does this stay between reboots? or does this need to be re-applied each boot? Jun 18, 2020 at 23:40
  • @deweydb it does not stay between reboots.
    – brablc
    Jun 19, 2020 at 4:54
  • if the second address is in the same subnet, it seems to need to be added as /32. See the man page for ifconfig and look for 'alias'. at least on monterey.
    – tladuke
    Feb 24, 2023 at 19:49
2

.. and to remove the alias added in brabic's answer

sudo ifconfig en0 -alias 128.133.123.83

3
  • This would make a nice edit to the other answer.
    – bmike
    Nov 24, 2019 at 0:44
  • yes - but i didn't have enough reputation to comment on the other answer :-(. working on it.. Nov 24, 2019 at 0:45
  • Click edit and make the changes - your content belongs in the body of the answer, not as a comment or a half answer
    – bmike
    Nov 24, 2019 at 1:28
0

I've tried this and worked for me. Since I have two Wi-Fi networks, one from work and another from home hot spot using my iPhone.

Go to network settings, add a service, then set interface to Wi-Fi and new name (three dot right down).

While your Wi-Fi is disconnected assign IP address to second Wi-Fi you have recently created.

You must log in to answer this question.

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