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

Add rule for filtering outgoing DNS server traffic #217

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ and Manager Daemons (MGR).
* [`nftables::rules::out::dhcp`](#nftables--rules--out--dhcp): manage out dhcp
* [`nftables::rules::out::dhcpv6_client`](#nftables--rules--out--dhcpv6_client): Allow DHCPv6 requests out of a host
* [`nftables::rules::out::dns`](#nftables--rules--out--dns): manage out dns
* [`nftables::rules::out::dnsserver`](#nftables--rules--out--dnsserver): manage outgoing DNS responses from a DNS server
* [`nftables::rules::out::hkp`](#nftables--rules--out--hkp): allow outgoing hkp connections to gpg keyservers
* [`nftables::rules::out::http`](#nftables--rules--out--http): manage out http
* [`nftables::rules::out::https`](#nftables--rules--out--https): manage out https
Expand Down Expand Up @@ -919,6 +920,24 @@ specify dns_server name

Default value: `[]`

### <a name="nftables--rules--out--dnsserver"></a>`nftables::rules::out::dnsserver`

manage outgoing DNS responses from a DNS server

#### Parameters

The following parameters are available in the `nftables::rules::out::dnsserver` class:

* [`dns_servers`](#-nftables--rules--out--dnsserver--dns_servers)

##### <a name="-nftables--rules--out--dnsserver--dns_servers"></a>`dns_servers`

Data type: `Array[Stdlib::IP::Address]`

optional list of local ip addresses from the DNS server

Default value: `[]`

### <a name="nftables--rules--out--hkp"></a>`nftables::rules::out::hkp`

allow outgoing hkp connections to gpg keyservers
Expand Down
30 changes: 30 additions & 0 deletions manifests/rules/out/dnsserver.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#
# @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| {
$content = $dns ? {
Stdlib::IP::Address::V6 => "ip6 saddr ${dns}",
Stdlib::IP::Address::V4 => "ip saddr ${dns}",
}
nftables::rule { "default_out-dnsservertcp-${index}":
content => "${content} tcp sport 53 accept",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derp, I need to rethink this. DNS servers don't respond with src port 53 but a random port. Maybe we can just close the PR.

}
nftables::rule { "default_out-dnsserverudp-${index}":
content => "${content} udp sport 53 accept",
}
}
} else {
nftables::rule {
'default_out-dnsserverudp':
content => 'udp sport 53 accept';
'default_out-dnsservertcp':
content => 'tcp sport 53 accept';
}
}
}
1 change: 1 addition & 0 deletions spec/acceptance/all_rules_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class { 'nftables':
include nftables::rules::out::postgres
include nftables::rules::out::icmp
include nftables::rules::out::dns
include nftables::rules::out::dnsserver
include nftables::rules::out::nfs3
include nftables::rules::out::ssh
include nftables::rules::out::kerberos
Expand Down
Loading