Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Уточняем сетевые интерфейсы, и делим их на "внутренний" и "внешний".

...

Пример настройки iptables для конфигурации системы на одном сервере (single node):

cat > /etc/sysconfig/iptables <<EOF
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:kamailio - [0:0]
:freeswitch - [0:0]
:web - [0:0]
# prepare
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp -j ACCEPT
# accept out, established
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
#main section
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -i ${EXT_DEV} -j kamailio
-A INPUT -i ${EXT_DEV} -j freeswitch
-A INPUT -i ${EXT_DEV} -j web
# deny other
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

#
#-A kamailio -i ${EXT_DEV} -p tcp -m tcp --dport 5060 -j ACCEPT -m comment --comment "SIP traffic - TCP (disabled)"
-A kamailio -i ${EXT_DEV} -p udp -m udp --dport 5060 -j ACCEPT -m comment --comment "SIP traffic - UDP"
-A kamailio -i ${EXT_DEV} -p udp -m udp --dport 5068 -j ACCEPT -m comment --comment "SIP traffic - UDP"
-A kamailio -j RETURN
#
# 5080 - freeswitch sip port, drop it, all another ports accept
-A freeswitch -i ${EXT_DEV} -p tcp -m tcp --dport 5080 -j DROP
-A freeswitch -i ${EXT_DEV} -p udp -m udp --dport 5080 -j DROP
-A freeswitch -i ${EXT_DEV} -p udp -m udp --dport 1024:65535 -j ACCEPT -m comment --comment "RTP freeswitch + rtpengine"
-A freeswitch -j RETURN
#
-A web -i ${EXT_DEV} -p tcp -m tcp --dport 80 -j ACCEPT -m comment --comment "HTTP"
-A web -i ${EXT_DEV} -p tcp -m tcp --dport 443 -j ACCEPT -m comment --comment "HTTPS"
-A web -j RETURN
#
COMMIT
EOF

При рестарте iptables правила будут перечитаны из
/etc/sysconfig/iptables, firewalld должен быть выключен, а iptables-services установлены.
Для защиты от брутфорса 22го порта можно использовать fail2ban