Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

firewall: NAT rule logging improvements #5005

Closed
pallebone opened this issue May 21, 2021 · 16 comments
Closed

firewall: NAT rule logging improvements #5005

pallebone opened this issue May 21, 2021 · 16 comments
Assignees
Labels
feature Adding new functionality
Milestone

Comments

@pallebone
Copy link

Important notices

Our forum is located at https://forum.opnsense.org , please consider joining discussions there in stead of using GitHub for these matters.

Before you ask a new question, we ask you kindly to acknowledge the following:

Hello,

I tried asking my question on the forum, but nobody knows the answer.
https://forum.opnsense.org/index.php?topic=23192.0

Im happy to either continue on the forum or here depending on your preference, but I dont know how to get this information from the logs.

Please let me know your preferred method to proceed and I will do my best to accommodate as you require :)

I believe this information should be exposed because it has security implications, being able to monitor what external addresses internal IP's are accessing.

Looking forward to your insight :) Hope you are having a good day so far :)

Kind regards
Peter

@pallebone pallebone added the support Community support label May 21, 2021
@pallebone
Copy link
Author

Hi,

If you need any further info please let me know :)

Kind regards
Pete

@pallebone
Copy link
Author

Additional information from KeyHand here:

https://forum.opnsense.org/index.php?topic=23192.msg112811#msg112811

@pallebone pallebone changed the title Outbound Nat Rewrite - how to monitor in logs? Port Forward issue related to Outbound Nat Rewrite - how to monitor in logs? Jun 28, 2021
@fichtner fichtner self-assigned this Jun 29, 2021
@fichtner fichtner added cleanup Low impact changes and removed support Community support labels Jun 29, 2021
@fichtner fichtner added this to the 21.7 milestone Jun 29, 2021
@fichtner
Copy link
Member

Hi Peter,

This is a fun one. ;)

When using port forwards and using Filter rule association "pass" with logging enabled will pop up the traffic in the firewall log:

Screenshot 2021-06-29 at 17 42 56

The problem here is as described a limitation of the filterlog output. However, a state is being created for this redirect rule:

Screenshot 2021-06-29 at 17 41 11

And you can see the NAT origin...

There are two TODO's here:

  1. Try to emulate this with an associated filter pass rule (logging enabled correctly? I couldn't tell from first test as it wasn't working).

  2. Tie states listing closer to port forward rules. One of the issues is that rdr/nat/binat rules do not support labels as far as I understand so tracking is more difficult. We also do not dump the state ID in the filterlog. ;(

Cheers,
Franco

@pallebone
Copy link
Author

Hello Franco,

Thank you for your reply.

I tried to follow your screenshots but I do not have a "Firewall:Diagnostics:States" page. I only have States dump, States reset, or States summary. This page you have accessed I cannot find.

In addition, if you would like me to check anything please let me know and I will do so :)

Kind regards,
Pete

@fichtner
Copy link
Member

Hi Pete,

The page I showed is from the upcoming 21.7 release. It sort of replaces the states dump page, although the NAT information is on that older page as well.

With an associated pass rule, using inspect on the development version allows to directly fetch the associated states. Though the logging is incorrect IMO as rdr is no longer logged (not the final action I suppose):

Screenshot 2021-06-29 at 9 13 25 PM

Screenshot 2021-06-29 at 9 14 15 PM

Screenshot 2021-06-29 at 9 14 28 PM

Cheers,
Franco

@fichtner fichtner changed the title Port Forward issue related to Outbound Nat Rewrite - how to monitor in logs? firewall: NAT rule logging improvements Jun 30, 2021
fichtner added a commit to opnsense/src that referenced this issue Jun 30, 2021
@fichtner
Copy link
Member

Hi Pete,

With opnsense/src@bdb244c37d and a separate firewall pass rule it looks like this now:

Screenshot 2021-06-30 at 09 47 20

I suppose seeing NAT log pre-NAT and firewall rule post-NAT is the desired result? :)

Cheers,
Franco

fichtner added a commit that referenced this issue Jun 30, 2021
@pallebone
Copy link
Author

Hi Franco,

This is very interesting. how did you manage to achieve this result?

I do not use the dev version... is there any way I can test this to check what happens my side? It looks like it is showing both the original destination and the destination after the rewrite occurs in your screenshot which is excellent.

Kind regards
Peter

@fichtner
Copy link
Member

fichtner commented Jun 30, 2021

The snapshot kernel to try is:

# opnsense-update -zkr 21.7.r_1
# opnsense-shell reboot

Cheers,
Franco

@pallebone
Copy link
Author

Hi Franco,

Thank you for your reply. Apologies for bothering you further but I was not able to complete this. This is the output:

Enter an option: 8

root@OPNsense:~ # opnsense-update -zkr 21.7.r1_1
Fetching kernel-21.7.r1_1-amd64.txz: .. failed, no signature found
root@OPNsense:~ #

Kind regards
Peter

@fichtner
Copy link
Member

Hi Pete,

Which mirror are you using? The default mirror should be good. The file was only published today.

Cheers,
Franco

@pallebone
Copy link
Author

Apologies again. It must be something my side. I cannot get it to work.

My settings are:
Mirror: Default
Flavour: Libressl
Type: Community.

Could it be because I am using libressl (not a default setting).

Sorry I feel bad wasting your time. This is most likely due to my specific config its not working so apologies again in advance.

Kind regards
Pete

@fichtner
Copy link
Member

Sorry, my fault... it's actually:

# opnsense-update -kr 21.7.r_1

@pallebone
Copy link
Author

pallebone commented Jun 30, 2021

Sorry, my fault... it's actually:

# opnsense-update -kr 21.7.r_1

No problem, actually it was opnsense-update -zkr 21.7.r_1 but I managed to guess that myself so it has installed. I will test and come back to you in a little while :) (without the z it fails)

@pallebone
Copy link
Author

I can confirm that the new patch indeed fixes it - see below:
RDR

All info is now exposed as requested in the OP.

Thank you very much for this. Can I ask how you managed to add this functionality into OpnSense? It seems like it would have been a nightmare to add.

Kind regards,
Peter

@fichtner
Copy link
Member

Hi Peter,

It was a mix of reading a bit of source code and remembering that logging already worked somehow. Glad we could put the pieces together.

This will likely end up in OPNsense 21.7, but not the RC1 to be released next week.

To keep the code in place lock "kernel" package from the firmware packages tab.

Close then? :)

Cheers,
Franco

@fichtner fichtner added feature Adding new functionality and removed cleanup Low impact changes labels Jun 30, 2021
@pallebone
Copy link
Author

Yes please. Thank you for your time. It is appreciated.

Kind regards
Peter.

fichtner added a commit that referenced this issue Jul 5, 2021
fichtner added a commit to opnsense/src that referenced this issue Sep 16, 2021
fichtner added a commit to opnsense/src that referenced this issue Sep 17, 2021
freebsd-git pushed a commit to freebsd/freebsd-src that referenced this issue Sep 18, 2021
fichtner added a commit to opnsense/src that referenced this issue Sep 19, 2021
fichtner added a commit to opnsense/src that referenced this issue Sep 20, 2021
fichtner added a commit to opnsense/src that referenced this issue Sep 23, 2021
fichtner added a commit to opnsense/src that referenced this issue Sep 27, 2021
fichtner added a commit to opnsense/src that referenced this issue Sep 28, 2021
fichtner added a commit to opnsense/src that referenced this issue Sep 29, 2021
fichtner added a commit to opnsense/src that referenced this issue Sep 30, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 1, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 5, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 7, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 11, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 12, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 13, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 14, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 15, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 20, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 21, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 25, 2021
fichtner added a commit to opnsense/src that referenced this issue Oct 29, 2021
fichtner added a commit to opnsense/src that referenced this issue Nov 4, 2021
fichtner added a commit to opnsense/src that referenced this issue Nov 5, 2021
bsdjhb pushed a commit to bsdjhb/cheribsd that referenced this issue Dec 31, 2021
fichtner added a commit to opnsense/src that referenced this issue May 4, 2022
fichtner added a commit to opnsense/src that referenced this issue May 5, 2022
fichtner added a commit to opnsense/src that referenced this issue May 6, 2022
fichtner added a commit to opnsense/src that referenced this issue May 16, 2022
fichtner added a commit to opnsense/src that referenced this issue May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding new functionality
Development

No branches or pull requests

2 participants