Настраиваю iptables на сервере Debian 6 (VPS, KVM).
На сервере снаружи нужна видимость только nginx(80) и ssh(22).
Также, нужно обеспечить работу sendmail(25,587)
Установил правила
CODE (bash):
скопировать код в буфер обмена
скопировать код в буфер обмена
- #!/bin/bash
- # сбрасываем все ранее установленные правила
- iptables -F
- iptables -t nat -F
- iptables -t mangle -F
- iptables -X
- iptables -t nat -X
- iptables -t mangle -X
- # по умолчанию
- iptables -P INPUT DROP
- iptables -P OUTPUT ACCEPT
- iptables -P FORWARD DROP
- iptables -A INPUT -i lo -j ACCEPT
- iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
- iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT
- iptables -A INPUT -p tcp --dport 25 -j ACCEPT
- iptables -A INPUT -p tcp --sport 25 -j ACCEPT
- iptables -A INPUT -p udp --dport 25 -j ACCEPT
- iptables -A INPUT -p udp --sport 25 -j ACCEPT
- iptables -A OUTPUT -p tcp --dport 25 -j ACCEPT
- iptables -A OUTPUT -p tcp --sport 25 -j ACCEPT
- iptables -A OUTPUT -p udp --dport 25 -j ACCEPT
- iptables -A OUTPUT -p udp --sport 25 -j ACCEPT
- iptables -A INPUT -p tcp --dport 587 -j ACCEPT
- iptables -A INPUT -p tcp --sport 587 -j ACCEPT
- iptables -A INPUT -p udp --dport 587 -j ACCEPT
- iptables -A INPUT -p udp --sport 587 -j ACCEPT
- iptables -A OUTPUT -p tcp --dport 587 -j ACCEPT
- iptables -A OUTPUT -p tcp --sport 587 -j ACCEPT
- iptables -A OUTPUT -p udp --dport 587 -j ACCEPT
- iptables -A OUTPUT -p udp --sport 587 -j ACCEPT