A firewall can protect your server or computer from network attacks, however it does have some limitations to what it can do. One of the most important things to know about firewalls is when you can rely on them for protection and when you need additional forms of security.
Most internet attackers will scan for weaknesses in a server and look for any possible entry points, which are usually unsecured network ports. A good firewall will also have other security features that will help protect against DoS attacks as well.
The more ports you have open on a network, the more chances of having an attack on your sever. However, some ports have to remain open such as an SSH server or a web server. With these ports open, the firewall can do little to protect a sight with a weak password or poorly written scripts against possible attacks. This is why it is important to have additional security features to keep your serve safe.