To increase server uptime and ensure security, closing security vulnerabilities is critical. In this article, we will go step-by-step through the installation of a firewall, DDoS protection, and Web Application Firewall (WAF) in a Linux environment.
1. Firewall Installation
Common firewalls in Linux servers include iptables or firewalld. Below is a basic configuration example using iptables:
1.1. Installing iptables
First, ensure that iptables is installed:
sudo apt-get install iptables
1.2. Basic Setup
Add the following rules to configure your firewall:
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
sudo iptables -A INPUT -j DROP
These rules allow traffic only from specified ports and block others.
2. DDoS Protection
To protect against DDoS attacks, you can use a combination of fail2ban and iptables.
2.1. Installing fail2ban
fail2ban is a tool that blocks IP addresses after a certain number of failed login attempts:
Add the following line to your Apache or Nginx configuration file:
Include /usr/local/nginx/conf/coreruleset/rules/*.conf
Conclusion
These steps will help you create a basic security structure to increase your server's uptime and ensure its security. Remember, security is an ongoing process, and it is essential to regularly update your systems to keep them protected.