iptables or nftables. Or firewalld depending on the Linux distro and version you use.
Sometimes the Arch Wiki has some good info on specific configurations. I mean it’s not that easy to write firewall rules on the command line. But it’s no rocket science either.