title: Find IP of raspberry pi by scanning IPs with Python
body: <p>I use a Raspberry Pi which gets its IP address from a DHCP host in our company network. I'd like to find out its IP address without having a display connected.</p>
  
  <p>It's quite obvious how to scan through a range of possible IPs using Python for instance, but how do I check if there is a Raspberry Pi on the other end of the line?</p>
  
  <p>Here is what I've tried so far (there should be an open ssh port on the device), but I haven't found the Raspberry Pi yet. Now I am not sure whether my Raspi isn't properly connected or my method is not working at all:</p>
  
  <pre><code>import socket
  
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  
  for i in range(1,256):
      ip = '192.168.132.{}'.format(i)
      try:
          s.connect((ip, 22))
          print('Raspi is probably on {}'.format(ip))
      except socket.error as e:
          print('Nothing on {}.'.format(ip))
      s.close()
  </code></pre>