Linux server restricts IP access

Reprinted from: http://blog.163.com/yuzhongfeiyan338@126/blog/static/3868832320106810188355/

Recently a bonus event was launched on the server, so some people attack the server every day. Here is a brief introduction to restricting the designated IP way to access.
The command for a single IP is iptables -I INPUT -s 59.151.119.180 -j The command to
DROP

the IP segment is
iptables -I INPUT -s 211.1.0.0/16 -j DROP
iptables -I INPUT -s 211.2.0.0/16 -j DROP
iptables -I INPUT -s 211.3.0.0/16 -j

The command to DROP the entire segment is
iptables -I INPUT -s 211.0.0.0/8 -j

The command to DROP several segments is
iptables -I INPUT -s 61.37. 80.0/24 -j DROP
iptables -I INPUT -s 61.37.81.0/24 -j DROP

server starts and runs automatically
There are three methods:
1. Add it to /etc/rc.local
2. iptables-save >;/etc/sysconfig/iptables can put your current iptables rules in /etc/sysconfig/iptables, which will be executed automatically when the system starts iptables.
3. Service iptables save can also put your current iptables rules in /etc/sysconfig/iptables, which will be executed automatically when the system starts iptables.
The latter two are better. Generally, the iptables service will start before the network service, which is safer to

unpack :
iptables -L INPUT
iptables -L --line-numbers and then iptables -D INPUT serial number

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327063025&siteId=291194637