When we have our own linux Services, a lot of operations require a little linux Foundation. It is not as simple as using people's virtual hosts in the past... Uncle often met some wonderful people. In order not to allow their access, he had to prohibit access from some IP addresses... What should I do in linux? In fact, the method is very simple! After logging on to root through ssh
Run the following command to disable access from an IP address:
Iptables-I INPUT-s ***. ***-j DROP
To unban access from an IP address, you must run the following command:
Iptables-d input-s ***. ***-j DROP
The difference between the two commands is that "-I" represents Insert (add), and "-D" represents Delete (Delete)
You can use these two commands to simply disable and unban access rules for an IP address!
Run the following command:
Iptables-list
You can view the IP rule table of the current linux server
To clear the IP rule table on the current server, run the following command:
Iptables-flush
To ban an IP segment, run the following command:
Iptables-I INPUT-s 121.0.0.0/8-j DROP
Run the following command:
Iptables-L
Check whether the rule has taken effect.
Finally, you can save and restart iptables.
/Etc/rc. d/init. d/iptables save
Service iptables restart
Appendix: other common commands
Edit The iptables file
Vi/etc/sysconfig/iptables
Disable/enable/restart firewall
/Etc/init. d/iptables stop
# Start
# Restart
Verify that all rules have taken effect:
Iptables-L
Save and restart iptables
/Etc/rc. d/init. d/iptables save
Service iptables restart