OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Archive »
  • 21.1 Legacy Series »
  • Outbound Nat Rewrite - how to monitor in logs?
« previous next »
  • Print
Pages: [1] 2 3 4

Author Topic: Outbound Nat Rewrite - how to monitor in logs?  (Read 14498 times)

allebone

  • Sr. Member
  • ****
  • Posts: 402
  • Karma: 34
    • View Profile
Outbound Nat Rewrite - how to monitor in logs?
« on: May 20, 2021, 09:52:28 pm »
Hello,

I have an outbound NAT rewrite rule that captures devices that ignore DNS and forces them to go via my internal pihole. For example if a client such as my Roku TV attempts to connect to 8.8.8.8 on port 53 this is captured and sent correctly internal to my pihole.

See figure 1:

My issue is the logs do not tell me what ip this device attempted to access externally. I would like to know how to capture this information. Eg: I can see that 192.168.2.51 tried to access an IP on port 53 as the rewrite rule kicked in. But would like to know what that IP is (ie was it 8.8.8.8 or some other Ip etc).

How can I know this?

Here is the rewrite rule:

Here is the LAN FW rule:


Thanks in advance :)

Pete


« Last Edit: May 20, 2021, 09:55:31 pm by allebone »
Logged

allebone

  • Sr. Member
  • ****
  • Posts: 402
  • Karma: 34
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #1 on: May 21, 2021, 02:17:40 pm »
Does nobody know the answer to this question? I can log a ticket on github if its an unknown question?

Kind regards
Pete
Logged

astuckey

  • Newbie
  • *
  • Posts: 31
  • Karma: 1
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #2 on: May 24, 2021, 05:13:41 pm »
Sorry if this is obtuse (me not understanding fully) - would it not be easier to use a block policy for all DNS with logging enabled, and whitelist the correct servers (also logged)?  Or if you must let the traffic pass log everything DNS with a inverted destination maybe of not your good DNS servers (via alias) or something similar.  NAT seems to be complicating it a bit from what I can tell.
Logged

allebone

  • Sr. Member
  • ****
  • Posts: 402
  • Karma: 34
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #3 on: May 24, 2021, 07:36:47 pm »
I must be honest. I also dont fully understand what you are telling me.

My desire (and why I set it up like this) is to silently capture devices on the network that try use other dns servers and reroute them to my internal dns server without them knowing (ie blocking them).

This is working as intended but I cant see what external dns servers they are trying to query.

Sorry if you explained how to do this. I didnt fully understand your comment.

Pete
Logged

FullyBorked

  • Sr. Member
  • ****
  • Posts: 353
  • Karma: 24
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #4 on: May 26, 2021, 06:09:13 pm »
Quote from: allebone on May 24, 2021, 07:36:47 pm
I must be honest. I also dont fully understand what you are telling me.

My desire (and why I set it up like this) is to silently capture devices on the network that try use other dns servers and reroute them to my internal dns server without them knowing (ie blocking them).

This is working as intended but I cant see what external dns servers they are trying to query.

Sorry if you explained how to do this. I didnt fully understand your comment.

Pete

I'm doing the same NAT redirect to my DNS server.  I can confirm as well even with logging enabled on that NAT rule I do not see logs for the rewrite either.  At least not in the live view. 

Also check this post out https://forum.opnsense.org/index.php?topic=20149.0 
Logged

Meditux

  • Jr. Member
  • **
  • Posts: 86
  • Karma: 12
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #5 on: May 26, 2021, 06:29:30 pm »
Sorry, can be deleted

Greeting Meditux

« Last Edit: May 26, 2021, 06:32:19 pm by Meditux »
Logged

FullyBorked

  • Sr. Member
  • ****
  • Posts: 353
  • Karma: 24
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #6 on: May 26, 2021, 06:35:36 pm »
Quote from: Meditux on May 26, 2021, 06:29:30 pm
Hi guys,

I do the same, however the redirects show up in the livelog for me.

Greeting Meditux

I can see the resulting rewrite as well but I think what the OP looking for is an entry like
Code: [Select]
NAT - <Orig> Dest 8.8.8.8:53 > <New> Dest 192.168.1.1:53 to see the original destination. 
Logged

allebone

  • Sr. Member
  • ****
  • Posts: 402
  • Karma: 34
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #7 on: May 26, 2021, 10:44:22 pm »
Yes exactly there is no log showing the destination the client tried to access like to 8.8.8.8 as you say in your example.
Logged

allebone

  • Sr. Member
  • ****
  • Posts: 402
  • Karma: 34
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #8 on: June 24, 2021, 09:02:19 pm »
I am still looking for a solution to this problem if anyone is aware of one :)
Logged

Greelan

  • Hero Member
  • *****
  • Posts: 1028
  • Karma: 72
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #9 on: June 24, 2021, 09:14:26 pm »
I suspect the code to log the original destination IP for the NAT rule is just not there.

A workaround perhaps is to have a specific firewall rule for the source IPs that are being rewritten on the DNS port and log that.
Logged

allebone

  • Sr. Member
  • ****
  • Posts: 402
  • Karma: 34
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #10 on: June 24, 2021, 09:20:51 pm »
Do you mean the workaround is to log this on the DNS server and not the opnsense firewall?
Logged

Greelan

  • Hero Member
  • *****
  • Posts: 1028
  • Karma: 72
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #11 on: June 24, 2021, 09:26:19 pm »
No, I meant to create a firewall (filter) rule on the relevant OPNsense interface for the source IPs (eg LAN if they are in the LAN subnet), destination port 53, and then have logging on for that. Put that rule above any general pass rule (such as the default allow LAN to any rule). So the incoming DNS requests will hit that and be logged before they even reach the NAT rule
Logged

allebone

  • Sr. Member
  • ****
  • Posts: 402
  • Karma: 34
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #12 on: June 24, 2021, 09:28:14 pm »
I dont know how to do this. How do I create a firewall rule that does not block or pass the packets, so that the rewrite rule can take effect after the logging? If I make a rule the only options are "pass" "block" or "reject" I do not wish to block the packet or reject it. I also dont want to pass it (Ie allow it out). I want it to be captured and rewritten.
« Last Edit: June 24, 2021, 09:30:59 pm by allebone »
Logged

Greelan

  • Hero Member
  • *****
  • Posts: 1028
  • Karma: 72
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #13 on: June 24, 2021, 09:30:16 pm »
?

You do want to pass the packets on the internal interface, otherwise they will be dropped by OPNsense and there will be no DNS resolution, with or without a NAT rule
Logged

allebone

  • Sr. Member
  • ****
  • Posts: 402
  • Karma: 34
    • View Profile
Re: Outbound Nat Rewrite - how to monitor in logs?
« Reply #14 on: June 24, 2021, 09:33:52 pm »
The rule that is there allows only the packet to pass to the internal DNS server. The packet is already rewritten by the time it gets to that rule. There is not an allow rule that allows the LAN client out to anywhere on 53 as this would be undesirable. I dont know how to implement what you are suggesting.
Logged

  • Print
Pages: [1] 2 3 4
« previous next »
  • OPNsense Forum »
  • Archive »
  • 21.1 Legacy Series »
  • Outbound Nat Rewrite - how to monitor in logs?
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2