views:

7115

answers:

7

I know that you can make a virtual network interface in Windows (see here), and in Linux it is also pretty easy with ip-aliases, but does something similar exist for Mac OS X? I've been looking for loopback adapters, virtual interfaces and couldn't find a good solution.

You can create a new interface in the networking panel, based on an existing interface, but it will not act as a real fully functional interface (if the original interface is inactive, then the derived one is also inactive).

This scenario is needed when working in a completely disconnected situation. Even then, it makes sense to have networking capabilities when running servers in a VMWare installation. Those virtual machines can be reached by their IP address, but not by their DNS name, even if I run a DNS server in one of those virtual machines. By configuring an interface to use the virtual DNS server, I thought I could test some DNS scenario's. Unfortunately, no interface is resolving DNS names if none of them are inactive...

+1  A: 

What do you mean by

"but it will not act as a real fully functional interface (if the original interface is inactive, then the derived one is also inactive"

?

I can make a new interface, base it on an already existing one, then disable the existing one and the new one still works. Making a second interface does however not create a real interface (when you check with ifconfig), it will just assign a second IP to the already existing one (however, this one can be DHCP while the first one is hard coded for example).

So did I understand you right, that you want to create an interface, not bound to any real interface? How would this interface then be used? E.g. if you disconnect all WLAN and pull all network cables, where would this interface send traffic to, if you send traffic to it? Maybe your question is a bit unclear, it might help a lot if rephrase it, so it's clear what you are actually trying to do with this "virtual interface" once you have it.

As you mentioned "alias IP" in your question, this would mean an alias interface. But an alias interface is always bound to a real interface. The difference is in Linux such an interface really IS an interface (e.g. an alias interface for eth0 could be eth1), while on Mac, no real interface is created, instead a virtual interface is created, that can configured and used independently, but it is still the same interface physically and thus no new named interface is generated (you just have two interfaces, that are both in fact en0, but both can be enabled/disabled and configured independently).

Mecki
+1  A: 

ifconfig interfacename create will create a virtual interface,

Brian Mitchell
Could you provide an example for that? If I try that, it does not work and has never worked as far as I know.
Mecki
I can confirm, it will not work
Hans Doggen
ifconfig vlan0 create as documented in the ifconfig man page"create Create the specified network pseudo-device. If the interface is given without a unit number, try to create a new device with an arbitrary unit number."
Brian Mitchell
It will not work as the vlan0 above cannot be made active (status) and so it will not receive any packets...
Hans Doggen
Well your question related a virtual interface, without any indication about what you wanted to do with it, which is specifically what I answered. This feature is for vlans, you can do something likeifconfig vlan0 vlan sometag vlandev en0ipconfig set vlan0 DHCPIf a vlan is your goal.
Brian Mitchell
A: 

I think that what Hans wants, and it is also what I'm looking for, is to create a virtual network, in which several virtual interfaces could be attached to it, and be accessed by the OS as real interfaces.

So you'd have a network which only existed within those virtual interfaces.

Has it ever been done?

João
+3  A: 

The loopback adapter is always up.

ifconfig lo0 alias 172.16.123.1 will add an alias IP 172.16.123.1 to the loopback adapter

ifconfig lo0 -alias 172.16.123.1 will remove it

This is correct for creating an alias, but to my knowledge you cannot define a DNS Server linked to the loopback adapter, so it will not work in my scenario as described above.
Hans Doggen
+2  A: 

It's possible to use TUN/TAP device. http://tuntaposx.sourceforge.net/

psv141
User yar made a similar suggestion through a blog post. I've looked at it, but I didn't test it out, because of lack of time and I don't have the need anymore. Nevertheless thanks.
Hans Doggen
A: 

i have resorted to running PFSense, a BSD based router/firewall to achieve this goal….

why? because OS X Server gets so FREAKY without a Static IP…

so after wrestling with it for DAYS to make NAT and DHCP and firewall and …

I'm trying this is parallels…

will let ya know how it goes...

alex gray
A: 

Take a look at this tutorial, it's for FreeBSD but also applies to OS X. http://people.freebsd.org/~arved/vlan/vlan_en.html

amonaco