#!/usr/sbin/nft --file flush ruleset table inet my_filter { chain my_input { type filter hook input priority filter policy drop jump my_prologue comment "deal with boring conntrack/loopback/ICMP/ICMPv6" tcp dport ssh accept jump my_epilogue } chain my_forward { type filter hook forward priority filter policy drop jump my_prologue comment "deal with boring conntrack/loopback/ICMP/ICMPv6" jump my_epilogue } chain my_prologue { ct state vmap { established: accept, related: accept, invalid: drop } ct status dnat accept iiftype loopback accept icmp type echo-request accept icmpv6 type { echo-request, nd-neighbor-solicit } accept } chain my_epilogue { iiftype != ppp reject comment "be polite (reject, not drop) to local networks" } } table ip my_nat { chain my_postrouting { type nat hook postrouting priority srcnat policy accept oiftype ppp masquerade } chain my_prerouting { type nat hook prerouting priority dstnat policy accept iiftype != ppp return comment "port forwards are only relevant from the internet" define www.example.com = 127.1.2.3 define mail.example.com = 127.254.253.252 tcp dport { http, https } dnat to $www.example.com tcp dport { smtp, submission, imaps } dnat to $mail.example.com } } list ruleset