
나는 nat DNAT를 사용하여 GRE 터널을 통해 특정 포트의 트래픽을 다른 Centos 서버로 전달하고 있지만 ipset 목록 '블랙리스트'에 있는 여러 데이터 센터 IP의 속도를 제한하고 싶습니다. 따라서 터널로 출력되는 트래픽의 속도가 제한됩니다.
모든 FORWARD, INPUT 및 OUTPUT 목록에서 속도 제한을 시도했지만 속도 제한은 그 중 어느 것에서도 전혀 작동하지 않습니다. 어쩌면 nat DNAT가 이를 우회할까요?
iptables -A INPUT -m set --match-set blacklist src -p udp --dport 30000 -m hashlimit --hashlimit 10/min --hashlimit-name ratelimithash -j DROP
iptables -A FORWARD -m set --match-set blacklist src -p udp --dport 30000 -m hashlimit --hashlimit 10/min --hashlimit-name ratelimithash -j DROP
iptables -A OUTPUT -m set --match-set blacklist src -p udp --dport 30000 -m hashlimit --hashlimit 10/min --hashlimit-name ratelimithash -j DROP
'iptables -A OUTPUT -m set --match-set blacklist src -j DROP'을 통해 삭제할 목록을 추가하면 모든 트래픽이 중지되므로 내 IP ipset 목록이 속도 제한이 아닌 작동하고 있으므로 누구나 도움을 줄 수 있습니다. ?
iptables 출력:
iptables NAT 출력:
iptables 규칙
#!/bin/sh
iptables -F
sudo iptables -t nat -F
iptables -t nat -X
sudo iptables -t mangle -F
sudo iptables -t mangle -X
sudo iptables -t raw -F
sudo iptables -t raw -X
sudo iptables -t security -F
sudo iptables -t security -X
sudo iptables -F
sudo iptables -X
sudo iptables -P INPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
sudo iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
sudo iptables -A OUTPUT -p tcp --sport 22 -m conntrack --ctstate ESTABLISHED -j ACCEPT
iptables -A INPUT -m set --match-set blacklist src -p udp --dport 30000 -m hashlimit --hashlimit 10/min --hashlimit-name ratelimithash -j DROP
iptables -A FORWARD -m set --match-set blacklist src -p udp --dport 30000 -m hashlimit --hashlimit 10/min --hashlimit-name ratelimithash -j DROP
iptables -A OUTPUT -m set --match-set blacklist src -p udp --dport 30000 -m hashlimit --hashlimit 10/min --hashlimit-name ratelimithash -j DROP
iptables -t nat -A POSTROUTING -s 192.168.168.0/30 ! -o gre+ -j SNAT --to-source 20&&&&&&&&&&&&
iptables -A INPUT -s 192.168.168.2/32 -j ACCEPT
iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p gre -j ACCEPT
iptables -A OUTPUT -p gre -j ACCEPT
iptables -t nat -A PREROUTING -d 20&&&&&&&&&&&& -p udp --dport 30000 -j DNAT --to-destination 192.168.168.2
iptables -A OUTPUT -j DROP
iptables -P INPUT DROP
답변1
이것이 더 나은 규칙인 것 같습니다. 한도를 초과하여 GRE 터널을 통과하기 전에 트래픽을 중지합니다.
iptables -t mangle -A PREROUTING -p udp --dport 30000 -m set --match-set blacklist src -m hashlimit --hashlimit-mode srcip --hashlimit-srcmask 24 --hashlimit-above 100/sec --hashlimit-name test -j DROP
-hashlimit-srcmask 24 - 들어오는 트래픽을 /24 그룹으로 그룹화합니다.