Skip to content
Advertisement

How to identify if a vector is a company or not from its ip address?

I want to set up a system to identify the companies that connect to my web site from their ip address. But once I have the ip addresses of visitors to my site, how do I determine if the visitor is a company or not?

I retrieved the ip addresses of visitors in php

<?php
  function getIp(){
    if(!empty($_SERVER['HTTP_CLIENT_IP'])){
      $ip = $_SERVER['HTTP_CLIENT_IP'];
    }elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
      $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }else{
      $ip = $_SERVER['REMOTE_ADDR'];
    }
    return $ip;
  }

  echo 'L adresse IP de l utilisateur est : '.getIp();
?>

Advertisement

Answer

Try to use : gethostbyaddr to get the DNS at least

<?php
  function getIp(){
    if(!empty($_SERVER['HTTP_CLIENT_IP'])){
      $ip = $_SERVER['HTTP_CLIENT_IP'];
    }elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
      $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
    }else{
      $ip = $_SERVER['REMOTE_ADDR'];
    }
    return $ip;
  }

  echo 'L adresse IP de l utilisateur est : '.gethostbyaddr(getIp());
?>
10 People found this is helpful
Advertisement