-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rule for filtering outgoing DNS server traffic
- Loading branch information
1 parent
c23d8bf
commit 899de90
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# | ||
# @summary manage outgoing DNS responses from a DNS server | ||
# | ||
# @param dns_servers optional list of local ip addresses from the DNS server | ||
# | ||
class nftables::rules::out::dnsserver ( | ||
Array[Stdlib::IP::Address] $dns_servers = [], | ||
) { | ||
unless empty($dns_servers) { | ||
$dns_servers.each |$index,$dns| { | ||
nftables::rule { | ||
"default_out-dnsserverudp-${index}": | ||
} | ||
if $dns =~ /:/ { | ||
Nftables::Rule["default_out-dnsudp-${index}"] { | ||
content => "ip6 daddr ${dns} udp sport 53 accept", | ||
} | ||
} else { | ||
Nftables::Rule["default_out-dnsudp-${index}"] { | ||
content => "ip daddr ${dns} udp sport 53 accept", | ||
} | ||
} | ||
|
||
nftables::rule { | ||
"default_out-dnsservertcp-${index}": | ||
} | ||
if $dns =~ /:/ { | ||
Nftables::Rule["default_out-dnstcp-${index}"] { | ||
content => "ip6 daddr ${dns} tcp sport 53 accept", | ||
} | ||
} else { | ||
Nftables::Rule["default_out-dnstcp-${index}"] { | ||
content => "ip daddr ${dns} tcp sport 53 accept", | ||
} | ||
} | ||
} | ||
} else { | ||
nftables::rule { | ||
'default_out-dnsudp': | ||
content => 'udp sport 53 accept'; | ||
'default_out-dnstcp': | ||
content => 'tcp sport 53 accept'; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters