Netgate SG-1000 microFirewall

Author Topic: Question about rules when redirecting DNS to firewall  (Read 1163 times)

0 Members and 1 Guest are viewing this topic.

Offline Trel

  • Sr. Member
  • ****
  • Posts: 368
  • Karma: +11/-1
    • View Profile
Question about rules when redirecting DNS to firewall
« on: October 25, 2015, 01:15:34 pm »
I was looking at this: https://doc.pfsense.org/index.php/Redirecting_all_DNS_Requests_to_pfSense

It said "If DNS requests to other DNS servers are blocked, such as in the Blocking DNS queries to external resolvers example, ensure the rule to pass DNS to 127.0.0.1 is above any rule that blocks DNS. "

My question is if my DNS block rule blocks DNS requests to destinations which are "NOT This Firewall", then that line would not apply, correct?

Offline Derelict

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10257
  • Karma: +1176/-313
    • View Profile
Re: Question about rules when redirecting DNS to firewall
« Reply #1 on: October 25, 2015, 01:23:24 pm »
As long as DNS is passed by a subsequent rule that should work.

I'm not a fan of the "Not" checkbox.  It makes more sense to me to pass what you want then block the rest.

For instance I would pass TCP/UDP 53 to This firewall then block TCP/UDP 53 to any. It's just clearer to me when I'm looking at the rule set.
Las Vegas, Nevada, USA
Use this diagram to describe your issue.
The pfSense Book is now available for just $24.70!
Do Not PM For Help! NO_WAN_EGRESSTM

Offline Trel

  • Sr. Member
  • ****
  • Posts: 368
  • Karma: +11/-1
    • View Profile
Re: Question about rules when redirecting DNS to firewall
« Reply #2 on: October 26, 2015, 10:01:07 am »
As long as DNS is passed by a subsequent rule that should work.

I'm not a fan of the "Not" checkbox.  It makes more sense to me to pass what you want then block the rest.

For instance I would pass TCP/UDP 53 to This firewall then block TCP/UDP 53 to any. It's just clearer to me when I'm looking at the rule set.

I'm confused specifically because it's mentioning adding a pass rule to 127.0.0.1 on the LAN interface.

Quote
If DNS requests to other DNS servers are blocked, such as in the Blocking DNS queries to external resolvers example, ensure the rule to pass DNS to 127.0.0.1 is above any rule that blocks DNS.

That's what I'm unsure about in this situation.

I have no problem doing it the way you said with a pass to "This Firewall" followed by a global block, but would that work in the case of the NAT redirection to 127.0.0.1?

I added an attachment, this is what I have.
Is that allow to 127.0.0.1 required due to the NAT rule or does the allow to "This firewall" cover that case as well is what I'm asking.
« Last Edit: October 26, 2015, 10:10:07 am by Trel »

Offline Derelict

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10257
  • Karma: +1176/-313
    • View Profile
Re: Question about rules when redirecting DNS to firewall
« Reply #3 on: October 26, 2015, 12:26:28 pm »
Pretty sure the self macro (aka This firewall) includes the addresses of loopback interfaces like 127.0.0.1 so that rule is redundant.

Quote
self
    Expands to all addresses assigned to all interfaces.
Las Vegas, Nevada, USA
Use this diagram to describe your issue.
The pfSense Book is now available for just $24.70!
Do Not PM For Help! NO_WAN_EGRESSTM

Offline Trel

  • Sr. Member
  • ****
  • Posts: 368
  • Karma: +11/-1
    • View Profile
Re: Question about rules when redirecting DNS to firewall
« Reply #4 on: October 26, 2015, 12:56:52 pm »
Pretty sure the self macro (aka This firewall) includes the addresses of loopback interfaces like 127.0.0.1 so that rule is redundant.

Quote
self
    Expands to all addresses assigned to all interfaces.

So then if I had the rule specifically for the LAN IP (10.9.0.1) rather than "This Firewall" would the 127.0.0.1 still be needed in that case?  I'm just failing to see how that rule would ever trigger on the LAN interface, though I'm sure I'm probably misunderstanding something with how the NAT translation is handled.

Offline Derelict

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 10257
  • Karma: +1176/-313
    • View Profile
Re: Question about rules when redirecting DNS to firewall
« Reply #5 on: October 26, 2015, 01:48:50 pm »
I don't know what you did with the NAT.

If you port forward TCP/UDP 53 on LAN to 127.0.0.1 the NAT happens before the firewall rule so you have to pass traffic to it.
Las Vegas, Nevada, USA
Use this diagram to describe your issue.
The pfSense Book is now available for just $24.70!
Do Not PM For Help! NO_WAN_EGRESSTM

Offline Trel

  • Sr. Member
  • ****
  • Posts: 368
  • Karma: +11/-1
    • View Profile
Re: Question about rules when redirecting DNS to firewall
« Reply #6 on: October 26, 2015, 02:48:01 pm »
I don't know what you did with the NAT.

If you port forward TCP/UDP 53 on LAN to 127.0.0.1 the NAT happens before the firewall rule so you have to pass traffic to it.

Ok that's the part I wasn't clear on.  That due to NAT the Firewall actually does see a packet "LAN -> 127.0.0.1" when it processes the firewall rules.


That being said, I'm going to keep my pass rule as "This Firewall",  it makes my life easier in the long run.