1. Install a firewall
apt-get install ufw
2. Enable the firewall
ufw enable
3. Disable the firewall
ufw disable
4. View firewall status
ufw status
5. Allow external access to port 80
ufw allow 80
6. Delete the added rule
ufw delete allow 80
7. Allow this ip to access all ports of this machine
ufw allow from 192.168.0.105
8. Prohibit the port
uwf deny service (port)
9. View port status
lsof -i: port number
Recommended settings
APT- GET install ufw ufw enable ufw default deny # If you have special needs, to enable the service ufw allow port