https://blog.csdn.net/zht666/article/details/17505789

    1. cat >/bin/iptables.sh <<EOF
    2. #!/bin/bash
    3. iptables -F
    4. iptables -t nat -F
    5. #### Below are the basal iptables config, normally need not be modified #######
    6. iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT
    7. iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
    8. iptables -A INPUT -p icmp --icmp-type echo-reply -j ACCEPT
    9. iptables -A INPUT -p icmp --icmp-type echo-request -j ACCEPT
    10. iptables -A INPUT -p udp --source-port 53 -j ACCEPT
    11. iptables -A INPUT -p tcp --dport 62222 -j ACCEPT
    12. iptables -A INPUT -p tcp --dport 22 -j ACCEPT
    13. ##### Below are the Appalication related iptables config #######
    14. iptables -A INPUT -s 192.168.5.0/24 -j ACCEPT
    15. iptables -A INPUT -p tcp --dport 80 -j ACCEPT
    16. iptables -A INPUT -p tcp --dport 443 -j ACCEPT
    17. iptables -A INPUT -j DROP
    18. iptables -A FORWARD -j DROP
    19. EOF
    20. systemctl enable iptables.service
    21. systemctl restart iptables.service
    22. sh /bin/iptables.sh
    23. echo 'sh /bin/iptables.sh' >> /etc/rc.local
    1. ###
    2. # -- 查找所有input规则
    3. iptables -L INPUT --line-numbers
    4. #-- 删除一条规则
    5. iptables -D INPUT 11 #(注意,这个11是行号,是iptables -L INPUT --line-numbers 所打印出来的行号)
    6. #iptables 四表五链
    7. # https://www.cnblogs.com/zhujingzhi/p/9706664.html