Ví dụ IP cần block là: 1.2.3.4
1. Ban IP trong SSH: sử dụng server hay VPS đã cài CSF, do đó để BAN 1 IP có thể sử dụng lệnh
csf -d IP
csf -d 1.2.3.4
2. Ban 1 dãy IP trong SSH: tương tự như trên, có thể dùng lệnh
csf -d IP/[range]
[range] ở đây là dãy IP range. Đối với bạn thì chỉ cần lưu ý các dãy 24,16,8 là được.
Lệnh này sẽ block toàn bộ các IP từ 1.2.3.0 đến 1.2.3.255 [có đầu 1.2.3.*]
csf -d
1.2.3.0/24
Lệnh này sẽ block toàn bộ các IP từ 1.2.0.0 đến 1.2.255.255 [có đầu 1.2.*.*]
csf -d 1.2.0.0/16
Lệnh này sẽ block toàn bộ các IP từ 1.0.0.0 đến 1.255.255.255 [có đầu 1.*.*.*]
csf -d 1.0.0.0/8
3. Kill 1 process trong SSH:
Khi em sử dụng lệnh "top" thì cột đầu tiên của lệnh top là "ID" , đây là Process ID , bạn cần kill process nào thì sử dụng lệnh:
kill -9 [PID]
Chúc bạn thành công.
1. Ban IP trong SSH: sử dụng cPanel đã cài CSF, do đó để BAN 1 IP có thể sử dụng lệnh
csf -d IP
2. Ban 1 dải IP trong SSH: tương tự như trên, có thể dùng lệnh
csf -d IP/[range]
[range] ở đây là dãy IP range. Đối với bạn thì chỉ cần lưu ý các dãy 24,16,8 là được.
- Lấy ví dụ thực tế việc block các dải IP nhé:
csf -d 210.245.80.0/24
Lệnh này sẽ block toàn bộ các IP từ 210.245.80.0 đến 210.245.80.255
csf -d 210.245.0.0/16
Lệnh này sẽ block toàn bộ các IP từ 210.245.0.0 đến 210.245.255.255
csf -d 210.0.0.0/8
Lệnh này sẽ block toàn bộ các IP có đầu 210.*.*.*
3. Kill 1 process trong SSH:
Khi em sử dụng lệnh "top" thì cột đầu tiên của lệnh top là "ID" , đây là Process ID , bạn cần kill process nào thì sử dụng lệnh:
kill -9 [PID]
Chúc bạn thành công.
Last updated on: 2021-05-05
Authored by: Morgan Marion
A large number of requests from one IP address can deplete the server of available resources. This article provides the commands to block an IP address on three common Linux® software firewalls.
Prerequisites
- Basic understanding of commands in a Linux operating system.
- Basic understanding of Secure Shell [SSH].
- Administrative
access to your server by using the
sudo
command.
NOTE: These steps are for servers that are not RackConnect® cloud servers. For RackConnect, make changes in the dedicated firewall.
Log on to the server by using SSH and then complete the steps in the following sections.
firewalld tool
firewalld is available on the following Linux versions:
Red Hat® Enterprise Linux 7 and later.
CentOS® 7 and later.
Fedora® 18 and later.
To ensure that
firewalld
is running on your server, run the following command. Iffirewalld
is not running, go to theiptables
section.sudo systemctl status firewalld
Run the following command to block the IP address and to add the rule to the permanent set:
sudo firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='xxx.xxx.xxx.xxx' reject"
Run the following command to reload the
firewalld
rules:sudo firewall-cmd --reload
Run the following command to list and verify the new rule:
sudo firewall-cmd --list-all
Uncomplicated Firewall [UFW]
The UFW tool is available on the Ubuntu® operating system 8.04 LTS and later.
To ensure that
UFW
is running on your server, run the following command. IfUFW
is not running, go to theiptables
section.sudo systemctl status ufw
Run the following command to block the IP address:
sudo ufw deny from xxx.xxx.xxx.xxx to any
Run the following command to list and verify the new rule:
sudo ufw status
iptables tool
iptables
is commonly pre-installed on all Linux operating systems.
Run the following command to block the IP address:
sudo iptables -I INPUT -s xxx.xxx.xxx.xxx -j DROP
Run the following command to save the settings. The settings persist after the server reboots.
sudo service iptables save
Run the following command to list and verify the new rule:
sudo iptables -L
Use the Feedback tab to make any comments or ask questions. You can also start a conversation with us.
©2020 Rackspace US, Inc.
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License
See license specifics and DISCLAIMER