Last update at :2024-04-25,Edit by888u
Iptables is a basic component of Linux. It is mainly used in firewall applications, such as banning access to a certain IP or banning some ports to improve website security. Under normal circumstances, the system will install it by default. If it is not installed, you can install it yourself:
yum install iptables #centos system
apt-get install iptables #debian/ubuntu system
1. Let’s talk about some common commands:
service iptables -status #Check whether iptables is running
iptables -F #Capital F, clear all current rules
iptables-save #Note that there is no space between s- to save the current rules
iptables -L -n #List displays current rules
2. Common IP blocking commands:
iptables -A INPUT -s 123.45.67.89 -j DROP #Block a single IP address
#To shield the entire segment (class A address) from 192.0.0.1 to 192.255.255.254, add the following rules.
iptables -I INPUT -s 192.0.0.0/8 -j DROP
#Block the IP segment (Class B address) from 192.168.0.1 to 192.168.255.254, then add the following rules.
iptables -I INPUT -s 192.168.0.0/16 -j DROP
#Block the IP segment (Class C address) from 192.168.200.1 to 192.168.200.254, then add the following rules.
iptables -I INPUT -s 192.168.200.0/24 -j DROP
3. View and delete commands:
iptables -L -n --line-numbers #Display current rules in line list
iptables -D INPUT 15 #Delete rule 15
Please note that after making any modifications, you must save and restart, otherwise they will become invalid.
service iptables save
service iptables restart
Recommended site searches: check IP online, how to rent a server, foreign host shopping guide, anti-attack IP, buy high-defense server, German server, IP segment query, website registration domain name query, Taiwan proxy server, Hong Kong server ,
发表评论