<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Peek Read Info (Posts about NAS)</title><link>https://peekread.info/</link><description></description><atom:link href="https://peekread.info/tags/nas.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2024 &lt;a href="mailto:dugite-code@peekread.info"&gt;Dugite-Code&lt;/a&gt; 
&lt;a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"&gt;
&lt;img alt="Creative Commons License BY-SA"
width="88px" height="31px" style="border-width:0; margin-bottom:12px;"
src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png"&gt;&lt;/a&gt;</copyright><lastBuildDate>Wed, 14 Feb 2024 06:33:10 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Getting a QNAP NAS to Log to my Graylog instance</title><link>https://peekread.info/tech/20190708-getting-a-qnap-nas-to-log-to-my-graylog-instance/</link><dc:creator>Dugite-Code</dc:creator><description>&lt;p&gt;Running old embedded devices is a pain not to mention a major security risk. But if you are like me and are stuck with it sometimes you can take solace in software repo projects like &lt;a href="https://github.com/Entware/Entware" title="Entware was founded as an alternative to very outdated Optware packages. Within five years of development a several Entware forks was born to run on NASes, PCs and new ARM routers. Now x86, x64, MIPS, ARMv5 and ARMv7 forks are merged into Entware-ng. Now Entware-ng-3x and Entware-ng merged to become Entware. It's maintained by the same team as Entware-ng/-3x before."&gt;Entware&lt;/a&gt;. In this case I needed to centralize all the disparate system logs on the network so I could find issues &lt;strong&gt;BEFORE&lt;/strong&gt; they cause real trouble. The problem is the QNAP NAS I had could only send system logs over unencrypted UDP.&lt;/p&gt;
&lt;p&gt;That's just not good enough, especially as I want to use client certs down the line. The simplest solution I found was to install syslog-ng to redirect the logs securely.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Note:&lt;/em&gt; I'm using a letsencrypt cert to make my life simpler&lt;/p&gt;
&lt;h3&gt;Setting up the NAS&lt;/h3&gt;
&lt;p&gt;Install &lt;a href="https://github.com/Entware/Entware/wiki/Install-on-QNAP-NAS" title="Please remove Optware, Qnapware if it is currently installed. Entware cannot be used simultaneously with Optware or Qnapware."&gt;Entware&lt;/a&gt; by downloading the &lt;code&gt;.qpkg&lt;/code&gt; file, navigating to the NAS in the web browser and then selecting the install manually option in the app center.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Manualy install the .qpkg file" class="img-fluid dark-image mx-auto d-block text-center text-light" loading="lazy" max-height="46" max-width="800" src="https://peekread.info/images/2019/0708-getting-a-qnap-nas-to-log-to-my-graylog-instance/image01.png"&gt;&lt;/p&gt;
&lt;p&gt;SSH into the NAS and install &lt;code&gt;syslog-ng&lt;/code&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;opkg&lt;span class="w"&gt; &lt;/span&gt;update
opkg&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;syslog-ng
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Configure syslog-ng by editing &lt;code&gt;/opt/etc/syslog-ng.conf&lt;/code&gt;&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="c1"&gt;# Important set the right config file version&lt;/span&gt;
@version:&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;.20

options&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;# Listen to local syslog connection&lt;/span&gt;
&lt;span class="nb"&gt;source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;localhostudp&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;udp&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;ip&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"127.0.0.1"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;port&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1514&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;# Forward to remote graylog server over tls to port 1514&lt;/span&gt;
&lt;span class="c1"&gt;# To Implement Client Cert&lt;/span&gt;
destination&lt;span class="w"&gt; &lt;/span&gt;graylog_loghost&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;network&lt;span class="o"&gt;(&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;&lt;span class="s2"&gt;"example.com"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;port&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1514&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;transport&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"tls"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;                &lt;/span&gt;tls&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;ca_dir&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/opt/sbin/cadir"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;# Enable both source and destination&lt;/span&gt;
log&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;{&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;source&lt;span class="o"&gt;(&lt;/span&gt;localhostudp&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="w"&gt;        &lt;/span&gt;destination&lt;span class="o"&gt;(&lt;/span&gt;graylog_loghost&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Set up the Letsencrypt CA by downloading the TrustID X3 Root Certificate (formallyu known as DST Root CA X3). We then need to discover the hash of the certificate using openssl. Syslog-ng requires as simlink named with the certificate hash.&lt;/p&gt;
&lt;p&gt;The hash should be 2e5ac55d&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;/opt/sbin/cadir
wget&lt;span class="w"&gt; &lt;/span&gt;https://github.com/letsencrypt/website/raw/master/static/certs/trustid-x3-root.pem

openssl&lt;span class="w"&gt; &lt;/span&gt;x509&lt;span class="w"&gt; &lt;/span&gt;-noout&lt;span class="w"&gt; &lt;/span&gt;-hash&lt;span class="w"&gt; &lt;/span&gt;-in&lt;span class="w"&gt; &lt;/span&gt;trustid-x3-root.pem

ln&lt;span class="w"&gt; &lt;/span&gt;-s&lt;span class="w"&gt; &lt;/span&gt;/opt/sbin/cadir/trustid-x3-root.pem&lt;span class="w"&gt; &lt;/span&gt;/opt/sbin/cadir/2e5ac55d.0
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Via the web admin, set the NAS to log to &lt;code&gt;127.0.0.1&lt;/code&gt; with the local port &lt;code&gt;1514&lt;/code&gt;. This can be found in Systems Logs in the Systems Settings category.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Control Panel -&amp;gt; System Logs -&amp;gt; Syslog Client Management" class="img-fluid dark-image mx-auto d-block text-center text-light" loading="lazy" max-height="198" max-width="800" src="https://peekread.info/images/2019/0708-getting-a-qnap-nas-to-log-to-my-graylog-instance/image02.png"&gt;&lt;/p&gt;
&lt;p&gt;Ensure syslog-ng isn't running then test in the foreground for any errors&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;/opt/etc/init.d/S01syslog-ng&lt;span class="w"&gt; &lt;/span&gt;stop

/opt/sbin/syslog-ng&lt;span class="w"&gt; &lt;/span&gt;-Fvde
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;If no errors appear you can then start syslog-ng&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;/opt/etc/init.d/S01syslog-ng&lt;span class="w"&gt; &lt;/span&gt;start
&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Graylog Notes&lt;/h3&gt;
&lt;p&gt;Graylog doesn't appear to directly accept the format sent via syslog-ng. While it is possible to change the format in syslog-ng I didn't figure out the best way to do it. My solution was to set the input to &lt;code&gt;Raw/Plaintext TCP&lt;/code&gt; and then run a GROK pattern extractor when matching the &lt;code&gt;conn log&lt;/code&gt; string&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="c"&gt;%{DATA} qlogd\[9147\]: %{DATA:facility}: Users: %{DATA:NAS_user}, Source IP: %{IP:NAS_src}, Computer name: %{DATA:NAS_id}, Connection type: %{DATA:NAS_connection}, Accessed resources: %{DATA:NAS_resource}, Action: %{GREEDYDATA:NAS_action}&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;</description><category>graylog</category><category>NAS</category><category>QNAP</category><category>syslog</category><guid>https://peekread.info/tech/20190708-getting-a-qnap-nas-to-log-to-my-graylog-instance/</guid><pubDate>Mon, 08 Jul 2019 00:00:00 GMT</pubDate></item></channel></rss>