# How to create security rule for Windows Authentication - Success from Public IPs Alert with KQL language?

**URL:** <https://discuss.elastic.co/t/how-to-create-security-rule-for-windows-authentication-success-from-public-ips-alert-with-kql-language/338588>\
**Category:** Kibana\
**Tags:** kql-kibana-query-language\
**Created:** [July 17, 2023, 4:06pm UTC](https://discuss.elastic.co/t/how-to-create-security-rule-for-windows-authentication-success-from-public-ips-alert-with-kql-language/338588 "2023-07-17T16:06:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aungsoemin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aungsoemin/32/122705_2.png) [@aungsoemin](https://discuss.elastic.co/u/aungsoemin)\
**Post date:** [July 17, 2023, 4:06pm UTC](https://discuss.elastic.co/t/how-to-create-security-rule-for-windows-authentication-success-from-public-ips-alert-with-kql-language/338588/1 "2023-07-17T16:06:12Z")

</div>

Hi,

I'm trying to create the custom use case "Windows Authentication - Success from Public IPs Alert" with below informations.

Event code = 4624  
Action = Success  
IP Range = Any Public IP

Here is my KQL query to create the custom rule for Windows OS.

(event.code : "4624" and event.outcome : "success") and (NOT winlog.event\_data.IpAddress : 10.\* or NOT winlog.event\_data.IpAddress : 172.[16-31].\* or NOT winlog.event\_data.IpAddress : 192.168.\*)

But doesn't work yet. It's always trigger the alert whatever I login with public and private IP. I just want to get the alert when login from public IP.

May I get your information how can I correct the query please? I'm looking forward to hear from you.

Thank you.

---

<div class="post-metadata">

**Author:** ![aungsoemin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aungsoemin/32/122705_2.png) [@aungsoemin](https://discuss.elastic.co/u/aungsoemin)\
**Post date:** [July 18, 2023, 5:22am UTC](https://discuss.elastic.co/t/how-to-create-security-rule-for-windows-authentication-success-from-public-ips-alert-with-kql-language/338588/2 "2023-07-18T05:22:01Z")

</div>

Below query also doesn't work for me.

event.code:"4624" and event.outcome:"success" and not winlog.event\_data.IpAddress:("10._" or "172.[16-31]._" or "192.168.\*")

---

<div class="post-metadata">

**Author:** ![aungsoemin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aungsoemin/32/122705_2.png) [@aungsoemin](https://discuss.elastic.co/u/aungsoemin)\
**Post date:** [July 19, 2023, 7:27am UTC](https://discuss.elastic.co/t/how-to-create-security-rule-for-windows-authentication-success-from-public-ips-alert-with-kql-language/338588/3 "2023-07-19T07:27:01Z")

</div>

Hi,

This EQL also doesn't work for me.  
As I'm new to ELK, I'm looking for someone's suggestion and your input is very valuable for me.

sequence

[event where event.code == "4624" and event.outcome == "success"]  
[network where host.os.type == "windows" and not cidrmatch(winlog.event\_data.IpAddress, "10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/24")]

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 16, 2023, 7:27am UTC](https://discuss.elastic.co/t/how-to-create-security-rule-for-windows-authentication-success-from-public-ips-alert-with-kql-language/338588/4 "2023-08-16T07:27:19Z")

</div>

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