<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Iptables on nagg.eu</title><link>https://nagg.eu/tags/iptables/</link><description>Recent content in Iptables on nagg.eu</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 14 Nov 2016 18:36:53 +0000</lastBuildDate><atom:link href="https://nagg.eu/tags/iptables/index.xml" rel="self" type="application/rss+xml"/><item><title>Ejabberd HTTP File Upload (XEP-0363)</title><link>https://nagg.eu/ejabberd-http-file-upload-xep-0363/</link><pubDate>Mon, 14 Nov 2016 18:36:53 +0000</pubDate><guid>https://nagg.eu/ejabberd-http-file-upload-xep-0363/</guid><description>&lt;p&gt;XMPP module HTTP File Upload (formerly XEP-0363) provides a way to share files
between XMPP clients, it works transparently and even in multi user chats.&lt;br&gt;
The sender uploads a file on an HTTP(S) server that will then generate an URI,
this is sent to each one of the recipients that can then download it.&lt;br&gt;
The interesting bits about this XEP are various:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;File sharing now works even in multi-user chats (MUC), in any case the file
is only uploaded a single time even if the recipients are more than one.&lt;/li&gt;
&lt;li&gt;Peer-to-peer file transfer, be it in-band (XEP-0234: Jingle File Transfer)
or out-of-band (XEP-0065: SOCKS5 Bytestreams), is slow, unreliable, does not
work in MUC and does not work if the recipient is offline.&lt;br&gt;
HTTP File Upload supports both client-server encryption (HTTPS) and end-to-end
encryption when used in conjunction with OMEMO encryption (as per today this is
supported by Conversations on Android and Gajim desktop client).&lt;br&gt;
3.1. When using OMEMO encryption the files are stored encrypted on the server,
this makes it impossibile for ejabberd to create a thumbnail if the file sent
is a picture.&lt;br&gt;
To enable HTTP File Upload module with HTTPS enabled in ejabberd edit
&lt;code&gt;ejabberd.yml&lt;/code&gt; configuration file: &amp;gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;listen:
 -
 port: 5443
 ip: &amp;#34;0.0.0.0&amp;#34;
 module: ejabberd_http
 request_handlers:
 &amp;#34;upload&amp;#34;: mod_http_upload
 tls: true
 protocol_options: &amp;#39;TLS_OPTIONS&amp;#39;
 dhfile: &amp;#39;DH_FILE&amp;#39;
 ciphers: &amp;#39;TLS_CIPHERS&amp;#39;

modules:
 mod_http_upload:
 docroot: &amp;#34;/home/ejabberd/upload&amp;#34; # this must be a valid path, user ownership and SELinux flags must be set accordingly
 put_url: &amp;#34;https://@HOST@:5443/upload&amp;#34;
 access: local
 max_size: 25000000 #25 MByte
 thumbnail: false
 file_mode: &amp;#34;0644&amp;#34;
 dir_mode: &amp;#34;0744&amp;#34;
 mod_http_upload_quota:
 max_days: 2

shaper:
 soft_upload_quota:
 - 250: all # MiB
 hard_upload_quota:
 - 10000: all # MiB

define_macro:
 &amp;#39;TLS_CIPHERS&amp;#39;: &amp;#34;ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256&amp;#34;
 &amp;#39;TLS_OPTIONS&amp;#39;:
 - &amp;#34;no_sslv2, no_sslv3, no_tlsv1&amp;#34;
 - &amp;#34;ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256&amp;#34;
 - &amp;#34;no_compression&amp;#34;
 &amp;#39;DH_FILE&amp;#39;: &amp;#34;/usr/local/etc/ejabberd/dhparams.pem&amp;#34; # generated with: openssl dhparam -out dhparams.pem 4096
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Add an &lt;code&gt;iptables&lt;/code&gt; rule to allow traffic coming from port &lt;code&gt;TCP 5443&lt;/code&gt;:&lt;/p&gt;</description></item><item><title>ejabberd and fail2ban</title><link>https://nagg.eu/ejabberd-and-fail2ban/</link><pubDate>Wed, 16 Sep 2015 18:54:42 +0000</pubDate><guid>https://nagg.eu/ejabberd-and-fail2ban/</guid><description>&lt;p&gt;Fail2ban is a useful tool capable of mitigating brute force attacks performed
against a multitude of services (ejabberd in our case).&lt;br&gt;
Configuration is split between a multitude of files: &lt;code&gt;jail.conf&lt;/code&gt; defines which
filters are active while the filters scripts are placed in &lt;code&gt;./filter.d&lt;/code&gt; directory.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;[root@CentOS ~]# vi /etc/fail2ban/jail.conf
---
bantime = 1200
findtime = 1200
maxretry = 10

backend = auto

