It's iptables that you are going to use & it's already there.
Run iptables -L to see the list of current rules. Then look at the site above for other command line options.
Side note: iptables is very complicated & I always recommend that a router or other hardware be used as a firewall. However, if you want the experience, have fun.
How do you know when a politician is lying? His mouth is moving.