10 |
10 |
context 'as router' do
|
11 |
11 |
let(:pre_condition) do
|
12 |
12 |
"""
|
|
13 |
# inet-filter-chain-ingoing
|
|
14 |
nftables::chain{ 'ingoing':
|
|
15 |
inject => '20-default_fwd',
|
|
16 |
inject_iif => 'eth0',
|
|
17 |
inject_oif => 'eth1';
|
|
18 |
}
|
|
19 |
|
13 |
20 |
# inet-filter-chain-default_fwd
|
14 |
21 |
nftables::rule{
|
15 |
22 |
'default_fwd-out':
|
... | ... | |
18 |
25 |
'default_fwd-drop':
|
19 |
26 |
order => '90',
|
20 |
27 |
content => 'iifname eth0 drop';
|
21 |
|
'default_fwd-in_web':
|
22 |
|
order => '30',
|
23 |
|
content => 'iifname eth0 oifname eth1 ip daddr 192.0.2.2 tcp dport { http, https } accept';
|
24 |
|
'PREROUTING-in_web':
|
|
28 |
|
|
29 |
'ingoing-web':
|
|
30 |
order => '10',
|
|
31 |
content => 'ip daddr 192.0.2.2 tcp dport { http, https } accept';
|
|
32 |
'PREROUTING-web':
|
25 |
33 |
table => 'ip-nat',
|
26 |
34 |
order => '30',
|
27 |
35 |
content => 'iifname eth0 tcp dport { http, https } dnat to 192.0.2.2';
|
... | ... | |
52 |
60 |
:content => /^ iifname eth1 oifname eth0 accept$/,
|
53 |
61 |
:order => '20',
|
54 |
62 |
)}
|
55 |
|
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-in_web').with(
|
|
63 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-jump_ingoing').with(
|
56 |
64 |
:target => 'nftables-inet-filter-chain-default_fwd',
|
57 |
|
:content => /^ iifname eth0 oifname eth1 ip daddr 192.0.2.2 tcp dport \{ http, https \} accept$/,
|
58 |
|
:order => '30',
|
|
65 |
:content => /^ iifname eth0 oifname eth1 jump ingoing$/,
|
|
66 |
:order => '20',
|
59 |
67 |
)}
|
60 |
68 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-default_fwd-rule-drop').with(
|
61 |
69 |
:target => 'nftables-inet-filter-chain-default_fwd',
|
... | ... | |
68 |
76 |
:order => '99',
|
69 |
77 |
)}
|
70 |
78 |
|
|
79 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-ingoing-header').with(
|
|
80 |
:target => 'nftables-inet-filter-chain-ingoing',
|
|
81 |
:content => /^chain ingoing {$/,
|
|
82 |
:order => '00',
|
|
83 |
)}
|
|
84 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-ingoing-rule-web').with(
|
|
85 |
:target => 'nftables-inet-filter-chain-ingoing',
|
|
86 |
:content => /^ ip daddr 192.0.2.2 tcp dport \{ http, https \} accept$/,
|
|
87 |
:order => '10',
|
|
88 |
)}
|
|
89 |
it { is_expected.to contain_concat__fragment('nftables-inet-filter-chain-ingoing-footer').with(
|
|
90 |
:target => 'nftables-inet-filter-chain-ingoing',
|
|
91 |
:content => /^}$/,
|
|
92 |
:order => '99',
|
|
93 |
)}
|
|
94 |
|
71 |
95 |
it { is_expected.to contain_concat('nftables-ip-nat-chain-PREROUTING').with(
|
72 |
96 |
:path => '/etc/nftables/puppet/ip-nat-chain-PREROUTING.nft',
|
73 |
97 |
:owner => 'root',
|
... | ... | |
90 |
114 |
:content => /^ policy accept$/,
|
91 |
115 |
:order => '02',
|
92 |
116 |
)}
|
93 |
|
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-in_web').with(
|
|
117 |
it { is_expected.to contain_concat__fragment('nftables-ip-nat-chain-PREROUTING-rule-web').with(
|
94 |
118 |
:target => 'nftables-ip-nat-chain-PREROUTING',
|
95 |
119 |
:content => /^ iifname eth0 tcp dport \{ http, https \} dnat to 192.0.2.2$/,
|
96 |
120 |
:order => '30',
|