Nowadays, cyber attacks are one of the biggest threats to businesses and individuals. Especially VDS servers, are highly targeted systems. In this article, we will perform DDoS protection and firewall setup on your VDS server step by step.
Step 1: Update Your Server
First of all, make sure your server is up to date. Connect to your server using SSH:
ssh root@server_ip_address
Then, update your system with the following commands:
yum update -y
Step 2: Install Required Packages
Install the required iptables and fail2ban packages for DDoS protection and firewall:
yum install iptables-services fail2ban -y
Step 3: Firewall Setup with Iptables
Create a basic firewall configuration with iptables:
iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A INPUT -j DROP
To save your configuration:
service iptables save
Step 4: Configuring Fail2ban
Fail2ban monitors login attempts and blocks malicious access. To configure Fail2ban:
nano /etc/fail2ban/jail.conf
Configure the following settings:
[sshd]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/secure
maxretry = 5
bantime = 86400
Finally, start Fail2ban:
service fail2ban start
Step 5: Using Cloudflare for DDoS Protection
To enhance DDoS protection, you can use a service like Cloudflare. Create a Cloudflare account and add your domain. Update your DNS settings to route your traffic through Cloudflare.
Conclusion
By following these steps, you have implemented cyber security measures on your VDS server. Remember, cyber security is an ongoing process, and it's important to review your system regularly.