First check if iptables is installed
$ service iptables status
$ yum install iptables
$ yum update iptables
$ yum install iptables-services
$ vi /etc/sysconfig/iptables-config
iptables -I INPUT -p tcp --dport 5672-j ACCEPT
iptables -I INPUT -p tcp --dport 15672-j ACCEPT
$ service iptables save
Read on for more operations
systemctl restart iptables.service
$ vi /etc/sysconfig/iptables-config
View iptables existing rules
iptables -L -n
Allow all
iptables -P INPUT ACCEPT
Allow IO access
Allow data packets from the lo interface (local access)
iptables -A INPUT -i lo -j ACCEPT
Open port 443 (TCP)
iptables -A INPUT -p tcp --dport 443-j ACCEPT
Open port 443 (FTP)
iptables -A INPUT -p tcp --dport 443-j ACCEPT
Open port 80 (HTTP)
iptables -A INPUT -p tcp --dport 80-j ACCEPT
Open port 443 (HTTPS)
iptables -A INPUT -p tcp --dport 443-j ACCEPT
Allow ping
iptables -A INPUT -p icmp --icmp-type 8-j ACCEPT
Allow response
Allow the return data RELATED after accepting the request of the machine, which is set for FTP
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
Discard all inbound
iptables -P INPUT DROP
Allow all outbound
iptables -P OUTPUT ACCEPT
Forward and discard
iptables -P FORWARD DROP
Purge rules
iptables -F #Clear all default rules
iptables -X #Clear all custom rules
iptables -Z #All counters return to 0
Save configuration
$ service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
Open service
$ systemctl start firewalld
Check status
$ service iptables status
Out of service
$ systemctl stop firewalld
Restart service
$ systemctl restart iptables.service
View rules
iptables -L -n
Mark display
$ iptables -L -n --line-numbers
Chain INPUT(policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp --0.0.0.0/00.0.0.0/0 tcp dpt:156722 ACCEPT tcp --0.0.0.0/00.0.0.0/0 tcp dpt:5672
Delete rule
iptables -D INPUT 1
Disable service
$ systemctl mask firewalld
boot
systemctl enable iptables.service
Recommended Posts