title: Interfacing with TUN\TAP for MAC OSX (Lion) using Python
body: <p>I found the following tun\tap example program and can not get it to work:</p>
  
  <p><a href="http://www.secdev.org/projects/tuntap_udp/files/tunproxy.py" rel="noreferrer">http://www.secdev.org/projects/tuntap_udp/files/tunproxy.py</a></p>
  
  <p>I have modified the following lines:</p>
  
  <pre><code>f = os.open("/dev/tun0", os.O_RDWR)
  ifs = ioctl(f, TUNSETIFF, struct.pack("16sH", "toto%d", TUNMODE))
  ifname = ifs[:16].strip("\x00")
  </code></pre>
  
  <p>The first line was modified to reflect the real location of the driver.  It was originally</p>
  
  <pre><code>f = os.open("/dev/net/tun", os.O_RDWR)
  </code></pre>
  
  <p>Upon running I get the following error:</p>
  
  <pre><code> sudo ./tuntap.py -s 9000
   Password:
   Traceback (most recent call last):
     File "./tuntap.py", line 65, in &lt;module&gt;
       ifs = ioctl(f, TUNSETIFF, struct.pack("16sH", "toto%d", TUNMODE))
   IOError: [Errno 25] Inappropriate ioctl for device
  </code></pre>
  
  <p>I am using the latest tun\tap drivers installed from <a href="http://tuntaposx.sourceforge.net/download.xhtml" rel="noreferrer">http://tuntaposx.sourceforge.net/download.xhtml</a></p>