delete all rules from iptables

3k views Asked by At

I'm make a shell script have some rules to limit connection on port Then it's effect badly on my vps

Script :

#!/bin/bash
# Window of time in seconds
SECS=60
# Max connections per IP
MAXCONN=5
iptables -A INPUT -p tcp --syn --dport 5222 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --syn --dport 5222 -m state --state NEW -m recent --update --seconds ${SECS} --hitcount ${MAXCONN} -j REJECT
iptables -A INPUT -p tcp --syn --dport 5223 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --syn --dport 5223 -m state --state NEW -m recent --update --seconds ${SECS} --hitcount ${MAXCONN} -j REJECT
iptables -A INPUT -p tcp --syn --dport 5224 -m state --state NEW -m recent --set
iptables -A INPUT -p tcp --syn --dport 5224 -m state --state NEW -m recent --update --seconds ${SECS} --hitcount ${MAXCONN} -j REJECT

And I need to remove all this rules

How can I do this?

1

There are 1 answers

0
Jerry Z. On

To run this command to flush all the rules:

iptables -F

This command will print all the rules:

iptables -L -n -v

Following command is to save firewall change

service iptables save