
노드 내부의 iptables에 대한 일련의 규칙을 만들고 싶지만 iptables가 모든 규칙을 추가하지 않거나 다음 스크립트를 실행할 때마다 나를 쫓아내는 것 같습니다. 다른 서버에서는 잘 작동합니다):
# Allow connections that are already connected to your server
iptables -A INPUT -i venet0 -m state --state ESTABLISHED,RELATED -j ACCEPT
# Allow connections to SSH
iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT
# Allowing connections to HTTP/HTTPS
iptables -A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -m state --state NEW -j ACCEPT
# Allow icmp input but limit it to 10/sec
iptables -A INPUT -p icmp -m limit --limit 10/second -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
# Allow all incoming traffic from local
iptables -A INPUT -i lo -j ACCEPT
# Changing the default policy for INPUT chain
iptables -A INPUT -j DROP
내가 발견한 문제는 마지막 줄(아무거나 DROP)이 하나로 해석되어 서버가 나를 쫓아낸다는 것입니다.
나는 이미 vz에 대한 conf를 변경했습니다.
IPTABLES_MODULES="ipt_REJECT ipt_tos ipt_limit ipt_multiport iptable_filter iptable_mangle ipt_TCPMSS ipt_tcpmss ipt_ttl ipt_length ipt_state xt_state ip_conntrack"
이에 대한 도움을 주시면 감사하겠습니다.
감사해요.
답변1
OpenVZ 및 "ESTABLISHED, RELATED"를 사용하여 더 많은 문제를 확인했습니다. 안타깝게도 어떤 이유로 컨테이너에서 상태 저장 iptables를 허용하지 않는 OpenVZ 설치를 수정하는 방법을 찾을 수 없었습니다.
그러나 합리적으로 간단한 IPTable 규칙을 사용하여 상태 저장이 정말로 필요합니까? 나는 다음이 잘 작동할 것이라고 생각합니다:
# Allow connections to SSH
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# Allowing connections to HTTP/HTTPS
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# Allow icmp input but limit it to 10/sec
iptables -A INPUT -p icmp -m limit --limit 10/second -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
# Allow all incoming traffic from local
iptables -A INPUT -i lo -j ACCEPT
# Changing the default policy for INPUT chain
iptables -A INPUT -j DROP