Tun/Tap under macOS Sierra

Anything not about Mac emulation.

Moderators: Cat_7, Ronald P. Regensburg

Post Reply
User avatar
adespoton
Forum All-Star
Posts: 4279
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Tun/Tap under macOS Sierra

Post by adespoton »

OK; so I upgraded to Sierra today... and it appears my tap0 interface, while still appearing in /dev, is no longer there. I have tun.kext and tap.kext in /Library/Extensions, but get the following:

Code: Select all

 sudo ifconfig tap0 192.168.0.20 netmask 255.255.255.0
ifconfig: interface tap0 does not exist
Anyone had any luck setting up tap0 and adding it to bridge0 under Sierra?

[edit] Also the following:
sudo ifconfig tap0 create
ifconfig: SIOCIFCREATE2: Invalid argument

I'm at a loss; I had this working under 10.11, so it's not SIP getting in the way.
User avatar
adespoton
Forum All-Star
Posts: 4279
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Tun/Tap under macOS Sierra

Post by adespoton »

Well, I appear to have got things working.

I created a new bridge device named bridge1 in System Preferences -> Network with en0 activated in it, then created the two scripts in my qemu folder:

tap-up

Code: Select all

#!/bin/sh
#
TAPDEV="$1"
BRIDGEDEV="bridge1"
#
ifconfig $BRIDGEDEV addm $TAPDEV
tap-down

Code: Select all

#!/bin/sh
#
TAPDEV="$1"
BRIDGEDEV="bridge1"
#
ifconfig $BRIDGEDEV deletem $TAPDEV
While I'm root, the scripts seem to work when calling them and bridging to bridge1.
User avatar
Cat_7
Expert User
Posts: 6172
Joined: Fri Feb 13, 2004 8:59 am
Location: Sittard, The Netherlands

Re: Tun/Tap under macOS Sierra

Post by Cat_7 »

Hi,

Nice, I also saw those examples for the scripts. Are they needed?

Did you use the script=no options in the command line the first time you tried?
-netdev tap,id=network0,script=no,downscript=no -device sungem,netdev=network0

This is from our current guide. Can you affirm this doesn't work anymore with Sierra?

Bridging a tap device in OSX

For OSX Mountain Lion and above, supporting network bridging: install tuntaposx and add the first line to your qemu command line, run qemu with sudo, and execute the other lines in another terminal window:

-netdev tap,id=network0,script=no,downscript=no -device rtl8139,netdev=network0

sudo ifconfig bridge0 create
sudo ifconfig bridge0 addm en0
sudo ifconfig bridge0 addm tap0
sudo ifconfig bridge0 up

EDIT: I just installed qemu/tuntaposx on my Sierra test installation on an USB disk. It all still seems to work. What's different in your place?

Best,
Cat_7
User avatar
adespoton
Forum All-Star
Posts: 4279
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Tun/Tap under macOS Sierra

Post by adespoton »

Cat_7 wrote:Hi,

Nice, I also saw those examples for the scripts. Are they needed?

Did you use the script=no options in the command line the first time you tried?
-netdev tap,id=network0,script=no,downscript=no -device sungem,netdev=network0

This is from our current guide. Can you affirm this doesn't work anymore with Sierra?

Bridging a tap device in OSX

For OSX Mountain Lion and above, supporting network bridging: install tuntaposx and add the first line to your qemu command line, run qemu with sudo, and execute the other lines in another terminal window:

-netdev tap,id=network0,script=no,downscript=no -device rtl8139,netdev=network0

sudo ifconfig bridge0 create
sudo ifconfig bridge0 addm en0
sudo ifconfig bridge0 addm tap0
sudo ifconfig bridge0 up

EDIT: I just installed qemu/tuntaposx on my Sierra test installation on an USB disk. It all still seems to work. What's different in your place?

Best,
Cat_7
Not sure what's different; when I was attempting to add tap0 using ifconfig to my bridge, Sierra was failing to find the tap device. But using the inline scripts, it worked. Maybe I just typo'd somewhere repeatedly. I know I had it working like that under El Capitan with no issues.

[edit] Hmm; nope, I removed my thunderbolt bridge at bridge0 so I could use that bridge instead of bridge1, and checking ifconfig, I do appear to have en0 and tap0 in bridge0, but I'm still getting a self-assigned IP in the guest. If I manually apply an IP in the host's network range, I'm still getting no communication with the host.

But if you're getting it working, it can't be Sierra; something else must have changed during the upgrade that I have to track down still.
Post Reply