This article has not been completed yet. However, it may already contain   helpful Information and therefore it has been published at this stage.

# Installing iptables
sudo apt-get install iptables
# Permission Evelation
sudo su
# Showing active rules
iptables -L -v
# Adding specific rules
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 514 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 514 -j ACCEPT
# Modifying the default input policy
sudo iptables -A INPUT -j DROP
# Showing active rules
iptables -L -v
# Saving iptables config
sudo /sbin/iptables-save

References:

The Beginner’s Guide to iptables, the Linux Firewall
Iptables is an extremely flexible firewall utility built for Linux operating systems. Whether you’re a novice Linux geek or a system administrator, there’s probably some way that iptables can be a great use to you. Read on as we show you how to configure the most versatile Linux firewall.

https://www.cyberciti.biz/tips/linux-iptables-4-block-all-incoming-traffic-but-allow-ssh.html