title: OSX connection sharing and Scapy
body: <p>I'm using Scapy to sniff network traffic with the following code:</p>
  
  <pre><code>from scapy.all import *
  
  import sys
  
  filter = sys.argv[1]
  
  def Responder():
  
      def getPacket(pkt):
          if Raw in pkt:  print pkt[Raw]
  
      return getPacket
  
  sniff(filter=filter, prn=Responder())
  </code></pre>
  
  <p>This code works fine if I just browse to a website.</p>
  
  <p>The problem is that when I turn on connection sharing and I try to run this script I get the following error:</p>
  
  <pre><code>bash-3.2# sudo python sniffy.py "tcp port 80"
  Traceback (most recent call last):
    File "sniffy.py", line 1, in &lt;module&gt;
      from scapy.all import *
    File "/Library/Python/2.7/site-packages/scapy/all.py", line 25, in &lt;module&gt;
      from route import *
    File "/Library/Python/2.7/site-packages/scapy/route.py", line 162, in &lt;module&gt;
      conf.route=Route()
    File "/Library/Python/2.7/site-packages/scapy/route.py", line 22, in __init__
      self.resync()
    File "/Library/Python/2.7/site-packages/scapy/route.py", line 31, in resync
      self.routes = read_routes()
    File "/Library/Python/2.7/site-packages/scapy/arch/unix.py", line 87, in read_routes
      ifaddr = scapy.arch.get_if_addr(netif)
    File "/Library/Python/2.7/site-packages/scapy/arch/__init__.py", line 36, in get_if_addr
      return socket.inet_ntoa(get_if_raw_addr(iff))
    File "/Library/Python/2.7/site-packages/scapy/arch/pcapdnet.py", line 188, in get_if_raw_addr
      return i.get(ifname)["addr"].data
    File "dnet.pyx", line 990, in dnet.intf.get
  OSError: Device not configured
  </code></pre>
  
  <p>I tried to add <code>"conf.iface=en1"</code> at the top of the script. This gives the same error. en1 is a valid interface.</p>
  
  <p>I've also followed the advise from <a href="https://github.com/andresriancho/w3af/issues/341" rel="nofollow">here</a>, and changed arch/unix.py on line 34 from "<code>os.popen("netstat -rn")</code>" to "<code>os.popen("netstat -rn | grep -v vboxnet")</code> ". This didn't fix it.</p>