Occasionally, you may want to restrict access for specific users or specific IPs from your server. This action can greatly enhance security or prevent DDoS attacks which are quite rampant. By using iptables
on Ubuntu, you can limit access to the server based on the source IP and only allow specific IPs to access it.
By executing the command below, you can block access from a specific IP:
# Blocking a specific IP
sudo iptables -A INPUT -s -j DROP
🔵 -A INPUT:
This is used to add a rule to the list of incoming traffic rules.
🔵 -s :
This is the IP you want to block.
🔵 -j DROP:
This command will cause traffic from this IP to be dropped.
Practical Example: Assume you want to prevent brute-force attacks or unauthorized attempts to access the server. By using iptables
, you can block the IPs that frequently try to access your server. This will restrict access to your server and improve the system's security.