title: TCP port scanner written in Python using Scapy yields no response
body: <p>I’m trying to make a TCP port scanner, but I’m sticking to a very simple example that I lined together from a more advanced example I found online.</p>
  
  <p>I don’t get any errors.</p>
  
  <p>I’m expecting the code to show me that port 80 is open since I started my Apache server on my Linux box.</p>
  
  <p><strong>Here is the code:</strong></p>
  
  <pre><code>#!/usr/bin/python
  
  import logging
  logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
  from scapy.all import *
  
  ip = "127.0.0.1"
  port = 80
  
  response = sr1(IP(dst=ip)/TCP(dport=port, flags="S"),verbose=False, timeout=0.2)
  
  if response :
      if response[TCP].flags == 18 :    
          print "Port open"
  </code></pre>
  
  <p><strong>Warning I had</strong> (but that does not show up any more):</p>
  
  <blockquote>
    <p>WARNING: No route found for IPv6 destination :: (no default route?)</p>
  </blockquote>
  
  <p>I read that including these two lines below would help on the error:</p>
  
  <pre><code>import logging
  logging.getLogger("scapy.runtime").setLevel(logging.ERROR)
  </code></pre>
  
  <p><strong>Nmap scan:</strong> </p>
  
  <pre><code>STATE SERVICE
  80/tcp   open  http
  </code></pre>
  
  <p><strong>The output is…</strong> Nothing at all.</p>
  
  <p>I tried several things like changing the port to different other ports, some which I had open and some which I did not.</p>
  
  <p>Any ideas as to what I did wrong?</p>