Creating Linux bridging / tap devices with tunctl and openvpn

The more and more I play around with KVM virtualization, the more I realize just how useful Linux bridging is. In the Linux bridging world, a bridge device simulates a multiport Ethernet switch. To connect to the switch, you create a tap device that simulates a port on that switch. Once you have bridging configured on your host, there are two prevalent ways of going about creating taps. The first method is through the openvpn program:

$ openvpn –mktun –dev tap0

Fri Apr 24 15:14:26 2009 TUN/TAP device tap0 opened
Fri Apr 24 15:14:26 2009 Persist state set to: ON

This will create a tap device named tap0, which you can configure locally or assign to a virtual machine running on the host. The second way to create a tap is through tunctl:

$ tunctl -u root

Set 'tap0' persistent and owned by uid 0

This will also create a tap device named tap0, and will set the owner of the interface to root. Once a tap device is created, you can configure it just like any other Ethernet interface. Nice!

2 thoughts on “Creating Linux bridging / tap devices with tunctl and openvpn”

  1. Very useful info!! The newer openvpn command asked for double “-” in the option part of the line but the warning hints to that. Again, it helped me understand what a TAP was. Thanks.

  2. I want to create tun interface also using tunctl at the same time when tap is created. Though I am able to create one, but only tap is functioning, not tun. Any solutions?

Leave a Reply

Your email address will not be published. Required fields are marked *