Answer the question
In order to leave comments, you need to log in
What is the best way to configure iptables in terms of performance?
Hello!
MySQL and Redis are running on a dedicated server, you need to allow access to them from trusted IPs.
My rules:
iptables -F
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT
iptables -A INPUT -s x.x.x.x -p tcp -m state --state NEW --dport 3306 -j ACCEPT
iptables -A INPUT -s x.x.x.x -p tcp -m state --state NEW --dport 6379 -j ACCEPT
iptables -P INPUT DROP
iptables -P FORWARD DROP
ip6tables -P INPUT DROP
ip6tables -P FORWARD DROP
Feb 2 22:03:04 cache kernel: [595850.616259] nf_conntrack: table full, dropping packet
Feb 2 22:03:09 cache kernel: [595855.555346] net_ratelimit: 806 callbacks suppressed
echo "net.netfilter.nf_conntrack_max=1048576" >> /etc/sysctl.conf
sysctl -p
Answer the question
In order to leave comments, you need to log in
Thanks for the help chupasaurus and arheops .
To avoid errors, you need to add the lines to /etc/sysctl.conf
net.netfilter.nf_conntrack_max = 1048576
net.netfilter.nf_conntrack_tcp_timeout_established = 3600
echo 262144 > /sys/module/nf_conntrack/parameters/hashsize
sysctl -p
1. No, netfilter is used by iptables anyway.
2. Add
echo 262144 > /sys/module/nf_conntrack/parameters/hashsize
before exit 0 in /etc/rc.local (a quarter of nf_conntrack_max). Well, do it. # sysctl -a | grep conntrack | grep timeout
), but you need to look at what netfilter clogs with.
you have this error occurs on the second rule. accordingly, if you have only mysql and redis on this server, then to speed up you just need to enable them BEFORE this rule like this.
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -s xxxx -m tcp -p tcp --dport 3306 -j ACCEPT
iptables -A INPUT -s xxxx -m tcp -p tcp --dport 6379 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question