<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Secwall&#x27;s notes</title>
    <link rel="self" type="application/atom+xml" href="https://secwall.me/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://secwall.me"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2024-02-24T00:00:00+00:00</updated>
    <id>https://secwall.me/atom.xml</id>
    <entry xml:lang="en">
        <title>A little brew helper to remove non needed formulas</title>
        <published>2024-02-24T00:00:00+00:00</published>
        <updated>2024-02-24T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://secwall.me/homebrew-dep-management-helper/"/>
        <id>https://secwall.me/homebrew-dep-management-helper/</id>
        
        <content type="html" xml:base="https://secwall.me/homebrew-dep-management-helper/">&lt;h1 id=&quot;problem&quot;&gt;Problem&lt;&#x2F;h1&gt;
&lt;p&gt;One of the annoying things about the &lt;a href=&quot;https:&#x2F;&#x2F;brew.sh&quot;&gt;Homebrew&lt;&#x2F;a&gt; package manager are garbage dependencies.
Sometimes, a formula switches from a source-only version to a bottle, so its build dependencies are no longer required.
Sometimes, a formula simply switches from one library to another.&lt;&#x2F;p&gt;
&lt;p&gt;Let&#x27;s take one example: the &lt;code&gt;include-what-you-use&lt;&#x2F;code&gt; formula depends on &lt;code&gt;llvm&lt;&#x2F;code&gt;.
If you run &lt;code&gt;brew upgrade&lt;&#x2F;code&gt; at a time when &lt;code&gt;llvm&lt;&#x2F;code&gt; already has version N,
but &lt;code&gt;include-what-you-use&lt;&#x2F;code&gt; still depends on version N-1,
you will end up with two versions of &lt;code&gt;llvm&lt;&#x2F;code&gt;.
Some time will go by, and &lt;code&gt;include-what-you-use&lt;&#x2F;code&gt; will depend on &lt;code&gt;llvm&lt;&#x2F;code&gt; version N.&lt;&#x2F;p&gt;
&lt;p&gt;So, what now? Do we need &lt;code&gt;llvm&lt;&#x2F;code&gt; &lt;code&gt;N-1&lt;&#x2F;code&gt;? There&#x27;s an easy way to check: just try removing it and homebrew will tell you.&lt;&#x2F;p&gt;
&lt;p&gt;But I like to see which formulas are not used as dependencies in my system using some simple command.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;helper&quot;&gt;Helper&lt;&#x2F;h1&gt;
&lt;p&gt;So I wrote a &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;secwall&#x2F;brew-helper&quot;&gt;little helper&lt;&#x2F;a&gt; for this task. Here is how to use it:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;$ brew-helper list
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;span&gt;llvm@16 &amp;lt;- here is an old version of llvm (at the moment of this writing the current version is 17)
&lt;&#x2F;span&gt;&lt;span&gt;...
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Let&#x27;s get rid of it:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;$ brew-helper rm-dep llvm@16
&lt;&#x2F;span&gt;&lt;span&gt;Removing llvm@16
&lt;&#x2F;span&gt;&lt;span&gt;Found new unused dep: six
&lt;&#x2F;span&gt;&lt;span&gt;Removing six
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;As you can see, after the removal of &lt;code&gt;llvm@16&lt;&#x2F;code&gt;, a new garbage dependency has appeared (&lt;code&gt;six&lt;&#x2F;code&gt;). And our helper has gotten rid of it too.&lt;&#x2F;p&gt;
&lt;p&gt;Hope you find it usefull.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Barman page-level incremental backups</title>
        <published>2016-06-18T00:00:00+00:00</published>
        <updated>2016-06-18T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://secwall.me/barman-incremental-backups/"/>
        <id>https://secwall.me/barman-incremental-backups/</id>
        
        <content type="html" xml:base="https://secwall.me/barman-incremental-backups/">&lt;h2 id=&quot;warning&quot;&gt;Warning&lt;&#x2F;h2&gt;
