How to automatically save iptables rules in CentOS
Source: Internet
Author: User
1. redirection example I want to add an ip to prohibit access # Disable all ports/sbin/iptables-IINPUT-s5.39.67.46-pTCP-jDROP # Disable port 80/sbin/iptables-IINPUT-s183.2.145.98-pTCP -- dport80-jDROP1.2. redirect save/sbin/iptables-save 1. for example, if you want to add an ip address to prohibit access
# Disable all ports
/Sbin/
Iptables-I INPUT-s 5.39.67.46-p TCP-j DROP
# Disable port 80
/Sbin/iptables-I INPUT-s 183.2.145.98-p TCP -- dport 80-jDROP
1. 2. save redirection
/Sbin/iptables-save | cat>/etc/sysconfig/iptables
1. 3. restart
Service iptables restart;
2. modify the configuration file/etc/sysconfig/iptables-config
IPTABLES_SAVE_ON_STOP = no. replace "no" with "yes"
# Disable all ports
/Sbin/iptables-I INPUT-s 5.39.67.46-p TCP-j DROP
# Disable port 80
/Sbin/iptables-I INPUT-s 183.2.145.98-p TCP -- dport 80-jDROP
Service iptables restart;
In this way, the existing rules are automatically saved before the service is stopped.
Go to the/etc/sysconfig/iptables file.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service