Hardware will be more secure and its helps to keep the server online when you are getting attack. because hardware means a server or machine which is dedicated to working only for Firewall.
all operating systems are comes with default software firewall. ie, iptables in Linux, windows firewall in windows. But you have to configure it as per your requirements. By default, it will allow all connections.
cPanel Web hosting companies usually using CSF to configure the iptables.
Dedicated server provider companies usually using hardware firewall to protect the servers and network from attack like DDoS.
██ Rack&Cloud Hosting Solutions
| Enterprise Dedicated Server Provider
| 24/7 Technical Support
New York City Metro | Miami - Florida | Los Angles - CA
█ One Year Free Fully Managed Support with any dedicated server.