&lt;p&gt;I present experimental &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;secwall&#x2F;barman&quot;&gt;fork&lt;&#x2F;a&gt; of
&lt;a href=&quot;http:&#x2F;&#x2F;www.pgbarman.org&#x2F;&quot;&gt;pgbarman&lt;&#x2F;a&gt; in this post. Some config parameters
could change in merging to upstream process. Stay tuned.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;tl-dr&quot;&gt;TL;DR&lt;&#x2F;h2&gt;
&lt;p&gt;I&#x27;ve added agent (&lt;code&gt;barman-incr&lt;&#x2F;code&gt;) which implements parallel compressed
page-level incremental backups support to barman.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;quick-example&quot;&gt;Quick example&lt;&#x2F;h1&gt;
&lt;p&gt;I&#x27;ll use CentOS 7 in this example. If you are using different distro you
should probably change install phase.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;install&quot;&gt;Install&lt;&#x2F;h2&gt;
&lt;p&gt;We&#x27;ll add some required repos:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; yum install epel-release
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; yum install https:&#x2F;&#x2F;download.postgresql.org&#x2F;pub&#x2F;repos&#x2F;yum&#x2F;9.5&#x2F;redhat&#x2F;rhel-7-x86_64&#x2F;pgdg-centos95-9.5-2.noarch.rpm
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now we&#x27;ll build &lt;code&gt;barman&lt;&#x2F;code&gt; and &lt;code&gt;barman-incr&lt;&#x2F;code&gt; packages from source (I assume that
you are in your home dir now):&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; yum install git rpm-build
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;git&lt;&#x2F;span&gt;&lt;span&gt; clone https:&#x2F;&#x2F;github.com&#x2F;secwall&#x2F;barman
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mv&lt;&#x2F;span&gt;&lt;span&gt; barman barman-1.6.2a1
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mkdir -p&lt;&#x2F;span&gt;&lt;span&gt; rpmbuild&#x2F;SOURCES
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;tar -zcf&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;home&#x2F;vagrant&#x2F;rpmbuild&#x2F;SOURCES&#x2F;barman-1.6.2a1.tar.gz barman-1.6.2a1
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;rpmbuild -bb&lt;&#x2F;span&gt;&lt;span&gt; barman-1.6.2a1&#x2F;rpm&#x2F;barman.spec
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;In result we should get &lt;code&gt;barman-1.6.2-0.1.a1.el7.centos.noarch.rpm&lt;&#x2F;code&gt; and
&lt;code&gt;barman-incr-1.6.2-0.1.a1.el7.centos.noarch.rpm&lt;&#x2F;code&gt; in &lt;code&gt;~&#x2F;rpmbuild&#x2F;RPMS&#x2F;noarch&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Installing pkgs:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; yum install rpmbuild&#x2F;RPMS&#x2F;noarch&#x2F;barman-*
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;postgresql-setup&quot;&gt;Postgresql setup&lt;&#x2F;h2&gt;
&lt;p&gt;We&#x27;ll setup pgsql without any replicas on localhost (this is only for demo
purposes, you should never do this on production environment, always use
replication, strong passwords, ssl, and so on).&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; yum install postgresql95-server postgresql95-contrib
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;usr&#x2F;pgsql-9.5&#x2F;bin&#x2F;postgresql95-setup initdb
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;Initializing&lt;&#x2F;span&gt;&lt;span&gt; database ... OK
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; systemctl restart postgresql-9.5
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo -u&lt;&#x2F;span&gt;&lt;span&gt; postgres psql
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;postgres&lt;&#x2F;span&gt;&lt;span&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;# &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;create&lt;&#x2F;span&gt;&lt;span&gt; user barman with encrypted password &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;barman&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39; superuser;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;CREATE&lt;&#x2F;span&gt;&lt;span&gt; ROLE
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cat &lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;EOF &lt;&#x2F;span&gt;&lt;span&gt;| &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; tee&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; --append&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;9.5&#x2F;data&#x2F;postgresql.conf
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;wal_level = hot_standby
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;archive_mode = on
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;archive_command = &amp;#39;rsync %p barman@localhost:&#x2F;var&#x2F;lib&#x2F;barman&#x2F;test&#x2F;incoming&#x2F;%f&amp;#39;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;EOF
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; sed&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -i -e &lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;s&#x2F;ident&#x2F;md5&#x2F;g&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39; &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;9.5&#x2F;data&#x2F;pg_hba.conf
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; grep&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -v &lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;^#&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39; &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;9.5&#x2F;data&#x2F;pg_hba.conf | &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sed &lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;^\s*$&#x2F;d&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;local   &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;all             all                                     peer
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;host&lt;&#x2F;span&gt;&lt;span&gt;    all             all             127.0.0.1&#x2F;32            md5
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;host&lt;&#x2F;span&gt;&lt;span&gt;    all             all             ::1&#x2F;128                 md5
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; systemctl restart postgresql-9.5
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;barman-setup&quot;&gt;Barman setup&lt;&#x2F;h2&gt;
&lt;p&gt;Now we&#x27;ll configure barman to backup our local postgresql&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cat &lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;EOF &lt;&#x2F;span&gt;&lt;span&gt;| &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; tee&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; --append&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;etc&#x2F;barman.conf
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;[test]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;backup_method = incr
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;description =  &amp;quot;Test PostgreSQL Database&amp;quot;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;ssh_command = ssh postgres@localhost
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;conninfo = host=localhost user=barman dbname=postgres password=barman
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;incr_compress = gzip-4
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;incr_parallel = 4
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;EOF
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Seems simple. We&#x27;ll compress our backups with gzip -4, use 4 processes to make
backup. Refer to &lt;code&gt;man 5 barman&lt;&#x2F;code&gt; for more info.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;openssh-auth-setup&quot;&gt;OpenSSH Auth Setup&lt;&#x2F;h2&gt;
&lt;p&gt;Gen ssh-keys for barman and postgres users. Add them into authorized_keys and
disable strict host checking.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo -u&lt;&#x2F;span&gt;&lt;span&gt; barman mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -p&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;var&#x2F;lib&#x2F;barman&#x2F;.ssh
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo -u&lt;&#x2F;span&gt;&lt;span&gt; barman ssh-keygen&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -f&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;var&#x2F;lib&#x2F;barman&#x2F;.ssh&#x2F;id_rsa&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -N &lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;&amp;#39;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo -u&lt;&#x2F;span&gt;&lt;span&gt; postgres mkdir&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -p&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;.ssh
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo -u&lt;&#x2F;span&gt;&lt;span&gt; postgres ssh-keygen&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -f&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;.ssh&#x2F;id_rsa&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -N &lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;&amp;#39;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; cat &#x2F;var&#x2F;lib&#x2F;barman&#x2F;.ssh&#x2F;id_rsa.pub | &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; tee &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;.ssh&#x2F;authorized_keys
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; cat &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;.ssh&#x2F;id_rsa.pub | &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; tee &#x2F;var&#x2F;lib&#x2F;barman&#x2F;.ssh&#x2F;authorized_keys
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cat &lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;EOF &lt;&#x2F;span&gt;&lt;span&gt;| &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo -u&lt;&#x2F;span&gt;&lt;span&gt; barman tee &#x2F;var&#x2F;lib&#x2F;barman&#x2F;.ssh&#x2F;config
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Host *
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;    StrictHostKeyChecking no
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;EOF
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cat &lt;&#x2F;span&gt;&lt;span&gt;&amp;lt;&amp;lt;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;EOF &lt;&#x2F;span&gt;&lt;span&gt;| &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo -u&lt;&#x2F;span&gt;&lt;span&gt; postgres tee &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;.ssh&#x2F;config
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Host *
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;    StrictHostKeyChecking no
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;EOF
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; chmod 700 &#x2F;var&#x2F;lib&#x2F;barman&#x2F;.ssh &amp;amp;&amp;amp; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; chown barman:barman &#x2F;var&#x2F;lib&#x2F;barman&#x2F;.ssh&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -R
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; chmod 700 &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;.ssh &amp;amp;&amp;amp; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; chown postgres:postgres &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;.ssh&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -R
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Check that everything works as expected:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; barman check test
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;Server&lt;&#x2F;span&gt;&lt;span&gt; test:
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;PostgreSQL:&lt;&#x2F;span&gt;&lt;span&gt; OK
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;superuser:&lt;&#x2F;span&gt;&lt;span&gt; OK
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;wal_level:&lt;&#x2F;span&gt;&lt;span&gt; OK
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;directories:&lt;&#x2F;span&gt;&lt;span&gt; OK
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;retention&lt;&#x2F;span&gt;&lt;span&gt; policy settings: OK
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;backup&lt;&#x2F;span&gt;&lt;span&gt; maximum age: OK (no last_backup_maximum_age provided)
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;compression&lt;&#x2F;span&gt;&lt;span&gt; settings: OK
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;failed&lt;&#x2F;span&gt;&lt;span&gt; backups: OK (there are 0 failed backups)
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;minimum&lt;&#x2F;span&gt;&lt;span&gt; redundancy requirements: OK (have 0 backups, expected at least 0)
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;ssh:&lt;&#x2F;span&gt;&lt;span&gt; OK (barman-incr)
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;version:&lt;&#x2F;span&gt;&lt;span&gt; OK (ok)
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;not&lt;&#x2F;span&gt;&lt;span&gt; in recovery: OK
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;archive_mode:&lt;&#x2F;span&gt;&lt;span&gt; OK
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;archive_command:&lt;&#x2F;span&gt;&lt;span&gt; OK
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;continuous&lt;&#x2F;span&gt;&lt;span&gt; archiving: OK
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;archiver&lt;&#x2F;span&gt;&lt;span&gt; errors: OK
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If you see WAL archive check failure. Try to use &lt;code&gt;pg_switch_xlog()&lt;&#x2F;code&gt; function on
postgres cluster and check the logs.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;backup&quot;&gt;Backup&lt;&#x2F;h2&gt;
&lt;p&gt;We&#x27;ll add some data with &lt;code&gt;pgbench&lt;&#x2F;code&gt;, make full backup, change some data, and
finally make incremental backup.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo -u&lt;&#x2F;span&gt;&lt;span&gt; postgres &#x2F;usr&#x2F;pgsql-9.5&#x2F;bin&#x2F;pgbench&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -i -s&lt;&#x2F;span&gt;&lt;span&gt; 100&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; --foreign-keys
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; du&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -hs&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;9.5&#x2F;data&#x2F;base&#x2F;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;1.5G&lt;&#x2F;span&gt;&lt;span&gt;    &#x2F;var&#x2F;lib&#x2F;pgsql&#x2F;9.5&#x2F;data&#x2F;base&#x2F;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Full backup:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; barman backup test
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;barman&lt;&#x2F;span&gt;&lt;span&gt; list-backup test
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;test&lt;&#x2F;span&gt;&lt;span&gt; 20160618T013124 - Sat Jun 18 01:32:55 2016 - Size: 84.3 MiB - WAL Size: 0 B
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Actually I cheat in some way here because pgbench data compressed really great.
You&#x27;ll not see such impressive results on real data.&lt;&#x2F;p&gt;
&lt;p&gt;Now we&#x27;ll update 1000 rows:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo -u&lt;&#x2F;span&gt;&lt;span&gt; postgres psql
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;postgres&lt;&#x2F;span&gt;&lt;span&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;# &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;update&lt;&#x2F;span&gt;&lt;span&gt; pgbench_accounts set abalance = 100 where aid % 10000 = 2;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;UPDATE&lt;&#x2F;span&gt;&lt;span&gt; 1000
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Another backup (now it&#x27;ll be really fast):&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; barman backup test
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;sudo&lt;&#x2F;span&gt;&lt;span&gt; barman list-backup test
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;test&lt;&#x2F;span&gt;&lt;span&gt; 20160618T013605 - Sat Jun 18 01:37:41 2016 - Size: 170.1 KiB - WAL Size: 0 B
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;test&lt;&#x2F;span&gt;&lt;span&gt; 20160618T013124 - Sat Jun 18 01:32:55 2016 - Size: 84.3 MiB - WAL Size: 1.8 MiB
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Wow. This looks really good.&lt;&#x2F;p&gt;
&lt;h1 id=&quot;what-is-next&quot;&gt;What is next?&lt;&#x2F;h1&gt;
&lt;p&gt;Read the docs (&lt;code&gt;man 5 barman&lt;&#x2F;code&gt;) and adjust options to suit your requrements.
Important note: in real-world setup you&#x27;ll need to install &lt;code&gt;barman-incr&lt;&#x2F;code&gt; on
database host to make backup (ssh check will fail if you enable incr backups
without agent on host).&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>QuickFix Log Pretty Print</title>
        <published>2014-05-03T00:00:00+00:00</published>
        <updated>2014-05-03T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://secwall.me/quickfix-log-pretty-print/"/>
        <id>https://secwall.me/quickfix-log-pretty-print/</id>
        
        <content type="html" xml:base="https://secwall.me/quickfix-log-pretty-print/">&lt;h1 id=&quot;problem&quot;&gt;Problem&lt;&#x2F;h1&gt;
&lt;p&gt;If you are using &lt;a href=&quot;http:&#x2F;&#x2F;quickfixengine.org&quot;&gt;QuickFix&lt;&#x2F;a&gt; and don&#x27;t want to
remember zillion of FIX tags you are in big trouble. Because messages.log
often looks like this:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;[2014-05-02 20:22:04.62] 8=FIX.4.4|9=263|35=X|34=10115815|49=CNTP|52=20140502-20:22:04.656|56=secwall|262=20|268=4|279=0|269=0|278=1716|55=CHF&#x2F;JPY|270=116.398|271=1000000|346=1|279=2|269=0|278=1722|55=CHF&#x2F;JPY|279=0|269=1|278=1837|55=CHF&#x2F;JPY|270=116.462|271=1000000|346=1|279=2|269=1|278=1819|55=CHF&#x2F;JPY|10=026|
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;(Standard fields separator (001 - octal 1) is replaced here with &amp;quot;|&amp;quot;)
So what? Do you remember what 268=4 means?&lt;&#x2F;p&gt;
&lt;p&gt;If you just need to read several messages use
&lt;a href=&quot;http:&#x2F;&#x2F;http:&#x2F;&#x2F;elato.se&#x2F;minifix&#x2F;&quot;&gt;minifix&lt;&#x2F;a&gt; (Windows application, runs ok under
wine). You could just copy-paste part of log in it and click on particular
message.&lt;&#x2F;p&gt;
&lt;p&gt;But what should we do if we want to grep log like in example below?&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cat&lt;&#x2F;span&gt;&lt;span&gt; messages.log | &amp;lt;mygrep&amp;gt; NoMDEntries=4
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h1 id=&quot;solution&quot;&gt;Solution&lt;&#x2F;h1&gt;
&lt;p&gt;QuickFix has fix dictionary files (xml) with it. And
&lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;secwall&#x2F;fixpp&quot;&gt;here&lt;&#x2F;a&gt; is simple python script for
translating numeric tags into their names.&lt;&#x2F;p&gt;
&lt;p&gt;Simple example:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cat&lt;&#x2F;span&gt;&lt;span&gt; messages.log | &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;fixpp -d&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;path&#x2F;to&#x2F;dictionary.xml | &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;grep&lt;&#x2F;span&gt;&lt;span&gt; NoMDEntries=4
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;But there are more. At first I don&#x27;t like to use long paths. So there are
&amp;quot;quicklinks&amp;quot;. Example usage:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cat ~&lt;&#x2F;span&gt;&lt;span&gt;&#x2F;.config&#x2F;fixpp&#x2F;fixpp.conf
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;[quicklink]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;fix44&lt;&#x2F;span&gt;&lt;span&gt; = &#x2F;opt&#x2F;feed-fix-prod&#x2F;selected&#x2F;data&#x2F;etc&#x2F;FIX44.xml
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;...
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cat&lt;&#x2F;span&gt;&lt;span&gt; messages.log | &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;fixpp -d&lt;&#x2F;span&gt;&lt;span&gt; fix44
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Another example. Using grep and long format (separated line for each tag):&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;fixpp -d&lt;&#x2F;span&gt;&lt;span&gt; fix44&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -i&lt;&#x2F;span&gt;&lt;span&gt; messages.log | &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;grep &lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Symbol=CHF&#x2F;JPY&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39; | &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;fixpp -d&lt;&#x2F;span&gt;&lt;span&gt; fix44&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -s &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;\,&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -l
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Code is real garbage but it works (I&#x27;ll try to fix this is near future).&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Configuring ferm to allow connection only from cloudflare CDN</title>
        <published>2014-03-22T00:00:00+00:00</published>
        <updated>2014-03-22T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://secwall.me/configuring-ferm-to-allow-connection-only-from-cloudflare-cdn/"/>
        <id>https://secwall.me/configuring-ferm-to-allow-connection-only-from-cloudflare-cdn/</id>
        
        <content type="html" xml:base="https://secwall.me/configuring-ferm-to-allow-connection-only-from-cloudflare-cdn/">&lt;h1 id=&quot;problem&quot;&gt;Problem&lt;&#x2F;h1&gt;
&lt;p&gt;VPS for this site is really slow. I wanted to speed up site load a bit.
So I signed up on &lt;a href=&quot;https:&#x2F;&#x2F;cloudflare.com&quot;&gt;Cloudflare&lt;&#x2F;a&gt; and set up CDN for it.&lt;&#x2F;p&gt;
&lt;p&gt;What now? Site is still available via ip directly (So if someone want to find
it&#x27;s real ip he&#x2F;she could just scan entire internet and try to make GET &#x2F; request
with HOST header secwall.me - not so easy task, but real).&lt;&#x2F;p&gt;
&lt;p&gt;This is really THE issue if you are going to use cloudflare as DDoS protection.
Attacker task may be really simplier if he&#x2F;she knows that you use specific hoster
(Leaseweb&#x2F;Digital ocean&#x2F;etc.).&lt;&#x2F;p&gt;
&lt;h1 id=&quot;solution&quot;&gt;Solution&lt;&#x2F;h1&gt;
&lt;p&gt;Warning! This makes your site unavailable without cloudflare.
You will need to disable firewall protection to make it work.&lt;&#x2F;p&gt;
&lt;p&gt;I prefer to use &lt;a href=&quot;http:&#x2F;&#x2F;ferm.foo-projects.org&quot;&gt;ferm&lt;&#x2F;a&gt; for automatic iptables
configuration. Cloudflare gives us a list of it&#x27;s ip addresses in
&lt;a href=&quot;https:&#x2F;&#x2F;www.cloudflare.com&#x2F;ips-v4&quot;&gt;machine parseble format&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Here is simple shell script for downloading this list and checking if it was
changed:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;bash&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-bash &quot;&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;#!&#x2F;bin&#x2F;sh
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;wget&lt;&#x2F;span&gt;&lt;span&gt; https:&#x2F;&#x2F;www.cloudflare.com&#x2F;ips-v4&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -O&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;tmp&#x2F;cloudflare-ips-v4.list
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;LOCAL&lt;&#x2F;span&gt;&lt;span&gt;=`&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;md5sum&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;etc&#x2F;ferm&#x2F;cloudflare-ipv4.list | &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cut -d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;\ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -f1&lt;&#x2F;span&gt;&lt;span&gt;`
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;CLOUD&lt;&#x2F;span&gt;&lt;span&gt;=`&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;md5sum&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;tmp&#x2F;cloudflare-ips-v4.list | &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;cut -d&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;\ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt; -f1&lt;&#x2F;span&gt;&lt;span&gt;`
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;if &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;[ &lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;$&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;LOCAL&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot; != &amp;quot;$&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;CLOUD&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot; &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;then
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mv&lt;&#x2F;span&gt;&lt;span&gt; &#x2F;tmp&#x2F;cloudflare-ips-v4.list &#x2F;etc&#x2F;ferm&#x2F;cloudflare-ipv4.list
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;&#x2F;etc&#x2F;init.d&#x2F;ferm&lt;&#x2F;span&gt;&lt;span&gt; reload
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;fi
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And example ferm configuraition:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;perl&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-perl &quot;&gt;&lt;code class=&quot;language-perl&quot; data-lang=&quot;perl&quot;&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;domain &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ip &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;table &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;filter &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;chain &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;INPUT &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;policy &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;DROP&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;INVALID DROP&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ESTABLISHED RELATED&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;interface lo &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            @&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;def &lt;&#x2F;span&gt;&lt;span&gt;$&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;CLOUDFLARE &lt;&#x2F;span&gt;&lt;span&gt;= `&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;cat &#x2F;etc&#x2F;ferm&#x2F;cloudflare-ipv4.list&lt;&#x2F;span&gt;&lt;span&gt;`;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;interface eth0 proto tcp saddr &lt;&#x2F;span&gt;&lt;span&gt;$&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;CLOUDFLARE dport &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;80 ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;proto icmp &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;proto tcp dport ssh &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;chain &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;OUTPUT &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;policy &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;INVALID DROP&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ESTABLISHED RELATED&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;chain &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;FORWARD &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;policy &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;INVALID DROP&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ESTABLISHED RELATED&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;domain &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ip6 &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;table &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;filter &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;chain &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;INPUT &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;policy &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;DROP&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;INVALID DROP&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ESTABLISHED RELATED&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;proto &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ipv6&lt;&#x2F;span&gt;&lt;span&gt;-&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;icmp &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;icmp&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;proto tcp dport ssh &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;chain &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;OUTPUT &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;policy &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;INVALID DROP&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ESTABLISHED RELATED&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;        &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;chain &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;FORWARD &lt;&#x2F;span&gt;&lt;span&gt;{
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;policy &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;INVALID DROP&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;            &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;mod &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;state state &lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ESTABLISHED RELATED&lt;&#x2F;span&gt;&lt;span&gt;) &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;ACCEPT&lt;&#x2F;span&gt;&lt;span&gt;;
&lt;&#x2F;span&gt;&lt;span&gt;        }
&lt;&#x2F;span&gt;&lt;span&gt;    }
&lt;&#x2F;span&gt;&lt;span&gt;}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Shell script should be placed is cron.hourly (or daily). This will make rules
update automatic.&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
