Prosody/iptables

From MattWiki
Jump to: navigation, search

Below is the iptables config file for Prosody, it may be applied by running the following command:

iptables-apply /etc/iptables.conf

This configuration will open the following ports to the internet

  • Port 22 - SSH Secure Shell
  • Port 80 - HTTP Web Server
  • Port 443 - TLS HTTP Web Server & TLS XMPP Client Port
  • Port 5222 - XMPP Client Port
  • Port 5223 - XMPP TLS Client Port
  • Port 5269 - XMPP Server Port
  • Port 5280 - XMPP Server HTTP Web Server
  • Port 5269 - XMPP TLS HTTP Web Server

The below configuration will allow standard web traffic, secure web traffic, ssh traffic, and prosody. This file should be stored as /etc/iptables.conf

*filter
:INPUT DROP [1:40]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [249:113407]
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5222 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5223 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5269 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5280 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5281 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5222 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5223 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5269 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5280 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 5281 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 53 -j ACCEPT
-A INPUT -p udp -m udp --dport 53 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
-A OUTPUT -o lo -j ACCEPT
COMMIT