mirror of
https://github.com/speatzle/nfsense.git
synced 2025-09-13 15:19:08 +00:00
initial nftables config generation test
This commit is contained in:
parent
ba99844ae4
commit
b279746017
17 changed files with 215 additions and 0 deletions
0
pkg/nftables/template/addresses.tmpl
Normal file
0
pkg/nftables/template/addresses.tmpl
Normal file
3
pkg/nftables/template/destination_nat_rules.tmpl
Normal file
3
pkg/nftables/template/destination_nat_rules.tmpl
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{range $rule := .Netfilter.DestinationNATRules}}
|
||||
{{template "rule_match.tmpl" .Match}} {{ if $rule.Counter }} counter {{ end }} {{ if ne $rule.Comment "" }} comment "{{ $rule.Comment }}" {{ end }}
|
||||
{{end}}
|
3
pkg/nftables/template/forward_rules.tmpl
Normal file
3
pkg/nftables/template/forward_rules.tmpl
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{range $rule := .Netfilter.ForwardRules}}
|
||||
{{template "rule_match.tmpl" .Match}} {{ if $rule.Counter }} counter {{ end }} {{ if ne $rule.Comment "" }} comment "{{ $rule.Comment }}" {{ end }}
|
||||
{{end}}
|
0
pkg/nftables/template/inbound_rules.tmpl
Normal file
0
pkg/nftables/template/inbound_rules.tmpl
Normal file
48
pkg/nftables/template/nftables.tmpl
Normal file
48
pkg/nftables/template/nftables.tmpl
Normal file
|
@ -0,0 +1,48 @@
|
|||
#!/usr/sbin/nft -f
|
||||
|
||||
flush ruleset
|
||||
|
||||
# Address object ipsets
|
||||
{{template "addresses.tmpl" .}}
|
||||
|
||||
# nfsense nftables inet (ipv4 + ipv6) table
|
||||
table inet nfsense_inet {
|
||||
|
||||
# Inbound Rules
|
||||
chain inbound {
|
||||
type filter hook input priority 0; policy drop;
|
||||
|
||||
# Allow traffic from established and related packets, drop invalid
|
||||
ct state vmap { established : accept, related : accept, invalid : drop }
|
||||
|
||||
# allow loopback traffic, anything else jump to chain for further evaluation
|
||||
iifname vmap { lo : accept, $DEV_WORLD : jump inbound_world, $DEV_PRIVATE : jump inbound_private }
|
||||
|
||||
{{template "inbound_rules.tmpl" .}}
|
||||
}
|
||||
|
||||
# Forward Rules
|
||||
chain forward {
|
||||
type filter hook forward priority 0; policy drop;
|
||||
|
||||
# Allow traffic from established and related packets, drop invalid
|
||||
ct state vmap { established : accept, related : accept, invalid : drop }
|
||||
|
||||
{{template "forward_rules.tmpl" .}}
|
||||
}
|
||||
|
||||
# Destination NAT Rules
|
||||
chain prerouting {
|
||||
type nat hook prerouting priority -100; policy accept;
|
||||
|
||||
{{template "destination_nat_rules.tmpl" .}}
|
||||
}
|
||||
|
||||
# Source NAT Rules
|
||||
chain postrouting {
|
||||
type nat hook postrouting priority 100; policy accept;
|
||||
|
||||
{{template "source_nat_rules.tmpl" .}}
|
||||
}
|
||||
}
|
||||
|
1
pkg/nftables/template/rule_match.tmpl
Normal file
1
pkg/nftables/template/rule_match.tmpl
Normal file
|
@ -0,0 +1 @@
|
|||
tcp dport {{ .TCPDestinationPort }}
|
3
pkg/nftables/template/source_nat_rules.tmpl
Normal file
3
pkg/nftables/template/source_nat_rules.tmpl
Normal file
|
@ -0,0 +1,3 @@
|
|||
{{range $rule := .Netfilter.SourceNATRules}}
|
||||
{{template "rule_match.tmpl" .Match}} {{ if $rule.Counter }} counter {{ end }} {{ if ne $rule.Comment "" }} comment "{{ $rule.Comment }}" {{ end }}
|
||||
{{end}}
|
Loading…
Add table
Add a link
Reference in a new issue