LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   *BSD (https://www.linuxquestions.org/questions/%2Absd-17/)
-   -   FQDN in Packet Filter (https://www.linuxquestions.org/questions/%2Absd-17/fqdn-in-packet-filter-4175699110/)

Rajasekhar Bhumireddy 08-13-2021 04:53 AM

FQDN in Packet Filter
 
I want to restrict access to specific public domain names form my machine.

For achieving this, I am providing fully qualified domain names in packet filter rule.

for example

pass out on <interface> inet from <myip> to example.com
pass in on <interface> inet from example.com to <myip>

What I understood from the OpenBSD's user guide is "A fully qualified domain name that will be resolved via DNS when the ruleset is loaded. All resulting IP addresses will be substituted into the rule"

I have few queries from this,

1. IPs are substituting into rule while loading ruleset, what if there is a change in IP of the domain name after loading ?

2. Is this FQDN option in pf rule only for static IPs?

3. Does it considering IP dynamicity of domain name?

jggimi 08-13-2021 07:37 AM

For PF, domain resolution occurs at rule loading time ONLY. And if the rules are being loaded during boot by rc(8), a domain name server may not yet be available to the OS. In that case, resolution must come from a hosts(5) file rather than a server. For HTTP/HTTPS traffic, the better solution is relayd(8). There's an example of blocking a social media website in the relayd.conf(5) man page.
Quote:

Originally Posted by Rajasekhar Bhumireddy (Post 6274878)
1. IPs are substituting into rule while loading ruleset, what if there is a change in IP of the domain name after loading ?

There will be no change to the rule(s) created at load time.
Quote:

2. Is this FQDN option in pf rule only for static IPs?
Yes.
Quote:

3. Does it considering IP dynamicity of domain name?
No.

jggimi 08-13-2021 09:32 AM

Two additional points on domain resolution.
  1. If during resolution there are both IPv4 and IPv6 addresses resolved -- both A and AAAA records returned by DNS or both IPv4 and IPv6 addresses in hosts(5) -- there will be two rules created internally for PF: one each for IPv4 and for IPv6.
  2. If the domain resolves to multiple addresses, then a temporary table is loaded with the addresses for each rule.
As an example, a rule written as
Code:

pass in from yahoo.com
will produce two internal rules with two temporary tables, as shown in the output from `# pfctl -sr`, since yahoo.com resolves to a pool of IPv4 addresses and a pool of IPv6 addresses:
Code:

pass in inet6 from <__automatic_311a83f5_0> to any flags S/SA
pass in inet from <__automatic_311a83f5_1> to any flags S/SA



All times are GMT -5. The time now is 01:24 AM.