Firewall related under CentOS7

This article is for personal notes only

  • Iptables related: (After changing the configuration, you need to run /etc/rc.d/init.d/iptables save and service iptables restart to make the configuration take effect)
    • iptables-save (Save the currently changed firewall rules, remember to run the last rule after changing the rules, otherwise the configuration will be lost after restart)
    • iptables -L (list current firewall rules)
    • iptables -F (clears the rules of all rule chains in the preset table filter)
    • iptables -X (clears the rules in the user-defined chain in the default table filter)
    • iptables -P [INPUT/OUTPUT/FORWARD] [DROP/ACCEPT]
    • iptables -A [INPUT/OUTPUT/FORWARD] -p tcp –dport [0-n] -j [DROP/ACCEPT]
    • Allow icmp packets to pass to allow ping
    • iptables -A OUTPUT -p icmp -j ACCEPT
    • iptables -A INPUT -p icmp -j ACCEPT
    • Only allow the specified ip to access a port (for example: specify 172.31.18.47 to access port 6379)
    • iptables -I INPUT -p tcp –dport 6379 -j DROP
    • iptables -I FORWARD -p tcp –dport 6379 -j DROP
    • iptables -I INPUT -s 172.31.18.47/24 -p tcp –dport 6379 -j ACCEPT
    • iptables -I FORWARD -s 172.31.18.47/24 -p tcp –dport 6379 -j ACCEPT
    • turn off firewall
    • systemctl stop firewalld.service
    • systemctl disable firewalld.service

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325390124&siteId=291194637