-
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.
rules::llmnr: Allow interface filtering
- Loading branch information
1 parent
9685362
commit 1ef7d5c
Showing
3 changed files
with
52 additions
and
2 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 |
---|---|---|
|
@@ -3,21 +3,31 @@ | |
# | ||
# @param ipv4 Allow LLMNR over IPv4 | ||
# @param ipv6 Allow LLMNR over IPv6 | ||
# @param iifname optional list of incoming interfaces to filter on | ||
# | ||
# @author Tim Meusel <[email protected]> | ||
# | ||
# @see https://datatracker.ietf.org/doc/html/rfc4795 | ||
# | ||
class nftables::rules::llmnr ( | ||
Boolean $ipv4 = true, | ||
Boolean $ipv6 = true, | ||
Array[String[1]] $iifname = [], | ||
) { | ||
if empty($iifname) { | ||
$_iifname = '' | ||
} else { | ||
$iifdata = $iifname.map |String[1] $interface| { "\"${interface}\"" }.join(', ') | ||
$_iifname = "iifname { ${iifdata} } " | ||
} | ||
if $ipv4 { | ||
nftables::rule { 'default_in-llmnr_v4': | ||
content => 'ip daddr 224.0.0.252 udp dport 5355 accept comment "allow LLMNR"', | ||
content => "${_iifname}ip daddr 224.0.0.252 udp dport 5355 accept comment \"allow LLMNR\"", | ||
} | ||
} | ||
if $ipv6 { | ||
nftables::rule { 'default_in-llmnr_v6': | ||
content => 'ip6 daddr ff02::1:3 udp dport 5355 accept comment "allow LLMNR"', | ||
content => "${_iifname}ip6 daddr ff02::1:3 udp dport 5355 accept comment \"allow LLMNR\"", | ||
} | ||
} | ||
} |
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,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'nftables::rules::llmnr' do | ||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let :facts do | ||
os_facts | ||
end | ||
|
||
context 'default options' do | ||
it { is_expected.to compile.with_all_deps } | ||
it { is_expected.to contain_nftables__rule('default_in-llmnr_v4').with_content('ip daddr 224.0.0.252 udp dport 5355 accept comment "allow LLMNR"') } | ||
it { is_expected.to contain_nftables__rule('default_in-llmnr_v6').with_content('ip6 daddr ff02::1:3 udp dport 5355 accept comment "allow LLMNR"') } | ||
end | ||
|
||
context 'with input interfaces set' do | ||
let :params do | ||
{ | ||
iifname: %w[docker0 eth0], | ||
} | ||
end | ||
|
||
it { is_expected.to compile } | ||
it { is_expected.to contain_nftables__rule('default_in-llmnr_v4').with_content('iifname { "docker0", "eth0" } ip daddr 224.0.0.252 udp dport 5355 accept comment "allow LLMNR"') } | ||
it { is_expected.to contain_nftables__rule('default_in-llmnr_v6').with_content('iifname { "docker0", "eth0" } ip6 daddr ff02::1:3 udp dport 5355 accept comment "allow LLMNR"') } | ||
end | ||
end | ||
end | ||
end |