|
|
195495 |
# Sample configuration for nftables service.
|
|
|
195495 |
# Load this by calling 'nft -f /etc/nftables/main.nft'.
|
|
|
195495 |
|
|
|
195495 |
# Note about base chain priorities:
|
|
|
195495 |
# The priority values used in these sample configs are
|
|
|
195495 |
# offset by 20 in order to avoid ambiguity when firewalld
|
|
|
195495 |
# is also running which uses an offset of 10. This means
|
|
|
195495 |
# that packets will traverse firewalld first and if not
|
|
|
195495 |
# dropped/rejected there will hit the chains defined here.
|
|
|
195495 |
# Chains created by iptables, ebtables and arptables tools
|
|
|
195495 |
# do not use an offset, so those chains are traversed first
|
|
|
195495 |
# in any case.
|
|
|
195495 |
|
|
|
195495 |
# drop any existing nftables ruleset
|
|
|
195495 |
flush ruleset
|
|
|
195495 |
|
|
|
195495 |
# a common table for both IPv4 and IPv6
|
|
|
195495 |
table inet nftables_svc {
|
|
|
195495 |
|
|
|
195495 |
# protocols to allow
|
|
|
195495 |
set allowed_protocols {
|
|
|
195495 |
type inet_proto
|
|
|
195495 |
elements = { icmp, icmpv6 }
|
|
|
195495 |
}
|
|
|
195495 |
|
|
|
195495 |
# interfaces to accept any traffic on
|
|
|
195495 |
set allowed_interfaces {
|
|
|
195495 |
type ifname
|
|
|
195495 |
elements = { "lo" }
|
|
|
195495 |
}
|
|
|
195495 |
|
|
|
195495 |
# services to allow
|
|
|
195495 |
set allowed_tcp_dports {
|
|
|
195495 |
type inet_service
|
|
|
195495 |
elements = { ssh, 9090 }
|
|
|
195495 |
}
|
|
|
195495 |
|
|
|
195495 |
# this chain gathers all accept conditions
|
|
|
195495 |
chain allow {
|
|
|
195495 |
ct state established,related accept
|
|
|
195495 |
|
|
|
195495 |
meta l4proto @allowed_protocols accept
|
|
|
195495 |
iifname @allowed_interfaces accept
|
|
|
195495 |
tcp dport @allowed_tcp_dports accept
|
|
|
195495 |
}
|
|
|
195495 |
|
|
|
195495 |
# base-chain for traffic to this host
|
|
|
195495 |
chain INPUT {
|
|
|
195495 |
type filter hook input priority filter + 20
|
|
|
195495 |
policy accept
|
|
|
195495 |
|
|
|
195495 |
jump allow
|
|
|
195495 |
reject with icmpx type port-unreachable
|
|
|
195495 |
}
|
|
|
195495 |
}
|
|
|
195495 |
|
|
|
195495 |
# By default, any forwarding traffic is allowed.
|
|
|
195495 |
# Uncomment the following line to filter it based
|
|
|
195495 |
# on the same criteria as input traffic.
|
|
|
195495 |
#include "/etc/nftables/router.nft"
|
|
|
195495 |
|
|
|
195495 |
# Uncomment the following line to enable masquerading of
|
|
|
195495 |
# forwarded traffic. May be used with or without router.nft.
|
|
|
195495 |
#include "/etc/nftables/nat.nft"
|