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 14383 times)
Greelan
Hero Member
Posts: 1028
Karma: 72
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #15 on:
June 24, 2021, 09:37:40 pm »
Destination NAT happens after the filter rule. The packet has to get into OPNsense before it is NATed
Logged
allebone
Sr. Member
Posts: 402
Karma: 34
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #16 on:
June 24, 2021, 09:41:15 pm »
I still dont understand how this can work.
The only DNS rule I have allowed is as such:
IPv4 TCP/UDP (Lan clients Alias) * 192.168.2.22 53 (DNS) * * lredirectrule DNS53Pihole
So for example a client would have 8.8.8.8 as its DNS server. in this case the packet is rewritten to go to 192.168.2.22.
Once its rewritten, the only DNS rule is the one above. Logging has no effect as its too late.
What rule are you proposing I add above this rule in order to log the client trying to access 8.8.8.8 on port 53, and is it pass, block, or reject?
Logged
Greelan
Hero Member
Posts: 1028
Karma: 72
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #17 on:
June 24, 2021, 09:42:48 pm »
You have a “allow LAN to any” filter rule on the LAN interface right?
Logged
allebone
Sr. Member
Posts: 402
Karma: 34
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #18 on:
June 24, 2021, 09:43:46 pm »
Yes it is the last rule in the table.
Logged
Greelan
Hero Member
Posts: 1028
Karma: 72
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #19 on:
June 24, 2021, 09:55:54 pm »
Is logging turned on for the filter rule that you put in your post above? That filter rule is what is automatically created to work with the NAT rule, and is essentially what I was saying you should log (I forgot that an outbound NAT rule on an internal interface automatically creates a corresponding filter rule)
Logged
allebone
Sr. Member
Posts: 402
Karma: 34
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #20 on:
June 24, 2021, 09:58:21 pm »
Ok I will try and report back.
Logged
allebone
Sr. Member
Posts: 402
Karma: 34
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #21 on:
June 24, 2021, 10:11:11 pm »
Im afraid it does not work. I even tried making a rule and placing it as the very first rule in my firewall as such:
IPv4 TCP/UDP * * * 53 (DNS) * *
It had no effect and this makes me think that the nat rewrite rules are processed before the firewall rule on that interface. Otherwise it should have been allowed out to 8.8.8.8.
The only logs I see are as example:
lan Jun 24 16:04:02 192.168.2.2:61891 192.168.2.22:53 udp nat rule
lan Jun 24 16:04:02 192.168.2.16:54209 192.168.2.22:53 udp
lan Jun 24 16:04:02 192.168.2.2:25605 192.168.2.22:53 udp nat rule
lan Jun 24 16:04:02 192.168.2.16:54208 192.168.2.22:53 udp
Logged
allebone
Sr. Member
Posts: 402
Karma: 34
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #22 on:
June 24, 2021, 10:16:55 pm »
I think outbound nat is done first if you check this post its first in the list:
https://forum.opnsense.org/index.php?topic=11233.0
Logged
allebone
Sr. Member
Posts: 402
Karma: 34
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #23 on:
June 24, 2021, 10:20:10 pm »
I checked that debug file by ssh to my firewall and indeed outbound nat is processed first. The lan rules are listed afterwards in that file. So making firewall rules has no effect.
Logged
Greelan
Hero Member
Posts: 1028
Karma: 72
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #24 on:
June 24, 2021, 10:20:45 pm »
Hmm. Can you post the full content of your NAT rule, rather than just the summary? Wonder if it is written correctly
Logged
allebone
Sr. Member
Posts: 402
Karma: 34
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #25 on:
June 24, 2021, 10:24:31 pm »
The screenshot is on page one. The debug log lists this:
(snipped)
# NAT Redirects
no nat proto carp all
no rdr proto carp all
# [prio: 100]
nat log on em1 inet from !$AllowQueryDNSServers to 192.168.2.22/32 port 53 -> (em1:0) port 1024:65535 # DNSOutRewrite
nat log on em1 inet from !$AllowQueryDNSServers to 192.168.2.22/32 port 853 -> (em1:0) port 1024:65535 # DNSOutRewrite853
nat on pppoe0 inet from (wireguard:network) to any -> (pppoe0:0) port 1024:65535 # Allow WG Clients to NAT
# [prio: 200]
Logged
Greelan
Hero Member
Posts: 1028
Karma: 72
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #26 on:
June 24, 2021, 10:27:44 pm »
I meant what is the full content when you edit the NAT rule in the GUI? And what does the source alias represent?
Logged
allebone
Sr. Member
Posts: 402
Karma: 34
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #27 on:
June 24, 2021, 10:37:42 pm »
Here are the images:
Logged
allebone
Sr. Member
Posts: 402
Karma: 34
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #28 on:
June 24, 2021, 10:39:44 pm »
I mean it does log when the rule runs, it just does not show the destination that was attempted to be accessed. im thinking the functionality is not exposed in opnsense and would need a change to allow it in the code (if even possible I dont know).
Logged
Greelan
Hero Member
Posts: 1028
Karma: 72
Re: Outbound Nat Rewrite - how to monitor in logs?
«
Reply #29 on:
June 24, 2021, 10:50:28 pm »
So here is where I am confused. That rule only operates where the original destination IP is .22. Is that your pihole? If so the destination should be inverted, and the translation/target address changed to the pihole address
So the logging is working as expected at the moment
Logged
Print
Pages:
1
[
2
]
3
4
« previous
next »
OPNsense Forum
»
Archive
»
21.1 Legacy Series
»
Outbound Nat Rewrite - how to monitor in logs?