[ejabberd-auth]
enabled = true
port = 5222,5280,7777
action = iptables-multiport[name=ejabberd, port=&amp;#34;5222,5269,5280,777&amp;#34;, protocol=tcp]
logpath = /var/log/ejabberd/ejabberd.log
---
&lt;/code&gt;&lt;/pre&gt;&lt;pre tabindex="0"&gt;&lt;code&gt;[root@CentOS ~]# vi /etc/fail2ban/filter.d/ejabberd-auth.conf
---
[Definition]

failregex = ^=INFO REPORT====  ===\nI\(&amp;lt;0\.\d+\.0&amp;gt;:ejabberd_c2s:\d+\) : \([^)]+\) Failed authentication for .+ from IP &amp;lt;HOST&amp;gt; \({{(?:\d+,){3}\d+},\d+}\)$
                ^(?:\.\d+)? \[info\] &amp;lt;0\.\d+\.\d&amp;gt;@ejabberd_c2s:wait_for_feature_request:\d+ \([^\)]+\) Failed authentication for \S+ from IP &amp;lt;HOST&amp;gt;$
                ^.* Failed authentication for \S+ from &amp;lt;HOST&amp;gt;$
                ^.* from &amp;lt;&amp;lt;&amp;#34;&amp;lt;HOST&amp;gt;&amp;#34;&amp;gt;&amp;gt; failed with error: &amp;lt;&amp;lt;&amp;#34;inexistent-account&amp;#34;&amp;gt;&amp;gt;$
                ^.* from &amp;lt;&amp;lt;&amp;#34;&amp;lt;HOST&amp;gt;&amp;#34;&amp;gt;&amp;gt; failed with error: &amp;lt;&amp;lt;&amp;#34;bad-password&amp;#34;&amp;gt;&amp;gt;$
                ^.* from &amp;lt;&amp;lt;&amp;#34;&amp;lt;HOST&amp;gt;&amp;#34;&amp;gt;&amp;gt; failed with error: &amp;lt;&amp;lt;&amp;#34;badformed-jid&amp;#34;&amp;gt;&amp;gt;$

ignoreregex =

[Init]

journalmatch =
---
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The first two regular expressions are for user authentication while the others
are for administration panel login.&lt;br&gt;
Other useful commands are:&lt;/p&gt;</description></item><item><title>ipset, a clever and effective way to block indesired hosts</title><link>https://nagg.eu/ipset-a-clever-and-effective-way-to-block-indesired-hosts/</link><pubDate>Sun, 13 Oct 2013 16:06:38 +0000</pubDate><guid>https://nagg.eu/ipset-a-clever-and-effective-way-to-block-indesired-hosts/</guid><description>&lt;p&gt;This post is meant to be the sequel of the one I wrote one month ago about &lt;!-- raw HTML omitted --&gt;CentOS as router, transparent proxy, and much more&lt;!-- raw HTML omitted --&gt;.&lt;br&gt;
A big chunk of the precedent article is on how configure squid and squidGuard to act as a transparent proxy with URLs filtering capabilities.&lt;br&gt;
But there&amp;rsquo;s a problem with that: nowadays many sites (f4c3b00k.c0m just to name the most annoying one) are HTTPS.&lt;br&gt;
With HTTP one can really easily intercept a packet and read the payload (which contains the URL) but with HTTPS this is not possible anymore since the payload is encrypted.&lt;br&gt;
The only way to be able to read the payload of an HTTPS packet is doing a man-in-the-middle attack with a fake certificate, but that&amp;rsquo;s not advisable and you really don&amp;rsquo;t wanna do it.&lt;br&gt;
If, like in my case, we are not interested in what the users are doing but we just want them to not be able to access some sites/services/whatever ipset (combined with iptables) are the right tools for the job.&lt;br&gt;
iptables is a pretty powerful tool, the only real issue is that it doesn&amp;rsquo;t scale pretty well if the number of the rules is very big, and this is not a good thing since we probably want to blacklist thousands of IPs.&lt;br&gt;
And here comes ipset: with it it&amp;rsquo;s possible to manage huge blacklists without iptables slowing down.&lt;/p&gt;</description></item><item><title>OpenVPN server and CentOS</title><link>https://nagg.eu/openvpn-server-and-centos/</link><pubDate>Sun, 19 May 2013 17:52:52 +0000</pubDate><guid>https://nagg.eu/openvpn-server-and-centos/</guid><description>&lt;p&gt;OpenVPN is the de facto standard VPN free open source software; it is widely
used, tested, well documented and also included in the CentOS repos (EPEL).&lt;/p&gt;
&lt;h2 id="-server-side-configuration"&gt;.:. Server side configuration&lt;/h2&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;yum install openvpn easy-rsa dnsmasq
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;When yum is done installing the required packages, copy the sample config file.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;cp /usr/share/doc/openvpn-*/sample/sample-config-files/server.conf /etc/openvpn
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Uncomment/edit the following lines in /etc/openvpn/server.conf:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh4096.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push &amp;#34;redirect-gateway def1&amp;#34;
push &amp;#34;dhcp-option DNS 10.8.0.1&amp;#34;
keepalive 10 120
tls-auth ta.key 0 # This file is secret
key-direction 0
tls-version-min 1.2
tls-cipher TLS-DHE-RSA-WITH-AES-256-CBC-SHA256
auth SHA512
cipher AES-256-GCM
#comp-lzo # Disable LZO compression
persist-key
persist-tun
status openvpn-status.log
;log openvpn.log # disable log, optional
;log-append openvpn.log # disable log, optional
user nobody
group nobody
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now, create two folders easy-rsa/keys in /etc/openvpn and copy some files into
them:&lt;/p&gt;</description></item></channel></rss>