I've been digging into Darwin source to try to find some way to create virtual Ethernet interfaces on Mac/Darwin without adding a kernel extension like tuntaposx. In doing so I've found something interesting that seems to exist but have zero documentation.

Here's the source file:


Reading the file leads me to think this is similar to a veth pair on Linux: create two interfaces and packets going into one pop out the other.

The only problem is that I can find nothing on the Internet about this.

I have been able to confirm that it exists as of OSX Mojave and assume they exist on older versions too:

# ifconfig feth0 create
  ether 66:65:74:68:00:00
  peer: <none>
  media: autoselect
  status: inactive

After looking some more I seem to have found an undocumented option in ifconfig to link two of these:

# ifconfig feth0 peer feth1
# ifconfig feth0
  ether 66:65:74:68:00:00
  inet netmask 0xffffff00 broadcast
  peer: feth1
  media: autoselect
  status: active

Now when I add an IP to feth0 and tcpdump feth1, I see a bunch of packets that are things like mDNS announcements that you would expect a Mac to spew into a new Ethernet link.

I'm posting this here because I'm curious about whether anyone else has any clue about this or has ever used it.

Edit: I can now confirm that if you peer them and bring them both up (ifconfig feth0 up, etc.) you can inject packets into either side and see them in the other. It looks like this indeed could work as a layer 2 Ethernet tap device or virtual machine veth pair device without requiring a kernel extension. Not only is this awesome for network virtualization but paired with Apple's virtualization extensions it would also allow a kext-free VM host with full networking capabilities.

Edit #2: We also just found this, which is also not very well documented albeit much better than feth. It may offer a more officially supported way of creating virtual Ethernet devices. We'll have to see how it works. The feth stuff is still interesting though!


You must log in to answer this question.

Browse other questions tagged .