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