# Scan IP matched accounts

**URL:** https://meta.discourse.org/t/scan-ip-matched-accounts/133930
**Category:** Support
**Created:** [November 20, 2019, 4:14pm UTC](https://meta.discourse.org/t/scan-ip-matched-accounts/133930 "2019-11-20T16:14:03Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [November 20, 2019, 4:14pm UTC](https://meta.discourse.org/t/scan-ip-matched-accounts/133930/1 "2019-11-20T16:14:04Z")

</div>

I know in the user admin we can see if there is another account on a IP address when you click the registered IP or last login IP, can we also see all users that have been matched with double IP’s instead of checking all my users one by one?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [November 20, 2019, 6:36pm UTC](https://meta.discourse.org/t/scan-ip-matched-accounts/133930/2 "2019-11-20T18:36:54Z")

</div>

Here’s a [data explorer](https://meta.discourse.org/t/32566?silent=true) query. It’d be better if it did a group by so that it could sort by most-recent-create-date or something like that, but maybe this’ll help.

```sql
WITH users_per_ip AS (
SELECT
count(1) AS user_count,
u.registration_ip_address AS ip,
max(u.created_at) last_create,
min(u.created_at) first_create,
(max(u.created_at) - min(u.created_at)) diff,
case when (max(u.suspended_at) is not null 
      or max(u.silenced_till) is not null )
      then 1 else 0 end bad
FROM users u
GROUP BY ip
)

SELECT
u.id AS user_id,
date_trunc('day',u.created_at)::date created,
date_trunc('day',upi.diff) days,
bad,
upi.ip AS ip_address
FROM users_per_ip upi
JOIN users u
ON u.registration_ip_address = upi.ip
WHERE upi.user_count > 1
ORDER BY upi.last_create DESC

```

---

<div class="post-metadata">

### Author: ![MarcP](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marcp/32/160184_2.png) [@MarcP](https://meta.discourse.org/u/MarcP)
#### Post date: [November 20, 2019, 7:27pm UTC](https://meta.discourse.org/t/scan-ip-matched-accounts/133930/3 "2019-11-20T19:27:56Z")

</div>

This seems to be working fine for me, didn’t know about [Data Explorer Plugin](https://meta.discourse.org/t/data-explorer-plugin/32566) at all.. Thanks!

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [December 20, 2019, 7:31pm UTC](https://meta.discourse.org/t/scan-ip-matched-accounts/133930/4 "2019-12-20T19:31:28Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
