1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Search for an IP (query)

Discussion in 'Tips and Guides [Archive]' started by Jake Bunce, May 3, 2011.

  1. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    There is currently no utility in the software to search for an IP address, but you can use a query.

    Here is a query you can run on your database to retrieve a list of all users that have used a particular IP address:

    Code:
    SELECT user.username, INET_NTOA(ip.ip)
    FROM xf_ip AS ip
    LEFT JOIN xf_user AS user ON (user.user_id = ip.user_id)
    WHERE ip.ip = INET_ATON('xxx.xxx.xxx.xxx')
    GROUP BY user.user_id
    
    Replace xxx.xxx.xxx.xxx with the IP you want to search for.

    Use this if you want to specify a range of IPs:

    Code:
    SELECT user.username, INET_NTOA(ip.ip)
    FROM xf_ip AS ip
    LEFT JOIN xf_user AS user ON (user.user_id = ip.user_id)
    WHERE ip.ip BETWEEN INET_ATON('xxx.xxx.xxx.1') AND INET_ATON('xxx.xxx.xxx.255')
    GROUP BY user.user_id
    
    You have to specify the beginning and end of the range.

    You will get results like this:

    Screen shot 2011-05-03 at 10.05.27 AM.png
     
    Saeed, Mopquill, Michael and 6 others like this.
  2. Dean

    Dean Well-Known Member

    Thank you Jake, much appreciated. :)
     
  3. Floris

    Floris Guest

    Thank you Jake :)
     

Share This Page