<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Arquivos grafana - Remontti</title>
	<atom:link href="https://blog.remontti.com.br/tag/grafana/feed" rel="self" type="application/rss+xml" />
	<link>https://blog.remontti.com.br/tag/grafana</link>
	<description>rudimar@remontti</description>
	<lastBuildDate>Tue, 14 Jan 2025 19:41:30 +0000</lastBuildDate>
	<language>pt-BR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.remontti.com.br/wp-content/uploads/2024/09/icone-rr-80x80.png</url>
	<title>Arquivos grafana - Remontti</title>
	<link>https://blog.remontti.com.br/tag/grafana</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Instalação do Grafana 11&gt;  com integração com Zabbix &#8211; (Debian 11 Bullseye/12 Bookworm)</title>
		<link>https://blog.remontti.com.br/6370</link>
					<comments>https://blog.remontti.com.br/6370#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Wed, 14 Jun 2023 19:00:02 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[administração]]></category>
		<category><![CDATA[Configuração]]></category>
		<category><![CDATA[dashboard]]></category>
		<category><![CDATA[Debian 11 Bullseye]]></category>
		<category><![CDATA[Debian 12 Bookworm]]></category>
		<category><![CDATA[ferramenta]]></category>
		<category><![CDATA[fontes de dados]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[graficos]]></category>
		<category><![CDATA[instalaçao]]></category>
		<category><![CDATA[instalação do Grafana]]></category>
		<category><![CDATA[integração]]></category>
		<category><![CDATA[integração com o Zabbix]]></category>
		<category><![CDATA[métricas]]></category>
		<category><![CDATA[monitoramento]]></category>
		<category><![CDATA[monitoramento de redes]]></category>
		<category><![CDATA[painéis]]></category>
		<category><![CDATA[software livre]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[tutorial Debian 11 Bullseye]]></category>
		<category><![CDATA[tutorial Debian 12 Bookworm]]></category>
		<category><![CDATA[tutorial Grafana]]></category>
		<category><![CDATA[tutorial passo a passo]]></category>
		<category><![CDATA[tutorial Zabbix.]]></category>
		<category><![CDATA[visualização de dados]]></category>
		<category><![CDATA[visualização de métricas]]></category>
		<category><![CDATA[zabbix]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=6370</guid>

					<description><![CDATA[<p>O Grafana é um software livre que permite a visualização de formato de dados métricos. Ele permite criar painéis e gráficos a partir de várias fontes, e neste tutorial vamos aprender a instala-lo e&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/6370">Instalação do Grafana 11&gt;  com integração com Zabbix &#8211; (Debian 11 Bullseye/12 Bookworm)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><center><img fetchpriority="high" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/06/grafana_debian.jpg" alt="" width="720" height="340" class="alignnone size-full wp-image-7454" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/06/grafana_debian.jpg 720w, https://blog.remontti.com.br/wp-content/uploads/2023/06/grafana_debian-300x142.jpg 300w, https://blog.remontti.com.br/wp-content/uploads/2023/06/grafana_debian-520x245.jpg 520w" sizes="(max-width: 720px) 100vw, 720px" /></center></p>
<p>O Grafana é um software livre que permite a visualização de formato de dados métricos. Ele permite criar painéis e gráficos a partir de várias fontes, e neste tutorial vamos aprender a instala-lo e integrar com o Zabbix.</p>
<h3>Requisitos:</h3>
<p>Debian<br />
<strong><a href="https://blog.remontti.com.br/7236" rel="noopener" target="_blank">Instalação Debian 12 Bookworm</a></strong><br />
<strong><a href="https://blog.remontti.com.br/5792" rel="noopener" target="_blank">Instalação Debian 11 Bullseye</a></strong><br />
Zabbix:<br />
<strong><a href="https://blog.remontti.com.br/7870" rel="noopener" target="_blank">Instalação do Zabbix 7 LTS + NGINX + PostgreSQL + Debian 12 Bookworm</a></strong><br />
<strong><a href="https://blog.remontti.com.br/7411" rel="noopener" target="_blank">Instalação do Zabbix 6 LTS + NGINX + PostgreSQL + Debian 12 Bookworm</a></strong><br />
<strong><a href="https://blog.remontti.com.br/6350" rel="noopener" target="_blank">Instalação do Zabbix 6 LTS + NGINX + PostgreSQL + Debian 11 Bullseye</a></strong></p>
<p>Vamos baixar a key do repositório e adiciona-lo </p>
<pre class="remontti-code"># apt install gnupg2 apt-transport-https software-properties-common wget
# wget -q -O - https://apt.grafana.com/gpg.key | \
 gpg --dearmor | tee /etc/apt/keyrings/grafana.gpg &gt; /dev/null
# echo &quot;deb [signed-by=/etc/apt/keyrings/grafana.gpg]\
 https://apt.grafana.com stable main&quot; &gt; /etc/apt/sources.list.d/grafana.list
</pre>
<p>Atualize o repositório e instale o grafana</p>
<pre class="remontti-code"># apt update; apt install grafana -y </pre>
<p>Já aconteu dos desenvolvedores remover do repositório o pacote grafana, nesse caso acesse:<br />
<a href="https://grafana.com/grafana/download?edition=oss" rel="noopener" target="_blank">https://grafana.com/grafana/download?edition=oss</a> e faça a instalação de forma manual.</p>
<h3>Proxy com Nginx grafana</h3>
<p>Se você esta usando como servidor web o Nginx para acessar o grafana através de um domínio faça: (se o seu for apache pule)</p>
<pre class="remontti-code"># vim /etc/nginx/sites-available/grafana.conf</pre>
<p>Adicione:</p>
<pre class="remontti-code">server {
    listen 80;
    listen [::]:80;

    server_name grafana.remontti.com.br;

    # Descomente para restringir o acesso apenas aos IPs Listados
    # allow 127.0.0.1;
    # allow ::1;
    # allow 192.168.0.0/16;
    # allow 2801:db8::/32;
    # deny  all;
    # error_page  403   http://www.remontti.com.br;
 
    location / {
        proxy_pass http://127.0.0.1:3000;  # Porta padrão do Grafana
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 90;

        # Suporte a WebSocket
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection &quot;upgrade&quot;;
        proxy_cache_bypass $http_upgrade;
    }
}</pre>
<p>Cria o link para sites-enabled em seguida verifique as configurações e reinicie o serviço.</p>
<pre class="remontti-code"># ln -s /etc/nginx/sites-available/grafana.conf /etc/nginx/sites-enabled/
# nginx -t
# systemctl restart nginx</pre>
<h3>Proxy com Apache grafana</h3>
<p>Se você esta usando como servidor web o Apache para acessar o grafana através de um domínio faça:</p>
<pre class="remontti-code"># a2enmod rewrite; a2enmod headers; a2enmod proxy ; a2enmod proxy_http ; 
mkdir /var/www/grafana
</pre>
<pre class="remontti-code"># vim /etc/apache2/sites-available/grafana.conf</pre>
<p>Adicione:</p>
<pre class="remontti-code">&lt;VirtualHost *:80&gt;
	Protocols h2 http/1.1
	ServerName grafana.remontti.com.br
	ServerAdmin noc@remontti.com.br
	DocumentRoot /var/www/grafana

	ErrorDocument 403 http://www.remontti.com.br

	&lt;Directory /var/www/grafana/&gt;
		Options Indexes FollowSymLinks
		AllowOverride all
		# Descomente para restringir o acesso apenas aos IPs Listados
		# Require ip 127.0.0.1 ::1 200.200.200.0/26 2001:db8:cafe::/48
	&lt;/Directory&gt;

	LogLevel warn

	ProxyPreserveHost On
	ProxyPass / http://127.0.0.1:3000/
	ProxyPassReverse / http://127.0.0.1:3000/

	ErrorLog ${APACHE_LOG_DIR}/grafana_error.log
	CustomLog ${APACHE_LOG_DIR}/grafana_access.log combined
	TransferLog ${APACHE_LOG_DIR}/grafana_access.log

&lt;/VirtualHost&gt;</pre>
<p>Ative a nova configuração e reinicie o Apache:</p>
<pre class="remontti-code"># a2ensite grafana
# systemctl restart apache2</pre>
<p>Vamos fazer alguns ajustes:</p>
<pre class="remontti-code"># vim /etc/grafana/grafana.ini</pre>
<p>Como utilizei um proxy irei executar o grafana apenas em modo localhost para que a porta 3000 fique aberta apenas para ele mesmo. Localize <strong>;http_addr = </strong> e deixe assim: </p>
<pre class="remontti-code">http_addr = 127.0.0.1</pre>
<p>Em <strong>;domain =</strong> ajuste para seu domínio.</p>
<pre class="remontti-code">domain = grafana.remontti.com.br</pre>
<p>E ajuste a <strong>;root_url = %(protocol)s://%(domain)s:%(http_port)s/</strong> para:</p>
<pre class="remontti-code">root_url = %(protocol)s://%(domain)s/</pre>
<p>Instale o <strong>Plugin Zabbix</strong></p>
<pre class="remontti-code"># grafana-cli plugins install alexanderzobnin-zabbix-app</pre>
<p>É recomendado que mensalmente você faça atualizações dos plugins instalados, com o comando:</p>
<pre class="remontti-code"># grafana-cli plugins update-all</pre>
<p>Depois da versão 11.1 existe um bug que acaba nao dando permissão para o usuário grafana ler/gravar em /var/lib/grafana/plugins, então corrija utilizando o comando: </p>
<pre class="remontti-code"># chown -R grafana: /var/lib/grafana/plugins</pre>
<p>Agora sim colocamos o Grafana para iniciar junto com a inicialização, ativamos e inicializamos o serviço:</p>
<pre class="remontti-code"># systemctl daemon-reload
# systemctl enable grafana-server
# systemctl start grafana-server</pre>
<p>Acesse em seu navegador seu <strong>&#8220;http://grafana._______.___.__&#8221;</strong> ou então <strong>http://IP_URL:3000</strong> ou pela porta que você alterou. O nome de usuário padrão é <strong>admin</strong> e a senha padrão é <strong>admin</strong>.</p>
<p>Se caso perder a senha de admin pode resetar ela com o comando:</p>
<pre class="remontti-code">grafana-cli admin reset-admin-password admin</pre>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12.png" alt="" width="1920" height="974" class="alignnone size-full wp-image-7430" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12.png 1920w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12-300x152.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12-1024x519.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12-768x390.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12-1536x779.png 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></a><br />
Ao fazer login pela primeira vez, você será solicitado a <strong>alterar sua senha</strong>.</p>
<h4>Integração com a base de dados Zabbix</h4>
<p>Acesse o Menu (1) Administration (2) Plugins(3) Localize o Zabbix e clique no mesmo.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_3.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_3.png" alt="" width="794" height="626" class="alignnone size-full wp-image-7433" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_3.png 794w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_3-300x237.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_3-768x606.png 768w" sizes="(max-width: 794px) 100vw, 794px" /></a></p>
<p>Escreva na pesquisa (1) Zabbix e em seguida clique sobre (2)<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_4.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_4.png" alt="" width="1064" height="607" class="alignnone size-full wp-image-7435" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_4.png 1064w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_4-300x171.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_4-1024x584.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_4-768x438.png 768w" sizes="auto, (max-width: 1064px) 100vw, 1064px" /></a></p>
<p>Clique em Enable (1)<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_5.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_5.png" alt="" width="1654" height="722" class="alignnone size-full wp-image-7436" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_5.png 1654w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_5-300x131.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_5-1024x447.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_5-768x335.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_5-1536x670.png 1536w" sizes="auto, (max-width: 1654px) 100vw, 1654px" /></a></p>
<p>Volte ao Menu (1) abra Connections (2) Clique em Data sources (3)<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_6.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_6.png" alt="" width="801" height="558" class="alignnone size-full wp-image-7437" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_6.png 801w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_6-300x209.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_6-768x535.png 768w" sizes="auto, (max-width: 801px) 100vw, 801px" /></a></p>
<p>Clique em Add data sourece<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_7.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_7.png" alt="" width="1659" height="573" class="alignnone size-full wp-image-7438" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_7.png 1659w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_7-300x104.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_7-1024x354.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_7-768x265.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_7-1536x531.png 1536w" sizes="auto, (max-width: 1659px) 100vw, 1659px" /></a></p>
<p>Escreve na busca (1) Zabbix e clique nele (2)<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_8.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_8.png" alt="" width="1648" height="432" class="alignnone size-full wp-image-7439" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_8.png 1648w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_8-300x79.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_8-1024x268.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_8-768x201.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_8-1536x403.png 1536w" sizes="auto, (max-width: 1648px) 100vw, 1648px" /></a></p>
<p>Agora em URL<strong> http://localhost/api_jsonrpc.php</strong> se você seguiu o tutorial do bloque para instalação do zabbix com domínio deve ter visto uma alias também para localhost, caso contrário informe os dados correto da URL do seu Zabbix.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_9.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_9.png" alt="" width="1657" height="907" class="alignnone size-full wp-image-7440" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_9.png 1657w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_9-300x164.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_9-1024x561.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_9-768x420.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_9-1536x841.png 1536w" sizes="auto, (max-width: 1657px) 100vw, 1657px" /></a></p>
<p>Role mais um pouco e informe o usuário e senha do zabbix (eu gosto de criar um usuário só para isso)<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_10.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_10.png" alt="" width="1646" height="971" class="alignnone size-full wp-image-7441" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_10.png 1646w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_10-300x177.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_10-1024x604.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_10-768x453.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_10-1536x906.png 1536w" sizes="auto, (max-width: 1646px) 100vw, 1646px" /></a></p>
<p>Clique em Save &#038; test (1) Se tudo ocorrer bem você receberá uma mensagem de sucesso (2)<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_11.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_11.png" alt="" width="1367" height="524" class="alignnone size-full wp-image-7442" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_11.png 1367w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_11-300x115.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_11-1024x393.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_11-768x294.png 768w" sizes="auto, (max-width: 1367px) 100vw, 1367px" /></a></p>
<p>Volte ao Menu, Connections, Data source (1) e clique em Add new data source (2)<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_12.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_12.png" alt="" width="1668" height="591" class="alignnone size-full wp-image-7444" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_12.png 1668w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_12-300x106.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_12-1024x363.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_12-768x272.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_12-1536x544.png 1536w" sizes="auto, (max-width: 1668px) 100vw, 1668px" /></a></p>
<p>Iremos adicionar o Postgresql para otimizar as consultas no zabbix, isso faz total diferença em otimização! Então pesquise (1) por Postgresql e clique sobre (2)<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_13.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_13.png" alt="" width="1653" height="486" class="alignnone size-full wp-image-7445" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_13.png 1653w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_13-300x88.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_13-1024x301.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_13-768x226.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_13-1536x452.png 1536w" sizes="auto, (max-width: 1653px) 100vw, 1653px" /></a></p>
<p>Informe os dados de conexão com o Postgres qual usou na instalação da base do zabbix.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_14.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_14.png" alt="" width="1653" height="930" class="alignnone size-full wp-image-7446" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_14.png 1653w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_14-300x169.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_14-1024x576.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_14-768x432.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_14-1536x864.png 1536w" sizes="auto, (max-width: 1653px) 100vw, 1653px" /></a></p>
<p>Role para baixo e selecione a versão (1) do seu PostgreSQL. Para Debian 12 a versão é a 15, e para Debian 11 a versão é a 13. Em Seguida Clique em Save &#038; Test (2) Se uma mensagem de sucesso (3) aparecer tudo funcionou!<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_15.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_15.png" alt="" width="1649" height="791" class="alignnone size-full wp-image-7447" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_15.png 1649w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_15-300x144.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_15-1024x491.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_15-768x368.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_15-1536x737.png 1536w" sizes="auto, (max-width: 1649px) 100vw, 1649px" /></a></p>
<p>Volte ao Menu, Connections, Data source (1) e clique em Zabbix (2)<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_16.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_16.png" alt="" width="1661" height="486" class="alignnone size-full wp-image-7449" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_16.png 1661w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_16-300x88.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_16-1024x300.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_16-768x225.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_16-1536x449.png 1536w" sizes="auto, (max-width: 1661px) 100vw, 1661px" /></a></p>
<p>Role até achar Direct DB Connection (1) e clique em enable (2), em Data Source selecione PostgreSQL (3) em seguida clique em Save &#038; Test (4), você receberá uma mensagem de sucesso (5)<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_17.png" data-rel="lightbox-gallery-BQn0rJs2" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_17.png" alt="" width="1586" height="556" class="alignnone size-full wp-image-7450" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_17.png 1586w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_17-300x105.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_17-1024x359.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_17-768x269.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_10_debian12_17-1536x538.png 1536w" sizes="auto, (max-width: 1586px) 100vw, 1586px" /></a></p>
<p>Agora vem a parte mais &#8220;legal&#8221; que é você montar seus gráficos, como isso é algo bem peculiar de cada um, o intuito aqui era ensinar instalar. Recomendo a leitura de <a href="https://alexanderzobnin.github.io/grafana-zabbix/guides/gettingstarted/" rel="noopener noreferrer" target="_blank">Introdução ao Grafana-Zabbix</a> do autor do plugin.</p>
<p>Simples né? Gostou e quer me ajudar? <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a></p>
<p>Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>Abraço!</p>
<p>Fontes:<br />
<a href="https://grafana.com/docs/grafana/latest/installation/debian/" rel="noopener" target="_blank">https://grafana.com/docs/grafana/latest/installation/debian/</a><br />
<a href="https://grafana.com/grafana/plugins/alexanderzobnin-zabbix-app" rel="noopener" target="_blank">https://grafana.com/grafana/plugins/alexanderzobnin-zabbix-app</a><br />
<a href="https://www.zabbix.com/documentation/" rel="noopener" target="_blank">https://www.zabbix.com/documentation/</a></p>
<p>O post <a href="https://blog.remontti.com.br/6370">Instalação do Grafana 11&gt;  com integração com Zabbix &#8211; (Debian 11 Bullseye/12 Bookworm)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/6370/feed</wfw:commentRss>
			<slash:comments>15</slash:comments>
		
		
			</item>
		<item>
		<title>Fortalecendo a Resiliência da Rede: Detecção de Ataques DDoS com FastNetMon, FRRouting, Grafana e Implementação em Debian 12 com Huawei &#038; RouterOS</title>
		<link>https://blog.remontti.com.br/7322</link>
					<comments>https://blog.remontti.com.br/7322#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Wed, 31 May 2023 20:38:50 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[alertas]]></category>
		<category><![CDATA[Análise de Tráfego]]></category>
		<category><![CDATA[Ataque]]></category>
		<category><![CDATA[Código Aberto]]></category>
		<category><![CDATA[Comunidade.]]></category>
		<category><![CDATA[Configuração]]></category>
		<category><![CDATA[ddos]]></category>
		<category><![CDATA[Debian 12]]></category>
		<category><![CDATA[Defesa]]></category>
		<category><![CDATA[Detecção]]></category>
		<category><![CDATA[detecção de ataques DDoS]]></category>
		<category><![CDATA[fastnetmon]]></category>
		<category><![CDATA[Firewalls]]></category>
		<category><![CDATA[frrouting]]></category>
		<category><![CDATA[Geração de Relatórios]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[Infraestrutura de Rede]]></category>
		<category><![CDATA[integração]]></category>
		<category><![CDATA[Melhores Práticas]]></category>
		<category><![CDATA[mitigação]]></category>
		<category><![CDATA[monitoramento]]></category>
		<category><![CDATA[Monitoramento em Tempo Real]]></category>
		<category><![CDATA[NE-Huawei]]></category>
		<category><![CDATA[notificações]]></category>
		<category><![CDATA[Políticas]]></category>
		<category><![CDATA[proteção]]></category>
		<category><![CDATA[resiliência da rede]]></category>
		<category><![CDATA[Roteadores]]></category>
		<category><![CDATA[routeros]]></category>
		<category><![CDATA[Segurança]]></category>
		<category><![CDATA[Tráfego]]></category>
		<category><![CDATA[tutorial]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=7322</guid>

					<description><![CDATA[<p>Este tutorial combina e aprimora dois tutoriais anteriores do blog sobre fastnetmon, incorporando melhorias e ideias compartilhadas pela comunidade ao longo do tempo. Espero que aprecie! Vamos aprender como identificar os ataques Dos/DDoS e&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/7322">Fortalecendo a Resiliência da Rede: Detecção de Ataques DDoS com FastNetMon, FRRouting, Grafana e Implementação em Debian 12 com Huawei &#038; RouterOS</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><center><a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/fastnetmon.jpg" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/05/fastnetmon.jpg" alt="" width="720" height="340" class="alignnone size-full wp-image-7359" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/05/fastnetmon.jpg 720w, https://blog.remontti.com.br/wp-content/uploads/2023/05/fastnetmon-300x142.jpg 300w, https://blog.remontti.com.br/wp-content/uploads/2023/05/fastnetmon-520x245.jpg 520w" sizes="auto, (max-width: 720px) 100vw, 720px" /></a></center></p>
<p><strong><em>Este tutorial combina e aprimora dois tutoriais anteriores do blog sobre fastnetmon, incorporando melhorias e ideias compartilhadas pela comunidade ao longo do tempo. Espero que aprecie!</em></strong></p>
<p>Vamos aprender como identificar os ataques Dos/DDoS e anunciar os prefixo atacados (ou atacantes) <strong>de seu AS</strong> em envia-los para uma blackhole, e repassar os mesmo para sua operadora. (Acordo)</p>
<p>Vamos utilizar o <a href="https://github.com/pavel-odintsov/fastnetmon/" rel="noopener noreferrer" target="_blank"><strong>FastNetMon</strong></a> (<strong>Community Edition</strong>) que é um analisador de carga DoS/DDoS de alto desempenho, construído sobre vários mecanismos de captura de pacotes (NetFlow, IPFIX, sFlow, AF_PACKET, SnabbSwitch, netmap, PF_RING, PCAP). </p>
<p>Farei a instalação no <a href="https://blog.remontti.com.br/7236" rel="noopener" target="_blank"><strong>Debian 12 (Instalação Limpa)</strong></a>. O hardware utilizado por ser bem generoso, 4CPU (se for usar o influx/grafana recomendo 8CPU) e 4GB de memoria. </p>
<p>Adicione <strong>contrib non-free</strong> ao repositório.</p>
<pre class="remontti-code"># vim /etc/apt/sources.list</pre>
<p>Irá ficar assim:</p>
<pre class="remontti-code-plain">deb http://deb.debian.org/debian/ bookworm main non-free-firmware contrib non-free
deb-src http://deb.debian.org/debian/ bookworm main non-free-firmware contrib non-free

deb http://security.debian.org/debian-security bookworm-security main non-free-firmware contrib non-free
deb-src http://security.debian.org/debian-security bookworm-security main non-free-firmware contrib non-free

deb http://deb.debian.org/debian/ bookworm-updates main non-free-firmware contrib non-free
deb-src http://deb.debian.org/debian/ bookworm-updates main non-free-firmware contrib non-free</pre>
<p>Atualize agora o repositório, e os pacotes. </p>
<pre class="remontti-code"># apt update ; apt upgrade -y
# apt install firmware-linux firmware-linux-free firmware-linux-nonfree</pre>
<p>Instale também alguns pacotes que iremos utilizar mais a frente.</p>
<pre class="remontti-code"># apt install wget tcpdump net-tools zip curl -y</pre>
<p><strong>Cenário fictício de exemplo:</strong><br />
Seu AS: 260072 <em>(Madruga Telecom)</em><br />
Operadora AS: 71 <em>(BrUxa71 Telecom)</em><br />
10.52.52.1/24 &#8211; Huawei/RouterOS<br />
10.52.52.2/24 &#8211; Servidor</p>
<h3>Configurando a interface de Rede</h3>
<p>Antes de iniciar a instalação do seu do seu servidor em meu exemplo estou usando o IP 10.52.52.2/30, porém eu NUNCA faria um NAT no roteador de borda então porque utilizar o IP privado? Simples por que ele não é acessível logo não pode ser atacado, mas por outro lado se ele não tiver internet você não poderá fazer a instalação e ele não poderá te notificar pelo telegram. Solução que eu gosto muito de aplicar em servidores é a seguinte (falo muito de como configurar interface de redes <a href="https://blog.remontti.com.br/5848" rel="noopener" target="_blank">nesse tutorial</a>, recomendo uma leitura). </p>
<p>Vamos supor que seu prefixo seja 72.72.72.0/22 e você vai alocar o ip 72.72.72.255<strong>/32</strong> para ser o IP de &#8220;loopback&#8221;. <em>Dica que esse IP não seja próximo a do prefixo público que utiliza em seus servidores</em>. Irei também configurar um IPv6 roteador da mesma forma para que ele tenha uma conectividade IPv6 qual o telegram pode se beneficiar para enviar um alerta por exemplo.</p>
<pre class="remontti-code"># vim /etc/network/interfaces</pre>
<pre class="remontti-code-plain">allow-hotplug enp0s3
iface enp0s3 inet static
    address 72.72.72.255/32

iface enp0s3 inet static
    address 10.52.52.2/24
    post-up /usr/sbin/ip route add default via 10.52.52.1 src 72.72.72.255

iface enp0s3 inet6 static
    pre-up modprobe ipv6
    address 2804:1234:bebe:caff::f0da/128

iface enp0s3 inet6 static
    pre-up modprobe ipv6
    address fd00:cafe::2/64
    post-up ip -6 route add default via fd00:cafe::1 src 2804:1234:bebe:caff:1:f0da:2:ff1f
</pre>
<p>Perceba que nós estaremos conversando com nosso roteador de borda pelo prefixo privado 10.100.0.0/30 porém todo o pacote de origem do servidor sai pelo o IP público. Caso este ip seja atacado o mesmo poderá cair em blackhole que o nosso servidor ainda terá comunicação com a borda. </p>
<p>Mas para que seu IP publico tenha rota será necessário criar um rota em seu roteador de borda apontando o IP público para o privado.</p>
<pre class="remontti-code">
RouterOS# /ip   address add interface=ether1 address=10.52.52.1/24
RouterOS# /ipv6 address add interface=ether1 address=fd00:cafe::1/64 advertise=no 
RouterOS# /ip   route add dst-address=72.72.72.255/32 gateway=10.52.52.2
RouterOS# /ipv6 route add dst-address=2804:1234:bebe:caff:1:f0da:2:ff1f/128 gateway=fd00:cafe::1
</pre>
<pre class="remontti-code">
&lt;HUAWEI&gt; system-view
[~HUAWEI] interface 25GE0/1/36
[*HUAWEI] description INTERFACE_SERVIDOR
[*HUAWEI] undo shutdown
[*HUAWEI] ipv6 enable
[*HUAWEI] ip address 10.52.52.1 255.255.255.0
[*HUAWEI] ipv6 address FD00:CAFE::1/64
[*HUAWEI] quit
[*HUAWEI] ip route-static 72.72.72.255 255.255.255.255 10.52.52.2 description FASTNETMON
[*HUAWEI] ipv6 route-static 2804:1234:bebe:caff:1:f0da:2:ff1f 128 2001:FD00:CAFE::1 description FASTNETMON
[*HUAWEI] commit
</pre>
<p>É claro que neste caso ficará sem internet, mas podemos aplicar um firewall para enviar que ele fique respondendo, apenas para deixar ele &#8220;escondidinho&#8221;. E para isso vamos usar o nftables (Que já vem instalado por padrão no Debian 11 substituindo o iptables)<br />
Habilite o mesmo para iniciar com o sistema:</p>
<pre class="remontti-code"># systemctl enable nftables</pre>
<p>Vamos montar nosso firewall de forma que apenas conexoes que forem abertas pelo servidor seja respondidas.</p>
<pre class="remontti-code"># vim /etc/nftables.conf</pre>
<pre class="remontti-code-plain">#!/usr/sbin/nft -f

flush ruleset

# IP SERVIDOR
define IPV4_SERV = { 72.72.72.255 }
define IPV6_SERV = { 2804:1234:bebe:caff:1:f0da:2:ff1f }

# Portas aberta para ADM (vou deixar só SSH e a do Grafana)
define PORTS_ACCEP_ADM = { 22, 3000 }

table inet filter {

    set ACESSO_TOTAL4 {
        type ipv4_addr
        flags interval
        # Lista dos IPv4 com permissão
        elements = {
            127.0.0.0/8,
            192.168.0.0/16,
            172.16.0.0/12,
            10.0.0.0/8,
            100.64.0.0/10,
            72.72.72.0/24
        }
    }
    set ACESSO_TOTAL6 {
        type ipv6_addr
        flags interval
        # Lista dos IPv6 com permissão
        elements = {
            ::1,
            2804:1234:bebe::/48
        }
    }

    chain input {
        type filter hook input priority 0;

        # Aceita ICMP apenas das origens com permissão
        ip saddr @ACESSO_TOTAL4 ip protocol icmp icmp type echo-request accept
        ip6 nexthdr icmpv6 ip6 saddr @ACESSO_TOTAL6 icmpv6 type echo-request accept

        # Permite acesso as portas vindo das origens com permissão
        ip  saddr @ACESSO_TOTAL4 tcp dport { $PORTS_ACCEP_ADM } counter accept
        ip6 saddr @ACESSO_TOTAL6 tcp dport { $PORTS_ACCEP_ADM } counter accept

        # Fecha todo resto
        ip  daddr { $IPV4_SERV } ct state related,established counter accept
        ip  daddr { $IPV4_SERV } counter drop
        ip6 daddr { $IPV6_SERV } ct state related,established counter accept
        ip6 daddr { $IPV6_SERV }  counter drop

        type filter hook input priority 0;
    }
    chain forward {
        type filter hook forward priority 0;
    }
    chain output {
        type filter hook output priority 0;
    }
}
</pre>
<p>Inicie o nftables</p>
<pre class="remontti-code"># systemctl enable nftables
# systemctl start nftables</pre>
<p>Você pode simplesmente rodar um scanner de porta no seu IP público bem como um ping, o mesmo não deve responde. </p>
<h3>Instalação FastNetMon (Edição da comunidade)</h3>
<p>FastNetMon se encontra no repositório do Debian 12</p>
<pre class="remontti-code"># apt search fastnetmon</pre>
<pre class="remontti-code-plain">Sorting... Pronto
Full Text Search... Pronto
fastnetmon/testing 1.2.4-2 amd64
  fast DDoS analyzer with sflow/netflow/mirror support (community edition)</pre>
<pre class="remontti-code"># apt install fastnetmon -y</pre>
<p>Adicione todos os prefixos do seu AS, são esses os IPs serão feito analise. Dica: se você for usar o grafana recomendo cadastras todos os prefixos /24 para poder visualizar o trafego de cada prefixo em especifico</p>
<pre class="remontti-code"># vim /etc/networks_list</pre>
<pre class="remontti-code-plain">72.72.72.0/24
72.72.73.0/24
72.72.74.0/24
72.72.75.0/24
</pre>
<p>Crie também o arquivo que irá conter a lista branca de IPs (Explico mais a frente)</p>
<pre class="remontti-code"># &gt; /etc/networks_whitelist</pre>
<p>As configurações do Fastnetmon ficam em <strong>/etc/fastnetmon.conf</strong>, vamos fazer alguns ajustes básicos:<br />
Vamos começar ativando o serviço de netflow. Utilizarei o comando <strong>sed</strong> que irá buscar no arquivo <strong>netflow = off</strong> e alterar para <strong>netflow = on</strong>, nos comandos seguintes farei o mesmo, se desejar acesse o arquivo e edite manualmente.</p>
<pre class="remontti-code"># sed -i &#039;s/netflow = off/netflow = on/&#039; /etc/fastnetmon.conf</pre>
<p><strong>Ajustes para Huawei</strong></p>
<pre class="remontti-code"># sed -i &#039;s/average_calculation_time = 5/average_calculation_time = 15/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/netflow_sampling_ratio = 1/netflow_sampling_ratio = 1024/&#039; /etc/fastnetmon.conf</pre>
<p><strong>Ajustes para Mikrotik</strong></p>
<pre class="remontti-code"># Não precisa alterar nada aqui</pre>
<p>Defina por quanto tempo em segundos um IP ficará em blackhole o padrão é 1900 seg. No comando estou alterando para 10min: </p>
<pre class="remontti-code"># sed -i &#039;s/ban_time = 1900/ban_time = 600/&#039; /etc/fastnetmon.conf</pre>
<p>Altera o top 7 para o top 10 ao usar o comando fastnetmon_client (Ao seu gosto)</p>
<pre class="remontti-code"># sed -i &#039;s/max_ips_in_list = 7/max_ips_in_list = 10/&#039; /etc/fastnetmon.conf</pre>
<p>Temos diferentes abordagens para detecção dos ataques: Pacotes por segundos, largura de banda e por fluxo (flows), protocolos, nessa parte irei habilitar todos filtros, mas cada caso é uma realidade.</p>
<pre class="remontti-code"># sed -i &#039;s/ban_for_flows = off/ban_for_flows = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_tcp_bandwidth = off/ban_for_tcp_bandwidth = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_udp_bandwidth = off/ban_for_udp_bandwidth = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_icmp_bandwidth = off/ban_for_icmp_bandwidth = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_tcp_pps = off/ban_for_tcp_pps = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_udp_pps = off/ban_for_udp_pps = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_icmp_pps = off/ban_for_icmp_pps = on/&#039; /etc/fastnetmon.conf</pre>
<p>Se desejar ter mais detalhes no log, aumenta de 20 para até 200 linhas de registro no log.</p>
<pre class="remontti-code"># sed -i &#039;s/ban_details_records_count = 20/ban_details_records_count = 200/&#039; /etc/fastnetmon.conf</pre>
<p>Como temos todas as detecções ativas, precisamos ajustar cada situação para sua realidade. Você precisa ter em mente qual é o maior tráfego que pode atingir por um IP da sua rede (seu maior plano) com base nisso tenha em mente que a cada 100MB gera em torno de 10.000 pps por segundo, <strong>isso não é regra</strong> mas pode ser uma base inicial. Vamos imaginar então que meu maior plano seja 900MB, farei uma ajuste no <strong>threshold_pps</strong> para 110.000 pps para não pegar alguma rajada inicial. <strong>Mas vale lembrar que inicialmente você precisa estudar sua rede e adaptar a sua realidade.</strong></p>
<pre class="remontti-code"># sed -i &#039;s/threshold_pps = 20000/threshold_pps = 110000/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/threshold_tcp_pps = 100000/threshold_tcp_pps = 90000/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/threshold_udp_pps = 100000/threshold_udp_pps = 90000/&#039; /etc/fastnetmon.conf</pre>
<p>Agora em <strong>threshold_mbps</strong> seria o maior tráfego que você irá permitir, eu normalmente não altero e deixo no padrão 1gb. E em <strong>threshold_flows</strong> o fluxos de limite qual também mantenho o mesmo valor 3500.</p>
<pre class="remontti-code"># sed -i &#039;s/threshold_mbps = 1000/threshold_mbps = 999/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/threshold_tcp_mbps = 100000/threshold_tcp_mbps = 900/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/threshold_udp_mbps = 100000/threshold_udp_mbps = 900/&#039; /etc/fastnetmon.conf</pre>
<p>Ajustes de ICMP</p>
<pre class="remontti-code"># sed -i &#039;s/threshold_icmp_mbps = 100000/threshold_icmp_mbps = 100/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/threshold_icmp_pps = 100000/threshold_icmp_pps = 10000/&#039; /etc/fastnetmon.conf</pre>
<p>O netflow ouve a porta padrão 2055 se desejar alterar basta alterar o valor de <strong>netflow_port</strong>. Irei alterar para 52055.</p>
<pre class="remontti-code"># sed -i &#039;s/netflow_port = 2055/netflow_port = 52055/&#039; /etc/fastnetmon.conf</pre>
<p>Ainda em /etc/fastnetmon.conf temos <strong>notify_script_path</strong> que sempre que o fastnetmon identificar um ataque irá executar o script <strong>/usr/local/bin/notify_about_attack.sh</strong>, identificando o IP da sua rede que está sofrendo <strong>(incoming)</strong> o ataque ou que está atacando <strong>(outgoing)</strong> alguém. <strong>Ele NÃO irá identificar os IPs de origem</strong>, pois em um ataque quase sempre as origens são alteradas por milhares de IPs aleatórios.  </p>
<p>Faça alguns ajustes nos parâmetros do kernel</p>
<pre class="remontti-code"># vim /etc/sysctl.conf</pre>
<p>Adicione ao final do arquivo, observe enp0s3 é o nome da sua interface de rede coloque o nome da sua, pode usar o comando ip addr para visualizar </p>
<pre class="remontti-code-plain">
net.ipv4.ip_forward = 1
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.lo.rp_filter = 0
net.ipv4.conf.enp0s3.rp_filter = 0</pre>
<p>Carregue as alterações:</p>
<pre class="remontti-code"># sysctl -p</pre>
<p>Habilite e reinicie o fastnetmon para carregar as novas configurações.</p>
<pre class="remontti-code"># systemctl enable fastnetmon
# systemctl restart fastnetmon</pre>
<p>Verifique se a porta 52055/udp esta ouvindo:</p>
<pre class="remontti-code"># netstat -putan  | grep 52055</pre>
<pre class="remontti-code-plain">udp        0      0 0.0.0.0:52055           0.0.0.0:*                           2522/fastnetmon     </pre>
<p>Bom mas antes de criarmos nosso script notify_about_attack.sh, precisamos preparar algumas coisas, e antes de mais nada vamos configurar nosso Huawei para enviar os dados.</p>
<p><strong>Roteador RuterOS/Mikrotik:</strong><br />
Informe apenas suas interfaces de upstream (operadoras) ex: spf1,sfp1.100</p>
<pre class="remontti-code">
RouterOS# /ip traffic-flow set active-flow-timeout=5s cache-entries=1k inactive-flow-timeout=1s interfaces=spf1,sfp1.100
RouterOS# /ip traffic-flow target add dst-address=10.52.52.2 v9-template-refresh=5 v9-template-timeout=1s
</pre>
<p><strong>Roteador Huawei:</strong></p>
<pre class="remontti-code">&lt;HUAWEI&gt; system-view
[~HUAWEI] ip netstream export version ipfix peer-as bgp-nexthop ttl
[*HUAWEI] ip netstream export template sequence-number fixed
[*HUAWEI] ip netstream export index-switch 32
[*HUAWEI] ip netstream as-mode 32
[*HUAWEI] ip netstream timeout active 1
[*HUAWEI] ip netstream timeout inactive 15
[*HUAWEI] ip netstream export template timeout-rate 1
[*HUAWEI] ip netstream export template option sampler
[*HUAWEI] ip netstream export template option application-label
[*HUAWEI] ip netstream sampler fix-packets 1024 inbound
[*HUAWEI] ip netstream sampler fix-packets 1024 outbound
[*HUAWEI] ip netstream export source 10.52.52.1
[*HUAWEI] ip netstream export host 10.52.52.2 52055</pre>
<p>slot 0 NE8000F1A / slot 10 ou 9 NE8000 M8 / slot 3 NE40</p>
<pre class="remontti-code">[*HUAWEI] slot &lt;0-10&gt;
[*HUAWEI] ip netstream sampler to slot self
[*HUAWEI]  ipv6 netstream sampler to slot self</pre>
<p>Será necessário adicionar em todas suas interfaces de Uplink: </p>
<pre class="remontti-code-plain"> ip netstream inbound
 ip netstream outbound</pre>
<p>Exemplo:</p>
<pre class="remontti-code">
interface 40GE0/1/49.71
 vlan-type dot1q 71
 description BruxaDo71Telecom
 ip address 71.71.71.2 255.255.255.252
 statistic enable
 ip netstream inbound
 ip netstream outbound
</pre>
<p>Com o tcpdump vamos monitorar a interface para ver o que esta chegando na porta.</p>
<pre class="remontti-code"># tcpdump -i enp0s3 -n udp port 52055 -T cnfp -c 10</pre>
<p>Se seu NE estiver mandado os pacotes você terá um resultado como:</p>
<pre class="remontti-code-plain">tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens192, link-type EN10MB (Ethernet), capture size 262144 bytes
14:25:19.601113 IP 10.52.52.1.40000 &gt; 10.52.52.2.52055: NetFlow v9
14:25:19.608068 IP 10.52.52.1.40000 &gt; 10.52.52.2.52055: NetFlow v9
14:25:19.668054 IP 10.52.52.1.40000 &gt; 10.52.52.2.52055: NetFlow v9
14:25:19.691123 IP 10.52.52.1.40000 &gt; 10.52.52.2.52055: NetFlow v9
14:25:19.768055 IP 10.52.52.1.40000 &gt; 10.52.52.2.52055: NetFlow v9
14:25:19.781129 IP 10.52.52.1.40000 &gt; 10.52.52.2.52055: NetFlow v9
14:25:19.831133 IP 10.52.52.1.40000 &gt; 10.52.52.2.52055: NetFlow v9
14:25:19.858054 IP 10.52.52.1.40000 &gt; 10.52.52.2.52055: NetFlow v9
14:25:19.941124 IP 10.52.52.1.40000 &gt; 10.52.52.2.52055: NetFlow v9
14:25:19.958060 IP 10.52.52.1.40000 &gt; 10.52.52.2.52055: NetFlow v9
10 packets captured
10 packets received by filter
0 packets dropped by kernel</pre>
<p>Agora com o comando: </p>
<pre class="remontti-code"># fastnetmon_client</pre>
<p>Iremos visualizar os TOP IPs</p>
<pre class="remontti-code-plain">FastNetMon 1.1.3 master git- Pavel Odintsov: stableit.ru
IPs ordered by: packets
Incoming traffic       724347 pps   6998 mbps    161 flows
72.72.72.238            51973 pps    569 mbps      0 flows  *banned*
72.72.72.112            14390 pps    154 mbps      0 flows
72.72.72.93             14000 pps    150 mbps      0 flows
72.72.72.161            11705 pps    129 mbps      0 flows
72.72.72.118             8797 pps     86 mbps      0 flows
72.72.72.43              7602 pps     84 mbps      0 flows
72.72.72.111             6669 pps     64 mbps      0 flows

Outgoing traffic       291008 pps    705 mbps    101 flows
72.72.72.238            18009 pps     14 mbps      0 flows  *banned*
72.72.72.112             7929 pps      5 mbps      0 flows
72.72.72.93              7110 pps     10 mbps      0 flows
72.72.72.14              4910 pps     40 mbps      0 flows
72.72.72.43              4887 pps      2 mbps      0 flows
72.72.72.161             4537 pps      2 mbps      0 flows
72.72.72.111             3933 pps     14 mbps      0 flows

Internal traffic             0 pps      0 mbps

Other traffic              420 pps      0 mbps

Screen updated in:              0 sec 331 microseconds
Traffic calculated in:          0 sec 854 microseconds
Total amount of IPv6 packets related to our own network: 0
Not processed packets: 0 pps 

Subnet load:
72.72.72.0/22      pps in: 256000   out: 52000    mbps in: 9630  out: 1077
100.100.0.6/32     pps in: 0        out: 0        mbps in: 0     out: 0
</pre>
<p>Perceba que o IP <strong>72.72.72.238</strong> foi banido, pois o mesmo excedeu os pps de 50.000, no entanto este é um dos IPs que então em meu CGNAT, e vai ser natural este ter um comportamento diferente. Para que o <strong>fastnetmon ignore o mesmo</strong> você pode cria uma <strong>lista branca</strong>. Não se preocupe se isso acontecer com você o fastnetmon não ira fazer nenhuma ação, pois não configuramos nada ainda.<br />
Para criar a lista branca <strong>networks_whitelist</strong> com os IPs ou prefixo que deseja ignorar.</p>
<pre class="remontti-code"># vim /etc/networks_whitelist</pre>
<p>Exemplo</p>
<pre class="remontti-code-plain">72.72.72.224/28
72.72.73.224/28</pre>
<p>Reinicie para carregar as novas configurações.</p>
<pre class="remontti-code"># systemctl restart fastnetmon</pre>
<h3>Bot Telegram</h3>
<p>Para receber notificações pelo Telegram juntamente com o arquivo de log, vai ser necessário criar um bot do telegram para o uso do mesmo. Se você não sabe como criar um Bot para telegram basta você falar com o <a href="https://telegram.me/BotFather" rel="noopener" target="_blank">@BotFather</a> e enviar para ele <strong>/newbot</strong>, ele irá pedir qual nome você gostaria de dar a seu bot, e em seguida ira gera um token que vamos precisar a seguir. </p>
<p>Para o Telegram vamos usar um scriptzinho que criei.</p>
<pre class="remontti-code"># cd /tmp/
# wget https://github.com/remontti/TelegramCMD/archive/master.zip
# unzip /tmp/master.zip
# chmod a+x /tmp/TelegramCMD-master/telegram
# mv /tmp/TelegramCMD-master/telegram* /usr/local/bin/
# ln -s /usr/local/bin/telegram /bin/telegram</pre>
<p>Edite o token.conf e altere para o seu TOKEN.</p>
<pre class="remontti-code"># vim /usr/local/bin/telegram.conf/token.conf</pre>
<pre class="remontti-code">######################################
# Telegram bot                       #
# Create a new bot with @BotFather   #
# get TOKEN                          #
######################################

TOKEN=&quot;123456789:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF&quot;</pre>
<p>Esse script você pode usar para diversas coisas, ele será capaz de zipar um diretorio e lhe enviar o arquivo bem como enviar apenas uma mensagem. Como usar? É importante você saber que o IDs de grupos tem um &#8220;-&#8221; no inicio do ID, já usuários não. Para descobrir o ID do seu usuário fale com o bot <a href="https://telegram.me/myidbot" rel="noopener" target="_blank"><strong>@myidbot</strong></a> e envie para ele <strong>/getid</strong>, para saber de um grupo adicione <strong>@myidbot</strong> ao seu grupo e envie <strong>/getgroupid@myidbot</strong>. Realize um teste com um dos comandos: (Não esqueça de alterar pelo seu ID)</p>
<pre class="remontti-code-plain">Uso: telegram [Opções]
  -m: Para enviar uma mensagem
     ex: telegram -m &quot;ID Chat&quot; &quot;Meu assunto&quot; &quot;Minha mensagem...&quot;
     ex: telegram -m &quot;-123456789&quot; &quot;Notificação&quot; &quot;Mensagem para um grupo ID&quot;
     ex: telegram -m &quot;123456789&quot; &quot;Notificação&quot; &quot;Mensagem para direta/privado&quot;

  -f: Para enviar um arquivo
     ex: telegram -f &quot;ID Chat&quot; &quot;/diretorio/arquivo&quot; &quot;nome do arquivo zip&quot; &quot;Comentário&quot;
     ex: telegram -f &quot;12345689&quot; /var/log/syslog syslog &quot;Logs do sistema para user privado&quot;
     ex: telegram -f &quot;-12345689&quot; /var/log/syslog syslog &quot;Logs do sistema para um grupo&quot;

  -t: Para enviar um arquivo sem compactar
     ex: telegram -f &quot;ID Chat&quot; &quot;/diretorio/arquivo.txt&quot; &quot;Mensagem&quot;
     ex: telegram -f &quot;-12345689&quot; /var/log/fastnetmon.log &quot;Logs do sistema&quot;</pre>
<h3>FRR</h3>
<p>Vamos realizar a instalação do <a href="http://frrouting.org/" rel="noopener" target="_blank">FRRouting</a> (FRR) para fechar sessão BGP entre o roteador de borda e servidor.</p>
<pre class="remontti-code"># apt install frr frr-doc</pre>
<p>Ative o modulo BGP</p>
<pre class="remontti-code"># sed -i &#039;s/bgpd=no/bgpd=yes/&#039; /etc/frr/daemons</pre>
<p>Reinicie o FRR</p>
<pre class="remontti-code"># systemctl restart frr</pre>
<p>Entre no shell VTY do FRR.</p>
<pre class="remontti-code"># vtysh</pre>
<p>Rode o comando: `show running-config`</p>
<pre class="remontti-code-plain">Hello, this is FRRouting (version 8.4.2).
Copyright 1996-2005 Kunihiro Ishiguro, et al.

fastnetmon#  show running-config 
Building configuration...

Current configuration:
!
frr version 8.4.2
frr defaults traditional
hostname fastnetmon
log syslog informational
no ipv6 forwarding
service integrated-vtysh-config
!
end
</pre>
<p>Agora entre no modo de configuração, e vamos preparar nosso peer com o router de borda. No exemplo está praticamente auto explicativo, vamos fechar o peer e <strong>deixar</strong> ser anunciado <strong>apenas nossos prefixos</strong> e aplicaremos a community <strong>65001:666</strong> para prefixos <strong>/32</strong> e <strong>65001:777</strong> para prefixos <strong>/24</strong></p>
<pre class="remontti-code">configure terminal
!
ip prefix-list FASTNETMON_EXPORT_32 seq 5 permit 72.72.72.0/22 le 32
!
ip prefix-list FASTNETMON_EXPORT_24 seq 5 permit 72.72.72.0/22 le 24
!
route-map MARK_FASTNETMON_IMPORT deny 10
exit
!
route-map MARK_FASTNETMON_EXPORT permit 10
 match ip address prefix-list FASTNETMON_EXPORT_24
 set community 65001:777
exit
! 
route-map MARK_FASTNETMON_EXPORT permit 20
 match ip address prefix-list FASTNETMON_EXPORT_32
 set community 65001:666
exit

!
router bgp 260072
 bgp router-id 10.52.52.2
 neighbor 10.52.52.1 remote-as 260072
 neighbor 10.52.52.1 description &quot;BORDA&quot;
 !
 address-family ipv4 unicast
  neighbor 10.52.52.1 route-map MARK_FASTNETMON_IMPORT in
  neighbor 10.52.52.1 route-map MARK_FASTNETMON_EXPORT out
 exit-address-family
exit
!
end
write memory
exit</pre>
<h4>Configuração RouterOS/Mikrotik </h4>
<p>Crie um filtro de entrada que todas as rotas /32 e /24 aprendida do fastnetmon seja setadas como blackhole ou como prefixo para mitigação, e não ensine nada para ele.</p>
<pre class="remontti-code">/routing filter
add action=accept chain=FASTNETMON_IMPORT_IPV4 prefix-length=32 \
 set-bgp-communities=65444:666 set-distance=1 set-type=blackhole
add action=accept chain=FASTNETMON_IMPORT_IPV4 prefix-length=24 \
 set-bgp-communities=65444:777 set-distance=1 set-type=blackhole
add action=discard chain=FASTNETMON_IMPORT_IPV4
add action=discard chain=FASTNETMON_EXPORT_IPV4</pre>
<p>Atenção para a instance que deve estar selecionada corretamente (use a mesma que você usa com sua operadora).</p>
<pre class="remontti-code">/routing bgp peer add name=FASTNETMON remote-as=260072 \
 in-filter=FASTNETMON_IMPORT_IPV4 out-filter=FASTNETMON_EXPORT_IPV4 \
 remote-address=10.52.52.2 update-source=10.52.52.1</pre>
<p>Exemplo de configuração para filtro para operadora</p>
<pre class="remontti-code">/routing filter
add action=accept bgp-communities=65444:666 \
 chain=OPERADORA_IPv4_EXPORT prefix-length=32 set-bgp-communities=71:666
add action=accept chain=OPERADORA_IPv4_EXPORT \
 prefix=72.72.72.0/22 prefix-length=22-24 set-bgp-communities=&quot;&quot;
add action=discard chain=OPERADORA_IPv4_EXPORT</pre>
<p>Exemplo de configuração para filtro para mitigação</p>
<pre class="remontti-code">/routing filter
add action=accept bgp-communities=65444:777 \
 chain=MITIGACAO_IPv4_EXPORT prefix=72.72.72.0/22 \
 prefix-length=24 set-bgp-communities=19000:666
add action=discard chain=MITIGACAO_IPv4_EXPORT</pre>
<h4>Configurações do Huawei</h4>
<pre class="remontti-code">&lt;HUAWEI&gt; system-view
Enter system view, return user view with return command.</pre>
<p>Crie uma rota estática de Blackhole</p>
<pre class="remontti-code">[~HUAWEI] ip route-static 192.0.2.1 255.255.255.255 NULL0 description BLACKHOLE</pre>
<p>Crie um filtro que irá aceitar qualquer rota /32</p>
<pre class="remontti-code">[*HUAWEI] ip ip-prefix  ACCEP_PREFIX_MASK32_FASTNETMON_IPV4 index 10 permit 0.0.0.0 0 greater-equal 32</pre>
<p>Crie um filtro que irá aceitar as rota /24 de seu prefixo</p>
<pre class="remontti-code">[*HUAWEI] ip ip-prefix  ACCEP_PREFIX_MASK24_FASTNETMON_IPV4 index 10 permit 72.72.72.0 22 greater-equal 24</pre>
<p>Crie filtro se desejar rejeitar algum IP ou prefixo atacado atacado, caso você deixar o fastnetmon anúnciar seu NE pode rejeitar (Ex IP Servidores ou CGNAT)</p>
<pre class="remontti-code">[*HUAWEI] ip ip-prefix  IGNORE_PREFIX_FASTNETMON_IPV4 index 10 permit 72.72.72.224 28 greater-equal 28 less-equal 32
[*HUAWEI] ip ip-prefix  IGNORE_PREFIX_FASTNETMON_IPV4 index 20 permit 72.72.73.224 28 greater-equal 28 less-equal 32</pre>
<p>Crie um filtro para nossas community  65001:666 65001:777</p>
<pre class="remontti-code">[*HUAWEI] ip community-filter basic COMM_FASTNETMON_BLACKHOLE_32 index 10 permit 65001:666
[*HUAWEI] ip community-filter basic COMM_FASTNETMON_BLACKHOLE_24 index 10 permit 65001:777</pre>
<p>Defina community para usar nos RP das operadoras</p>
<pre class="remontti-code">[*HUAWEI] ip community-filter basic COMM_BLACKHOLE_32 index 10 permit 65444:666
[*HUAWEI] ip community-filter basic COMM_BLACKHOLE_24 index 10 permit 65444:777</pre>
<p>Vamos montar agora nosso route policy de import (rotas que iremos receber). A 1ª é ignorar os prefixos <strong>IGNORE_PREFIX_FASTNETMON_IPV4</strong></p>
<pre class="remontti-code">[*HUAWEI] route-policy FASTNETMON_IMPORT_IPV4 deny node 1000
[*HUAWEI]  if-match ip-prefix IGNORE_PREFIX_FASTNETMON_IPV4</pre>
<p>A 2º é o que vir marcado do fastnetmon com 65001:666 (COMM_FASTNETMON_BLACKHOLE_32) jogar para blackhole e aplicar uma community nova <strong>65444:666</strong>, como no exemplo aqui meu AS é de 32bits vou usar um AS privado, mas onde seu AS é de 16bits o mais comunity de se encontrar é AS:666. Assim se você for trânsito de outro AS você pode montar em suas route policy para aceitar prefixos do AS dele com /32 marcados com AS:666 e jogar para blackhole também fica dica!</p>
<pre class="remontti-code">[*HUAWEI] route-policy FASTNETMON_IMPORT_IPV4 permit node 1010
[*HUAWEI]  if-match community-filter COMM_FASTNETMON_BLACKHOLE_32
[*HUAWEI]  apply local-preference 999
[*HUAWEI]  apply ip-address next-hop 192.0.2.1
[*HUAWEI]  apply community 65444:666
[*HUAWEI]  if-match ip-prefix ACCEP_PREFIX_MASK32_FASTNETMON_IPV4</pre>
<p>Vamos preparar também para receber os prefixos /24 caso for anunciar para um mitigação por exemplo.</p>
<pre class="remontti-code">
[*HUAWEI] route-policy FASTNETMON_IMPORT_IPV4 permit node 1020
[*HUAWEI]  if-match community-filter COMM_FASTNETMON_BLACKHOLE_24
[*HUAWEI]  apply local-preference 999
[*HUAWEI]  apply ip-address next-hop 192.0.2.1
[*HUAWEI]  apply community 65444:777
[*HUAWEI]  if-match ip-prefix ACCEP_PREFIX_MASK24_FASTNETMON_IPV4</pre>
<p>E a 3ª ignoramos o resto como boas praticas.</p>
<pre class="remontti-code">[*HUAWEI] route-policy FASTNETMON_IMPORT_IPV4 deny node 9999</pre>
<p>Para as route policy de export (Rotas que o NE irá ensinar) colocarei apenas um Deny pois ele não precisa ensinar nada.</p>
<pre class="remontti-code">[*HUAWEI] route-policy FASTNETMON_EXPORT_IPV4 deny node 9999
[*HUAWEI] commit</pre>
<p>Vamos ao peer</p>
<pre class="remontti-code">[~HUAWEI] bgp 260072
[~HUAWEI] undo peer 10.52.52.2
[*HUAWEI]  peer 10.52.52.2 as-number 260072
[*HUAWEI]  peer 10.52.52.2 description BORDA_VS_FASTNETMON_IPV4
[*HUAWEI]  peer 10.52.52.2 timer connect-retry 1
[*HUAWEI]  peer 10.52.52.2 connect-interface 10.52.52.1
[*HUAWEI]  peer 10.52.52.2 timer keepalive 10 hold 30 
           y
[*HUAWEI]  ipv4-family unicast
[*HUAWEI]   peer 10.52.52.2 enable
            y
[*HUAWEI]   peer 10.52.52.2 public-as-only
[*HUAWEI]   peer 10.52.52.2 route-policy FASTNETMON_IMPORT_IPV4 import
[*HUAWEI]   peer 10.52.52.2 route-policy FASTNETMON_EXPORT_IPV4 export
[*HUAWEI]   peer 10.52.52.2 next-hop-local
[*HUAWEI]   peer 10.52.52.2 advertise-community
[*HUAWEI]   peer 10.52.52.2 advertise-ext-community
[*HUAWEI] commit
[~HUAWEI] run save </pre>
<p>Em caso de alguma <strong>emergência</strong>, para <strong>baixar</strong> a sessão use:</p>
<pre class="remontti-code">[~HUAWEI] bgp 260072
[*HUAWEI] peer 10.52.52.2 ignore
[*HUAWEI] commit</pre>
<p>Para <strong>subir</strong> novamente:</p>
<pre class="remontti-code">[~HUAWEI] bgp 260072
[*HUAWEI] undo peer 10.52.52.2 ignore
[*HUAWEI] commit</pre>
<p>Verifique se sua sessão subiu:</p>
<pre class="remontti-code">[*HUAWEI] display bgp peer | include 10.52.52.2</pre>
<pre class="remontti-code-plain"> BGP local router ID : x.x.x.x
 Local AS number : 260072
 Total number of peers : 13                 Peers in established state : 13

  Peer                             V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State  PrefRcv
  10.52.52.2                       4       260072   897801  1088107     0 2496h26m Established        0</pre>
<p>No FRR use `show bgp summary`</p>
<pre class="remontti-code"># vtysh</pre>
<pre class="remontti-code-plain"># show bgp summary
IPv4 Unicast Summary:
BGP router identifier 10.52.52.2, local AS number 260072 vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 1, using 21 KiB of memory

Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
10.52.52.1      4     260072         5         5        0    0    0 00:02:52            0        0

Total number of neighbors 1
# exit</pre>
<p>Para repassar os prefixos marcados como blackhole para sua operadora você precisará saber qual é a community que a mesma utiliza e se ela lhe oferece esse recurso, em seguida você irá adicionar a route policy da sua operadora uma nova regra:</p>
<p>No exemplo tudo que recebemos do fastnetmon passamos a aplicar a community 65444:666, logo tudo que for marcado com a mesma iremos repassar para operadora, com o community da operadora.</p>
<pre class="remontti-code">[~HUAWEI] route-policy UPSTREAM_OP_BRUXADO71_EXPORT_IPV4 permit node 2070
[*HUAWEI]  if-match community-filter COMM_BLACKHOLE_32
[*HUAWEI]  apply community 71:666</pre>
<p>Agora tudo que marcamos com community 65444:777 enviamos para mitigraçação</p>
<pre class="remontti-code">[*HUAWEI] route-policy UPSTREAM_MITIGAAI_EXPORT_IPV4 permit node 2070
[*HUAWEI]  if-match community-filter COMM_BLACKHOLE_24
[*HUAWEI]  apply community 1000:9999</pre>
<p>Pronto agora que já temos nosso peer Up entre router e servidor, nosso Bot mandando mensagem, iremos criar o script que será executado sempre que um ataque for identificado <strong>BAN</strong> ou <strong>UNBAN</strong>. Irei criar um diretório /var/log/fastnetmon_attacks/ataques qual irá ficar os ataques finalizados.</p>
<pre class="remontti-code"># mkdir /var/log/fastnetmon_attacks/ataques -p
# vim /usr/local/bin/notify_about_attack.sh</pre>
<p>Altere <strong>ID_CHAT=&#8217;-1000000000000&#8242;</strong> pelo ID do seu usuário ou grupo.<br />
Para anunciar os prefixos /24 do IP atacado altere <strong>ANUNCIAR_24</strong> para <strong>sim</strong><br />
Se não quiser receber o arquivo de log altere <strong>ARQUIVO_DE_LOG</strong> para <strong>nao</strong><br />
Dei uma encrementada para identificar a categoria do IP, que iremos ver em seguido o script que ira identificar, em <strong>IDENT_CATEGORIA</strong> vai poder classificar exemplo se um ip é de CGNAT, servidor&#8230; </p>
<pre class="remontti-code">#!/usr/bin/env bash
#
# Este script receberá os seguintes parâmetros:
# $1 IP do cliente
# $2 INCOMING -&gt; Vindo de fora da rede | OUTGOING -&gt; Saindo da sua rede
# $3 Pacotes por seguncoes
# $4 Ação (ban ou unban)
#
#--------------------------------------------------------------------------------
# Defina o ID do Chat ou Grupo  do Telegram (Grupos sempre começam com &quot;-&quot; )
ID_CHAT=&#039;-1000000000000&#039;
#
# Deseja anunciar prefixos /24? (sim/nao)
ANUNCIAR_24=&#039;nao&#039;
#
# Deseja enviar arquivo de log compactado para o telegram? (sim/nao)
ARQUIVO_DE_LOG=&#039;sim&#039;
#
# Deseja identificar a categoria do endereço atacado (sim/nao)
# script python /opt/rr_fastnetmon/prefixos.txt
IDENT_CATEGORIA=&#039;sim&#039;
#
# Seu ASN
ASN=260072
#--------------------------------------------------------------------------------
#
# Pegando prefixo 24
ip32=$1
prefixo24=&quot;${ip32%.*}.0/24&quot;
#
quebralinha=&quot;
&quot;
#
if [ &quot;$2&quot; = &quot;incoming&quot; ]; then
  TIPO=&quot;Sendo atacado&quot;
else
  TIPO=&quot;Realizando um ataque&quot;
fi
#
if [ &quot;$IDENT_CATEGORIA&quot; = &quot;sim&quot; ]; then
  CATEGORIA=$(/opt/rr_fastnetmon/categoria_ip.py $1)
else
  CATEGORIA=&quot;&quot;
fi
#
# Desbanindo um IP
if [ &quot;$4&quot; = &quot;unban&quot; ]; then
  # Remove IP do anuncio para o FRR
  if [ $ANUNCIAR_24 = &quot;sim&quot; ]; then
    /usr/local/bin/telegram -m &quot;$ID_CHAT&quot; &quot;&lt;b&gt;(UNBAN) Anúncios removido&lt;/b&gt;&quot; &quot;&lt;code&gt; Blackhole: $1/32$quebralinha Prefixo: $prefixo24&lt;/code&gt;&quot;
    vtysh --command &quot;configure terminal
    no ip route $1/32 lo
    no ip route $prefixo24 lo
    router bgp $ASN
     address-family ipv4 unicast
      no network $1/32
      no network $prefixo24
    &quot;
  else
    /usr/local/bin/telegram -m &quot;$ID_CHAT&quot; &quot;&lt;b&gt;(UNBAN) Anúncio removido&lt;/b&gt;&quot; &quot;&lt;code&gt; Blackhole: $1/32$quebralinha&lt;/code&gt;&quot;
    vtysh --command &quot;configure terminal
    no ip route $1/32 lo
    router bgp $ASN
     address-family ipv4 unicast
      no network $1/32
    &quot;
  fi
  # Movemos os logs para pasta ataques pois não queremos mais receber elas.
  mv /var/log/fastnetmon_attacks/$1* /var/log/fastnetmon_attacks/ataques
  exit 0
fi
#
# Banindo um IP
if [ &quot;$4&quot; = &quot;ban&quot; ]; then
  cp /var/log/fastnetmon_attacks/$1* /var/log/fastnetmon_attacks/$1.log.txt &amp;&gt;/dev/null
  # Anuncia IP ao FRR
  if [ $ANUNCIAR_24 = &quot;sim&quot; ]; then
    /usr/local/bin/telegram -m &quot;$ID_CHAT&quot; &quot;&lt;b&gt;(BAN) $TIPO&lt;/b&gt; [ $3 pps ]&quot; &quot;Anunciando$quebralinha&lt;code&gt; Blackhole: $1/32$quebralinha Prefixo: $prefixo24&lt;/code&gt;$quebralinha &lt;i&gt;$CATEGORIA&lt;/i&gt;&quot;
    vtysh --command &quot;configure terminal
    ip route $1/32 lo
    ip route $prefixo24 lo
    router bgp $ASN
     address-family ipv4 unicast
      network $1/32
      network $prefixo24
    &quot;
  else
    /usr/local/bin/telegram -m &quot;$ID_CHAT&quot; &quot;&lt;b&gt;(BAN) $TIPO&lt;/b&gt; [ $3 pps ]&quot; &quot;Anunciando$quebralinha&lt;code&gt; Blackhole: $1/32&lt;/code&gt;$quebralinha &lt;i&gt;$CATEGORIA&lt;/i&gt;&quot;
    vtysh --command &quot;configure terminal
    ip route $1/32 lo
    router bgp $ASN
     address-family ipv4 unicast
      network $1/32
    &quot;
  fi
  # Envio de log
  if [ $ARQUIVO_DE_LOG = &quot;sim&quot; ]; then
    /usr/local/bin/telegram -t &quot;$ID_CHAT&quot; /var/log/fastnetmon_attacks/$1.log.txt &quot;Logs do ataque&quot;
  fi
  sleep 2
  rm /var/log/fastnetmon_attacks/$1.log.txt &amp;&gt;/dev/null
  exit 0
fi
#
if [ &quot;$4&quot; == &quot;attack_details&quot; ]; then
  # Null
  exit 0
fi
</pre>
<p>De permissão para execução</p>
<pre class="remontti-code"># chmod a+x /usr/local/bin/notify_about_attack.sh</pre>
<p>Crie um diretório em /opt/rr_fastnetmon onde iremos colocar nossos scripts complementares</p>
<pre class="remontti-code"># mkdir /opt/rr_fastnetmon</pre>
<p>Crie o arquivo categoria_ip.py que utiliza python3 (Não se preocupe em instalar o python)</p>
<pre class="remontti-code"># vim /opt/rr_fastnetmon/categoria_ip.py</pre>
<p>Adicione:</p>
<pre class="remontti-code-plain">
#!/usr/bin/env python3

import sys
import ipaddress

if len(sys.argv) != 2:
    print(&quot;Uso: categoria_ip.py &lt;endereço IP&gt;&quot;)
    sys.exit(1)

ip = sys.argv[1]

# Converter o endereço IP fornecido em um objeto ipaddress.IPv4Address
endereco_ip = ipaddress.IPv4Address(ip)

# Procurar a categoria correspondente ao endereço IP no arquivo prefixos.txt
categoria = None

with open(&quot;/opt/rr_fastnetmon/prefixos.txt&quot;) as arquivo:
    for linha in arquivo:
        prefixo, cat = linha.strip().split(&quot; &quot;)
        rede = ipaddress.IPv4Network(prefixo)
        if endereco_ip in rede:
            categoria = cat
            break

if categoria is None:
    print(&quot;Categoria não encontrada para o endereço IP&quot;)
else:
    print(&quot;Categoria:&quot;, categoria)


</pre>
<pre class="remontti-code"># chmod +x /opt/rr_fastnetmon/categoria_ip.py</pre>
<p>Agora crie um arquivo prefixos.txt nele você pode classificar seus IPs assim no alarme ira lhe ajudar (ou você pode invetar algo novo). Coloque sempre os mais especificos primeiro caso você não queira declarar todos os prefixos.</p>
<pre class="remontti-code"># vim /opt/rr_fastnetmon/prefixos.txt</pre>
<p>Exemplo:</p>
<pre class="remontti-code-plain">
72.72.72.0/26 Servidor
72.72.72.128/26 CGNAT
72.72.73.0/24 Cliente_Dedicado
72.72.72.0/22 Clientes_Dinamico
</pre>
<p>Teste o script executando como no exemplo:</p>
<pre class="remontti-code"># /opt/rr_fastnetmon/categoria_ip.py 72.72.72.20
Categoria: Servidor

# /opt/rr_fastnetmon/categoria_ip.py 72.72.72.140
Categoria: CGNAT

# /opt/rr_fastnetmon/categoria_ip.py 72.72.73.100
Categoria: Cliente_Dedicado

# /opt/rr_fastnetmon/categoria_ip.py 72.72.72.80
Categoria: Clientes_Dinamico

# /opt/rr_fastnetmon/categoria_ip.py 72.72.75.9
Categoria: Clientes_Dinamico</pre>
<p>Exemplo de alarme no telegram<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/telegram.jpg" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/05/telegram.jpg" alt="" width="356" height="742" class="alignnone size-full wp-image-7368" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/05/telegram.jpg 356w, https://blog.remontti.com.br/wp-content/uploads/2023/05/telegram-144x300.jpg 144w" sizes="auto, (max-width: 356px) 100vw, 356px" /></a></p>
<p>Restarte o fastnetmon</p>
<pre class="remontti-code"># systemctl restart fastnetmon</pre>
<p>Se quiser fazer um teste manual simulando um anuncio de um IP (Cuidado se estiver anunciando prefixo) exemplo: 72.72.73.255/32</p>
<pre class="remontti-code"> # /usr/local/bin/notify_about_attack.sh 72.72.73.255 incoming 9996 ban</pre>
<p>Verificando se esta enviando:</p>
<pre class="remontti-code"># vtysh --command &quot; show ip bgp neighbors 10.52.52.1 advertised-routes&quot;</pre>
<pre class="remontti-code-plain">BGP table version is 3, local router ID is 10.52.52.2, vrf id 0
Default local pref 100, local AS 260072
Status codes:  s suppressed, d damped, h history, * valid, &gt; best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop&#039;s vrf id, &lt; announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

   Network          Next Hop            Metric LocPrf Weight Path
*&gt; 72.72.73.255/32  0.0.0.0                  0         32768 i

Total number of prefixes 1</pre>
<p>Para remover:</p>
<pre class="remontti-code"> # /usr/local/bin/notify_about_attack.sh 72.72.73.255 incoming 9996 unban</pre>
<p>Finalizamos a primeira parte sem fazer nenhum estrago ao servidor (CPU) <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> </p>
<p>Seria interessante fazer alguns testes de ataques (coisa pequena) mas com características reais de dentro da sua rede e de fora, escolha uma IP que não esteja em uso para tal! Para realizar esse ataque user o a ferramenta criada pelo ekovegeance: <a href="https://github.com/ekovegeance/DDOS" rel="noopener noreferrer" target="_blank">https://github.com/ekovegeance/DDOS</a> Cuidado você pode criar um alto uso de Hardware na sua rede!!!</p>
<p>Em um servidor/desktop linux vai precisar ter instalado os pacotes bash sudo curl netcat hping3 openssl stunnel nmap whois dnsutils.<br />
<a href="https://github.com/ekovegeance/DDOS/archive/v1.2.4.zip">Baixe os arquivos</a>, extraia entre em sua pasta e execute o arquivo ddos.</p>
<pre class="remontti-code">$ wget https://github.com/ekovegeance/DDOS/archive/v1.2.4.zip
$ unzip v1.2.4.zip 
$ cd DDOS-1.2.4/
$ ./ddos</pre>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2020/01/ddos.png" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/01/ddos.png" alt="" width="676" height="881" class="alignnone size-full wp-image-3988" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/01/ddos.png 676w, https://blog.remontti.com.br/wp-content/uploads/2020/01/ddos-230x300.png 230w" sizes="auto, (max-width: 676px) 100vw, 676px" /></a></p>
<h3>Gráficos Grafana</h3>
<p>Habilite o graphite no fastnetmon</p>
<pre class="remontti-code"># sed -i &#039;s/graphite = off/graphite = on/&#039; /etc/fastnetmon.conf</pre>
<p>Vamos instalar o <strong>influxdb</strong> para ser a base de dados</p>
<pre class="remontti-code"># apt install gnupg2 -y
# cd /tmp
# wget -q https://repos.influxdata.com/influxdata-archive_compat.key
# echo &#039;393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key&#039; \
  | sha256sum -c &amp;&amp; cat influxdata-archive_compat.key \
  | gpg --dearmor \
  | tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg &gt; /dev/null
# echo &#039;deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main&#039;\
  | tee /etc/apt/sources.list.d/influxdata.list
# apt update
# apt install influxdb -y</pre>
<p>Crie uma cópia do arquivo de configuração, e edite o mesmo</p>
<pre class="remontti-code"># cp /etc/influxdb/influxdb.conf /etc/influxdb/influxdb.conf.orig
# vim /etc/influxdb/influxdb.conf</pre>
<p>Localize [[graphite]] e insira a baixo as seguintes linhas:</p>
<pre class="remontti-code-plain">
[[graphite]]
  enabled = true
  bind-address = &quot;:2003&quot;
  protocol = &quot;tcp&quot;
  consistency-level = &quot;one&quot;
  separator = &quot;.&quot;
  templates = [
    &quot;fastnetmon.hosts.* app.measurement.cidr.direction.function.resource&quot;,
    &quot;fastnetmon.networks.* app.measurement.cidr.direction.resource&quot;,
    &quot;fastnetmon.total.* app.measurement.direction.resource&quot;
  ]</pre>
<p>Reinicie o influxdb</p>
<pre class="remontti-code"># systemctl restart influxdb</pre>
<p>Em seguida o fastnetmon</p>
<pre class="remontti-code"># systemctl restart fastnetmon</pre>
<p>Agora vamos acessar o o influxdb para ver se o banco e verificar se o graphite foi criado.</p>
<pre class="remontti-code"># influx</pre>
<pre class="remontti-code-plain">Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10</pre>
<pre class="remontti-code">&gt; SHOW databases</pre>
<pre class="remontti-code-plain">name: databases
name
----
_internal
graphite</pre>
<pre class="remontti-code">&gt; USE graphite</pre>
<pre class="remontti-code-plain">Using database graphite</pre>
<pre class="remontti-code">&gt; SHOW MEASUREMENTS</pre>
<pre class="remontti-code-plain">name: measurements
name
----
hosts
networks
total</pre>
<p>Se você tem pouco disco e deseja não salvar por tanto tempo, você pode ajustar o tempo de retenção dos dados, no comando estarei informando 90 dias (padrão é infinito) com métrica de tráfego para 7 dias (padrão ja é 7 dias), será necessário apagar o banco e recria-lo.</p>
<pre class="remontti-code">&gt; SHOW RETENTION POLICIES ON graphite</pre>
<pre class="remontti-code-plain">name    duration shardGroupDuration replicaN default
----    -------- ------------------ -------- -------
autogen 0s       168h0m0s           1        true</pre>
<p>Vamos remover o banco, criar novamente com os tempos desejados</p>
<pre class="remontti-code">&gt; DROP DATABASE graphite
&gt; CREATE DATABASE graphite WITH DURATION 90d SHARD DURATION 7d
&gt; SHOW RETENTION POLICIES ON graphite</pre>
<pre class="remontti-code-plain">name    duration  shardGroupDuration replicaN default
----    --------- ------------------ -------- -------
autogen 2160h0m0s 168h0m0s           1        true</pre>
<pre class="remontti-code">&gt; exit</pre>
<p>Reinicie os serviços novamente</p>
<pre class="remontti-code"># systemctl restart influxdb fastnetmon</pre>
<p>Você pode optar pelo modo bruto e remover com script.</p>
<pre class="remontti-code"># vim /root/limpa_graphite.sh</pre>
<p>Ajuste o número de dias que deseja que fique salvo apenas.</p>
<pre class="remontti-code">
#!/bin/bash

# Manter por quantos dias?
DIAS=&quot;7&quot;

# Define o banco de dados
DATABASE=&quot;graphite&quot;

# Define os comandos
COMMANDS=(&quot;DELETE FROM hosts WHERE time &lt; now() - ${DIAS}d&quot; &quot;DELETE FROM networks WHERE time &lt; now() - ${DIAS}d&quot; &quot;DELETE FROM total WHERE time &lt; now() - ${DIAS}d&quot;)

# Executa cada comando
for cmd in &quot;${COMMANDS[@]}&quot;; do
    echo &quot;Executing: $cmd&quot;
    influx -database &quot;$DATABASE&quot; -execute &quot;$cmd&quot;
done

echo &quot;Todos os comandos executados com sucesso&quot;
</pre>
<p>De permissão e execute, se desejar pode adicionar ao cron:</p>
<pre class="remontti-code"># chmod +x /root/limpa_graphite.sh
# /root/limpa_graphite.sh</pre>
<h4>Grafana</h3>
<p>Adicione o repositório do grafana e instale-o</p>
<pre class="remontti-code"># wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key
# echo &quot;deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main&quot; | tee -a /etc/apt/sources.list.d/grafana.list
# apt update; apt install grafana -y</pre>
<p>Habilite serviço para inicialização e inicie o mesmo</p>
<pre class="remontti-code"># systemctl enable grafana-server
# systemctl start grafana-server</pre>
<p>Acesse em seu navegador <strong>http://ip_privado:3000</strong> e entre com <strong>usuário e senha admin</strong> em seguida defina uma nova senha. Atualmente o grafana esta na versão 9.5.x caso você instale uma versão superior no futuro os passos não devem mudarem muito de locais.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_1.png" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_1.png" alt="" width="1453" height="777" class="alignnone size-full wp-image-7334" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_1.png 1453w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_1-300x160.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_1-1024x548.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_1-768x411.png 768w" sizes="auto, (max-width: 1453px) 100vw, 1453px" /></a></p>
<p>No menu vá em  <strong>Connections</strong>, clique em <strong>Connect data</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a2.png" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a2.png" alt="" width="1445" height="728" class="alignnone size-full wp-image-7338" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a2.png 1445w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a2-300x151.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a2-1024x516.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a2-768x387.png 768w" sizes="auto, (max-width: 1445px) 100vw, 1445px" /></a><br />
Localize influxDB e clique nele<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a3.png" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a3.png" alt="" width="1445" height="530" class="alignnone size-full wp-image-7339" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a3.png 1445w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a3-300x110.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a3-1024x376.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_a3-768x282.png 768w" sizes="auto, (max-width: 1445px) 100vw, 1445px" /></a></p>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_aa3.png" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_aa3.png" alt="" width="1451" height="583" class="alignnone size-full wp-image-7340" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_aa3.png 1451w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_aa3-300x121.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_aa3-1024x411.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_aa3-768x309.png 768w" sizes="auto, (max-width: 1451px) 100vw, 1451px" /></a></p>
<p>Preencha apenas:<br />
URL:<strong> http://localhost:8086</strong><br />
Database: <strong>graphite</strong><br />
E clique em <strong>Save & test</strong>, você deve ter a resposta <strong>atasource is working. 3 measurements found</strong>.<br />
Mas antes de sair anote o uid que esta na <strong>URL</strong> no meu caso: <strong>da56a879-9ae6-42ca-aeb5-236e8b439be4</strong>, vamos precisar dele para facilitar ao importar as dashs.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_6.png" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_6.png" alt="" width="1428" height="878" class="alignnone size-full wp-image-7341" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_6.png 1428w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_6-300x184.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_6-1024x630.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_6-768x472.png 768w" sizes="auto, (max-width: 1428px) 100vw, 1428px" /></a></p>
<p>Faça <a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/Fastnetmon-Grafana.zip"><strong>download aqui</strong></a> das Dashs e importe.<br />
- Fastnetmon - Home<br />
- Fastnetmon - Painel Geral<br />
- Fastnetmon - Top PPs<br />
- Fastnetmon - Top Prefixos<br />
- Fastnetmon - Top Hosts MBs<br />
- Fastnetmon - Top Tráfego saída<br />
- Fastnetmon - Tráfego por Prefixo<br />
- Fastnetmon - Tráfego por endereço IPv4</p>
<p>Extraia o arquivo zip e abra em um editor de texto os arquivos .json localize <strong>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</strong> e substitua pelo seu <strong>uid</strong>, assim lhe poupará de fazer ajustes manuais.<br />
Se seu desktop é um linux use o comando sed e faça em um unico comando:<br />
`sed -i 's/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/da56a879-9ae6-42ca-aeb5-236e8b439be4/' *.json`<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_7a.png" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_7a.png" alt="" width="1272" height="578" class="alignnone size-full wp-image-7343" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_7a.png 1272w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_7a-300x136.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_7a-1024x465.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_7a-768x349.png 768w" sizes="auto, (max-width: 1272px) 100vw, 1272px" /></a></p>
<p>Volte para o menu <strong>e clique em Dashboards</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_4.png" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_4.png" alt="" width="1440" height="479" class="alignnone size-full wp-image-7336" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_4.png 1440w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_4-300x100.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_4-1024x341.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_4-768x255.png 768w" sizes="auto, (max-width: 1440px) 100vw, 1440px" /></a><br />
Importe uma a um das Dashs.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_5.png" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_5.png" alt="" width="1444" height="580" class="alignnone size-full wp-image-7337" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_5.png 1444w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_5-300x120.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_5-1024x411.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/05/grafana_fastnetmon_5-768x308.png 768w" sizes="auto, (max-width: 1444px) 100vw, 1444px" /></a></p>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2023/05/painel-geral.png" data-rel="lightbox-gallery-9BTRGF4p" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2023/05/painel-geral.png" alt="" width="2560" height="947" class="alignnone size-full wp-image-7374" srcset="https://blog.remontti.com.br/wp-content/uploads/2023/05/painel-geral.png 2560w, https://blog.remontti.com.br/wp-content/uploads/2023/05/painel-geral-300x111.png 300w, https://blog.remontti.com.br/wp-content/uploads/2023/05/painel-geral-1024x379.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2023/05/painel-geral-768x284.png 768w, https://blog.remontti.com.br/wp-content/uploads/2023/05/painel-geral-1536x568.png 1536w, https://blog.remontti.com.br/wp-content/uploads/2023/05/painel-geral-2048x758.png 2048w" sizes="auto, (max-width: 2560px) 100vw, 2560px" /></a></p>
<p>Gostou? Se sentindo mais seguro agora? É consultor e ganha $ com isso!?</p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a></p>
<p>Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>Abraço!</p>
<p>Fontes:<br />
<a href="https://fastnetmon.com/install/" rel="noopener" target="_blank">https://fastnetmon.com/install/</a><br />
<a href="https://docs.frrouting.org/en/latest/bgp.html" rel="noopener" target="_blank">https://docs.frrouting.org/en/latest/bgp.html</a><br />
<a href="https://deb.frrouting.org/" rel="noopener" target="_blank">https://deb.frrouting.org/</a><br />
<a href="https://fastnetmon.com/docs/influxdb_integration/" rel="noopener" target="_blank">https://fastnetmon.com/docs/influxdb_integration/</a><br />
<a href="https://grafana.com/docs/grafana/latest/installation/debian/" rel="noopener" target="_blank">https://grafana.com/docs/grafana/latest/installation/debian/</a></p>
<p>O post <a href="https://blog.remontti.com.br/7322">Fortalecendo a Resiliência da Rede: Detecção de Ataques DDoS com FastNetMon, FRRouting, Grafana e Implementação em Debian 12 com Huawei &#038; RouterOS</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/7322/feed</wfw:commentRss>
			<slash:comments>24</slash:comments>
		
		
			</item>
		<item>
		<title>BGP Monitoring Protocol (BMP) aprenda a instalar o OpenBMP</title>
		<link>https://blog.remontti.com.br/6723</link>
					<comments>https://blog.remontti.com.br/6723#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Thu, 04 Aug 2022 23:47:18 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[bgp]]></category>
		<category><![CDATA[cisco]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[Huawei]]></category>
		<category><![CDATA[juniper]]></category>
		<category><![CDATA[junos]]></category>
		<category><![CDATA[monitoramento]]></category>
		<category><![CDATA[openbmp]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=6723</guid>

					<description><![CDATA[<p>openBMP é um sistema de monitoramento BGP. Compatível com protocolo de monitoramento BGP (BMP). Os dados BGP são armazenados no banco de dados PostgreSQL. Os RIBs são mantidos pelo estado, bem como o histórico&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/6723">BGP Monitoring Protocol (BMP) aprenda a instalar o OpenBMP</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.openbmp.org/"><strong>openBMP</strong></a> é um sistema de monitoramento BGP. Compatível com protocolo de monitoramento BGP (BMP). Os dados BGP são armazenados no banco de dados PostgreSQL. Os RIBs são mantidos pelo estado, bem como o histórico completo para cada atualização do BGP.</p>
<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/08/openbmp-flow.png" alt="" width="640" height="565" class="alignnone size-full wp-image-6727" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/08/openbmp-flow.png 640w, https://blog.remontti.com.br/wp-content/uploads/2022/08/openbmp-flow-300x265.png 300w" sizes="auto, (max-width: 640px) 100vw, 640px" /></p>
<p>&#8211; Dispositivos BMP (por exemplo, roteadores) enviam mensagens BMP para um coletor/daemon OpenBMP. Um daemon OpenBMP pode lidar com muitos roteadores e peers bgp, mas em uma rede grande com links de trânsito e tabelas de roteamento de internet completas, vários coletores OpenBMP são recomendados. Basta configurar no dispositivo BMP (roteador) qual servidor BMP deve ser utilizado.</p>
<p>&#8211; O Kafka permite que muitos aplicativos acessem os feeds BMP existentes de qualquer número de roteadores. Um único feed BMP via OpenBMP pode alimentar centenas de aplicativos de consumo, como MySQL, Cassandra, monitores em tempo real, arquivo simples, ELK, Apache Spark, etc.</p>
<p>&#8211; Administradores, engenheiros de rede, programas/scripts automatizados, etc. interagem com a API OpenBMP ou qualquer outro aplicativo de consumo</p>
<h5>Casos de uso</h5>
<p><em>(Tradução de: <a href="https://www.openbmp.org">https://www.openbmp.org</a>)</em><br />
Existem muitas razões para usar o OpenBMP, mas para destacar algumas comuns:</p>
<p>&#8211; Coletor BMP Centralizado &#8211; OpenBMP é um produtor para Kafka. Você pode escrever seu próprio consumidor ou usar um existente. Outros produtos podem interagir com o OpenBMP via Apache Kafka para fluxos RAW BMP ou as mensagens analisadas. Consulte Especificação da API do Barramento de Mensagens para obter mais detalhes.</p>
<p>&#8211; Monitoramento de topologia em tempo real &#8211; Pode monitorar e alertar sobre alterações de topologia, alterações de política ou falta de aplicação, vazamento de rota, seqüestro, etc.</p>
<p>&#8211; Segurança de BGP/Rota &#8211; Vazamento de rota, seqüestro por origem, por melhores caminhos de trânsito ou desvio da linha de base</p>
<p>&#8211; Espelhos &#8211; IPv4, IPv6 e VPN4</p>
<p>&#8211; Route Analytics &#8211; Rastreie tempos de convergência, histórico de prefixos conforme eles mudam ao longo do tempo, monitore e rastreie mudanças de política BGP, etc…</p>
<p>&#8211; Análise de Engenharia de Tráfego &#8211; Adapte-se dinamicamente às mudanças e saiba qual é a melhor mudança</p>
<p>&#8211; Hipóteses pré-políticas de BGP &#8211; As informações de roteamento pré-políticas fornecem informações sobre todos os atributos de caminho de vários pontos na rede, permitindo visualizações de topologia hipotéticas não intrusivas para novas validações de políticas</p>
<p>&#8211; Topologia IGP &#8211; BGP-LS (link-state) fornece a topologia completa do IGP (OSPF e/ou IS-IS). A topologia IGP fornece informações de nível de nó, link e prefixo. Isso inclui todos os próximos saltos do BGP. Agora é possível fazer uma seleção de melhor caminho BGP com métrica IGP para informações Adj-In-RIB. Também é possível monitorar o próprio IGP no que se refere a links, nós, prefixos e BGP.</p>
<p>Quem desejar se aprofundar mais tem um lindo artigo no <a href="https://wiki.brasilpeeringforum.org/w/Solucoes_para_o_gerenciamento_efetivo_do_bgp_em_um_sistema_autonomo" rel="noopener" target="_blank">Brasil Peering Fórum</a> escrito pelo <a href="https://www.linkedin.com/in/leofurtadonyc/" rel="noopener" target="_blank">Leonardo Furtado</a>. Agradeço ao <a href="https://www.linkedin.com/in/rudsoncosta/" rel="noopener" target="_blank">Rudson Costa</a> por me apresentar a ferramenta e me instigar a escrever este tutorial.</p>
<p><strong>Distribuição utilizada neste tutorial:</strong><br />
Debian 11 (Bullseye) 64 bits <a href="https://blog.remontti.com.br/5792" rel="noopener" target="_blank">instalação mínima</a><br />
<a href="https://blog.remontti.com.br/5867" rel="noopener" target="_blank">Como melhorar a produtividade no seu Debian após instalação</a> (Recomendado)</p>
<p>Atualize e instale os pacotes necessários</p>
<pre class="remontti-code"># apt update -y 
# apt upgrade -y 
# apt install wget git vim nano docker-compose htop tree -y </pre>
<p>Crie o diretório qual iremos baixar o projeto OpenBMP</p>
<pre class="remontti-code"># mkdir /root/obmp-install
# cd /root/obmp-install
# wget https://raw.githubusercontent.com/OpenBMP/obmp-docker/main/docker-compose.yml 
# git clone https://github.com/OpenBMP/obmp-grafana.git</pre>
<p>Crie todos os diretórios e de as devidas permissões <em>(segui a documentação, antes de vir me criticar do 777)</em></p>
<pre class="remontti-code"># export OBMP_DATA_ROOT=/var/openbmp
# mkdir -p $OBMP_DATA_ROOT
# mkdir -p ${OBMP_DATA_ROOT}/config
# chmod -R 777 ${OBMP_DATA_ROOT}/config
# mkdir -p ${OBMP_DATA_ROOT}/zk-data
# mkdir -p ${OBMP_DATA_ROOT}/zk-log
# chown -R 1000:1000 ${OBMP_DATA_ROOT}/zk-*/
# mkdir -p ${OBMP_DATA_ROOT}/postgres/data
# mkdir -p ${OBMP_DATA_ROOT}/postgres/ts
# chown -R 1000:1000 ${OBMP_DATA_ROOT}/postgres/
# mkdir -p ${OBMP_DATA_ROOT}/kafka-data
# chown -R 1000:1000 ${OBMP_DATA_ROOT}/kafka-data/
# chmod 777 ${OBMP_DATA_ROOT}/kafka-data
# mkdir -p ${OBMP_DATA_ROOT}/grafana
# cp -r obmp-grafana/dashboards obmp-grafana/provisioning ${OBMP_DATA_ROOT}/grafana/
# chmod -R 777 ${OBMP_DATA_ROOT}/grafana</pre>
<p>Verifique se tudo foi criado</p>
<pre class="remontti-code"># tree $OBMP_DATA_ROOT</pre>
<p>Ajuste a memória Psql-App leia mais <a href="https://www.openbmp.org/getting_started.html#vm-sizing" rel="noopener" target="_blank">aqui</a> sobre requisitos de hardware</p>
<pre class="remontti-code"># sed -i &#039;s/- MEM=3/- MEM=4/&#039; docker-compose.yml</pre>
<p>Agora iremos subir todos os containes:</p>
<pre class="remontti-code"># OBMP_DATA_ROOT=/var/openbmp docker-compose -f ./docker-compose.yml -p obmp up -d</pre>
<p>Verifique se todos os containes estão Ups</p>
<pre class="remontti-code">docker ps</pre>
<pre class="remontti-code-plain">#CONTAINER ID   IMAGE                             COMMAND                  CREATED          STATUS          PORTS                                        NAMES
#079afaaba23f   confluentinc/cp-kafka:7.1.1       &quot;/etc/confluent/dock…&quot;   24 minutes ago   Up 24 minutes   0.0.0.0:9092-&gt;9092/tcp                       obmp-kafka
#fc2f5a316138   openbmp/whois:2.2.0               &quot;/bin/sh -c &#039;/usr/lo…&quot;   24 minutes ago   Up 24 minutes   0.0.0.0:4300-&gt;43/tcp                         obmp-whois
#47d8776c4fc9   openbmp/psql-app:2.2.1            &quot;/usr/sbin/run&quot;          24 minutes ago   Up 23 minutes   0.0.0.0:9005-&gt;9005/tcp                       obmp-psql-app
#9b97cc146ff7   openbmp/postgres:2.2.0            &quot;/docker-entrypoint.…&quot;   24 minutes ago   Up 24 minutes   8008/tcp, 0.0.0.0:5432-&gt;5432/tcp, 8081/tcp   obmp-psql
#dc694dd40972   openbmp/collector:2.2.0           &quot;/usr/sbin/run&quot;          24 minutes ago   Up 24 minutes   0.0.0.0:5000-&gt;5000/tcp                       obmp-collector
#305a1f316ba8   confluentinc/cp-zookeeper:7.1.1   &quot;/etc/confluent/dock…&quot;   24 minutes ago   Up 24 minutes   2181/tcp, 2888/tcp, 3888/tcp                 obmp-zookeeper
#949272653acb   grafana/grafana:8.5.4             &quot;/run.sh&quot;                24 minutes ago   Up 24 minutes   0.0.0.0:3000-&gt;3000/tcp                       obmp-grafana</pre>
<p>Acesse o grafana na porta 3000 deslogue e logue novamente com usuário <strong>admin</strong> e senha <strong>openbmp</strong> e faça a alteração do mesmo.<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/08/openbmp-grafana.png" alt="" width="1580" height="870" class="alignnone size-full wp-image-6734" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/08/openbmp-grafana.png 1580w, https://blog.remontti.com.br/wp-content/uploads/2022/08/openbmp-grafana-300x165.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/08/openbmp-grafana-1024x564.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/08/openbmp-grafana-768x423.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/08/openbmp-grafana-1536x846.png 1536w" sizes="auto, (max-width: 1580px) 100vw, 1580px" /></p>
<h3>Criando um firewall para proteger</h3>
<p>Podemos consultar com o comando ss várias portas abertas, por segurança vamos fecha-las.</p>
<pre class="remontti-code"># ss -putan | grep LIST</pre>
<pre class="remontti-code-plain">tcp   LISTEN 0      128          0.0.0.0:22          0.0.0.0:*     users:((&quot;sshd&quot;,pid=441,fd=3))                        
tcp   LISTEN 0      4096         0.0.0.0:5432        0.0.0.0:*     users:((&quot;docker-proxy&quot;,pid=5651,fd=4))               
tcp   LISTEN 0      4096         0.0.0.0:3000        0.0.0.0:*     users:((&quot;docker-proxy&quot;,pid=5547,fd=4))               
tcp   LISTEN 0      4096         0.0.0.0:9092        0.0.0.0:*     users:((&quot;docker-proxy&quot;,pid=6188,fd=4))               
tcp   LISTEN 0      4096         0.0.0.0:5000        0.0.0.0:*     users:((&quot;docker-proxy&quot;,pid=5576,fd=4))               
tcp   LISTEN 0      4096       127.0.0.1:42315       0.0.0.0:*     users:((&quot;containerd&quot;,pid=429,fd=13))                 
tcp   LISTEN 0      4096         0.0.0.0:4300        0.0.0.0:*     users:((&quot;docker-proxy&quot;,pid=5756,fd=4))               
tcp   LISTEN 0      4096         0.0.0.0:9005        0.0.0.0:*     users:((&quot;docker-proxy&quot;,pid=6559,fd=4))               
tcp   LISTEN 0      128             [::]:22             [::]:*     users:((&quot;sshd&quot;,pid=441,fd=4))  </pre>
<p>O nftablesjá vem por padrão instalado no Debian 11. </p>
<pre class="remontti-code"># vim /etc/nftables.conf</pre>
<p>Neste exemplo (quase q auto explicativo) vou deixar apenas a porta do Grafana aberta, as demais restritas a variável <strong>ACESSO_EXTERNO</strong>.</p>
<pre class="remontti-code">#!/usr/sbin/nft -f

flush ruleset

define PORTAS_RESTRITAS = { 22,4300,5000,5432,9092,9005 }
define PORTAS_ABERTAS = { 3000 }

define ACESSO_EXTERNO_IPv4 = { 172.16.0.0/12, 10.0.0.0/8, 200.200.200.0/24 }
define ACESSO_EXTERNO_IPv6 = { 2001:db8:1::/64 }

define ACESSO_LOCALHOST_IPv4 = { 127.0.0.0/8 }
define ACESSO_LOCALHOST_IPv6 = { ::1/128 }

table inet filter {
    set src_ipv4 {
        type ipv4_addr
        flags interval
        elements = { $ACESSO_LOCALHOST_IPv4, $ACESSO_EXTERNO_IPv4 }
    }
    set src_ipv6 {
        type ipv6_addr
        flags interval
        elements = { $ACESSO_LOCALHOST_IPv6, $ACESSO_EXTERNO_IPv6 }
    }
    chain input {
        type filter hook input priority 0;
        ip saddr  != @src_ipv4 tcp dport { $PORTAS_RESTRITAS } counter drop
        ip6 saddr != @src_ipv6 tcp dport { $PORTAS_RESTRITAS } counter drop

        tcp dport { $PORTAS_ABERTAS } counter accept
        
    }
    chain forward {
        type filter hook forward priority 0;
    }
    chain output {
        type filter hook output priority 0;
    }
}</pre>
<p>Habilite para o boot e reinicie o nftables </p>
<pre class="remontti-code"># systemctl enable nftables 
# systemctl restart nftables </pre>
<p>Se desejar matar todos os containes rode:</p>
<pre class="remontti-code"># cd /root/obmp-install
OBMP_DATA_ROOT=/var/openbmp docker-compose -p obmp down</pre>
<p>Para apagar tudo:</p>
<pre class="remontti-code"># rm -rf /var/openbmp</pre>
<h4>Integração com Huawei</h4>
<pre class="remontti-code">bmp
 #
 bmp-session __IP_SERVIDOR__ alias meuprovedor
 tcp connect port 5000
 #
 monitor public
  route-mode ipv4-family unicast adj-rib-in pre-policy
 #
 monitor peer __IP_SERVIDOR__
#
bgp xxxx
 ipv4-family unicast
 peer __IP_PEER_MONITORADO__ keep-all-routes
</pre>
<p><strong>Se quiser apoiar o blog e fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a></p>
<p>Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>Abraço!</p>
<p><strong>FONTE:</strong> <a href="https://www.openbmp.org/" rel="noopener" target="_blank">https://www.openbmp.org/</a></p>
<p>O post <a href="https://blog.remontti.com.br/6723">BGP Monitoring Protocol (BMP) aprenda a instalar o OpenBMP</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/6723/feed</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Como se proteger de ataques DDoS com FastNetMon de graça &#8211; Integração FRR vs NE-Huawei &#8211; Bonus Gráficos Grafana</title>
		<link>https://blog.remontti.com.br/6278</link>
					<comments>https://blog.remontti.com.br/6278#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Wed, 16 Feb 2022 20:00:18 +0000</pubDate>
				<category><![CDATA[Huawei]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mikrotik]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[ataques]]></category>
		<category><![CDATA[Bullseye]]></category>
		<category><![CDATA[ccr]]></category>
		<category><![CDATA[ddos]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[debian 11]]></category>
		<category><![CDATA[dos]]></category>
		<category><![CDATA[fastnemon]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[influxdb]]></category>
		<category><![CDATA[mitigação]]></category>
		<category><![CDATA[ne8000]]></category>
		<category><![CDATA[ne8000f1a]]></category>
		<category><![CDATA[Netflow]]></category>
		<category><![CDATA[telegram]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=6278</guid>

					<description><![CDATA[<p>Existe um tutorial mais atualizado acesse: Fortalecendo a Resiliência da Rede: Detecção de Ataques DDoS com FastNetMon, FRRouting, Grafana e Implementação em Debian 12 com Huawei &#038; RouterOS 👆 👆 👆 👆 👆 👆&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/6278">Como se proteger de ataques DDoS com FastNetMon de graça &#8211; Integração FRR vs NE-Huawei &#8211; Bonus Gráficos Grafana</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<h2><font color="red">Existe um tutorial mais atualizado acesse:</font></h2>
<p><a href="https://blog.remontti.com.br/7322">Fortalecendo a Resiliência da Rede: Detecção de Ataques DDoS com FastNetMon, FRRouting, Grafana e Implementação em Debian 12 com Huawei &#038; RouterOS</a><br />
 <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f446.png" alt="👆" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f446.png" alt="👆" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f446.png" alt="👆" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f446.png" alt="👆" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f446.png" alt="👆" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f446.png" alt="👆" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f446.png" alt="👆" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f446.png" alt="👆" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f446.png" alt="👆" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f446.png" alt="👆" class="wp-smiley" style="height: 1em; max-height: 1em;" /> <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f446.png" alt="👆" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<pre class="remontti-code">#
#
#
#
#
#
#
#
</pre>
<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_huawei-1.png" alt="" width="720" height="340" class="alignnone size-full wp-image-6341" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_huawei-1.png 720w, https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_huawei-1-300x142.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_huawei-1-520x245.png 520w" sizes="auto, (max-width: 720px) 100vw, 720px" /></p>
<p>Neste tutorial vamos aprender como identificar os ataques Dos/DDoS e anunciar os prefixo atacados (ou atacantes) <strong>de seu AS</strong> em envia-los para uma blackhole, e repassar os mesmo para sua operadora. (Acordo)</p>
<p>Vamos utilizar o <a href="https://github.com/pavel-odintsov/fastnetmon/" rel="noopener noreferrer" target="_blank"><strong>FastNetMon</strong></a> (<strong>Community Edition</strong>) que é um analisador de carga DoS/DDoS de alto desempenho, construído sobre vários mecanismos de captura de pacotes (NetFlow, IPFIX, sFlow, AF_PACKET, SnabbSwitch, netmap, PF_RING, PCAP). </p>
<p>Farei a instalação no <a href="https://blog.remontti.com.br/5792" rel="noopener" target="_blank"><strong>Debian 11 (Instalação Limpa)</strong></a>. O hardware utilizado por ser bem generoso, 1CPU e 1GB de memoria. </p>
<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_hardware.png" alt="" width="1212" height="383" class="alignnone size-full wp-image-6312" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_hardware.png 1212w, https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_hardware-300x95.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_hardware-1024x324.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_hardware-768x243.png 768w" sizes="auto, (max-width: 1212px) 100vw, 1212px" /><br />
Nesse gráfico podemos ver um servidor analisando 10GB via Netflow e quase nada sendo usado de recursos. Mais ao final irei configurar o Graphith para termos gráficos qual irá abusar mais do hardware, porém para muitos gráficos não são necessários, e sim algo que o proteja.  </p>
<p><strong>Cenário fictício de exemplo:</strong><br />
Seu AS: 260072 <em>(Madruga Telecom)</em><br />
Operadora AS: 71 <em>(BrUxa71 Telecom)</em><br />
10.100.0.1/30 &#8211; Huawei NE<br />
10.100.0.2/30 &#8211; Servidor</p>
<h3>Configurando a interface de Rede</h3>
<p>Antes de iniciar a instalação do seu do seu servidor em meu exemplo estou usando o IP 10.100.0.2/30, porém eu NUNCA faria um NAT no roteador de borda então porque utilizar o IP privado? Simples por que ele não é acessível logo não pode ser atacado, mas por outro lado se ele não tiver internet você não poderá fazer a instalação e ele não poderá te notificar pelo telegram. Solução que eu gosto muito de aplicar em servidores é a seguinte (falo muito de como configurar interface de redes <a href="https://blog.remontti.com.br/5848" rel="noopener" target="_blank">nesse tutorial</a>, recomendo uma leitura). </p>
<p>Vamos supor que seu prefixo seja 72.72.72.0/22 e você vai alocar o ip 72.72.72.255<strong>/32</strong> para ser o IP de &#8220;loopback&#8221;. <em>Dica que esse IP não seja próximo a do prefixo público que utiliza em seus servidores</em>.</p>
<pre class="remontti-code"># vim /etc/network/interfaces</pre>
<pre class="remontti-code-plain">allow-hotplug eno1
iface eno1 inet static
    address 72.72.72.255/32

iface enp0s3 inet static
    address 10.100.0.2/30
    post-up /usr/sbin/ip route add default via 10.100.0.1 src 72.72.72.255</pre>
<p>Perceba que nós estaremos conversando com nosso roteador de borda pelo prefixo privado 10.100.0.0/30 porém todo o pacote de origem do servidor sai pelo o IP público. Caso este ip seja atacado o mesmo poderá cair em blackhole que o nosso servidor ainda terá comunicação com a borda. </p>
<p>Mas para que seu IP publico tenha rota será necessário criar um rota em seu roteador de borda apontando o IP público para o privado.</p>
<pre class="remontti-code">&lt;NE-SEUMADRUGA&gt; system-view
Enter system view, return user view with return command.
[~NE-SEUMADRUGA] ip route-static 72.72.72.255 255.255.255.255 10.100.0.2 description FASTNETMON
[*NE-SEUMADRUGA] commit</pre>
<p>É claro que neste caso ficará sem internet, mas podemos aplicar um firewall para enviar que ele fique respondendo, apenas para deixar ele &#8220;escondidinho&#8221;. E para isso vamos usar o nftables (Que já vem instalado por padrão no Debian 11 substituindo o iptables)<br />
Habilite o mesmo para iniciar com o sistema:</p>
<pre class="remontti-code"># systemctl enable nftables</pre>
<p>Vamos montar nosso firewall de forma que apenas conexoes que forem abertas pelo servidor seja respondidas.</p>
<pre class="remontti-code"># vim /etc/nftables.conf</pre>
<pre class="remontti-code-plain">#!/usr/sbin/nft -f

flush ruleset

table inet filter {

        chain input {
                type filter hook input priority 0;

                # Permite que apenas conexoes que foram aberta pelo servidor seja respondidas
                ip daddr 72.72.72.255 ct state related,established counter accept
                ip daddr 72.72.72.255 counter drop

        }
        chain forward {
                type filter hook forward priority 0;
        }
        chain output {
                type filter hook output priority 0;
        }
}</pre>
<p>Inicie o nftables</p>
<pre class="remontti-code"># systemctl start nftables</pre>
<p>Você pode simplesmente rodar um scanner de porta no seu IP público bem como um ping, o mesmo não deve responde. </p>
<h3>Instalação FastNetMon (Edição da comunidade)</h3>
<p>Para ver o comparativo da versão gratuita <a href="https://fastnetmon.com/compare-community-and-advanced/" rel="noopener" target="_blank">acesse aqui</a>. Já antemão o que não teremos suporte é ao IPv6 e alguns recursos extras.<br />
Conversando com <a href="https://www.linkedin.com/in/podintsov">Pavel Odintsov</a> entendeu que no Brasil os planos da versão paga ficam muito pesada para a grande maioria devido a alto do dólar, então ele criou um cupom com <strong>50%</strong> de desconto para os brasileiros. <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
Segue os lins com o desconto:<br />
<a href="https://fastnetmon.chargebee.com/hosted_pages/plans/fastnetmon-10g?subscription[coupon]=BRAZIL_PROMO" rel="noopener" target="_blank">Licença 10Gb</a><br />
<a href="https://fastnetmon.chargebee.com/hosted_pages/plans/fastnetmon-40g?subscription[coupon]=BRAZIL_PROMO" rel="noopener" target="_blank">Licença 40GB</a><br />
<a href="https://fastnetmon.chargebee.com/hosted_pages/plans/fastnetmon-100g?subscription[coupon]=BRAZIL_PROMO" rel="noopener" target="_blank">Licença 100GB</a></p>
<p>Vamos a instalação <a href="https://fastnetmon.com/install/" rel="noopener" target="_blank">[Doc Oficial]</a></p>
<pre class="remontti-code"># apt install wget tcpdump net-tools zip curl
# cd /tmp/
# wget https://install.fastnetmon.com/installer -Oinstaller
# chmod +x installer
# ./installer -install_community_edition</pre>
<p>É necessário que vc informe seu e-mail durante a instalação. <em>(Para usar a Comunidade FastNetMon você deve fornecer seu e-mail corporativo válido e aceitar receber informações sobre nossa edição comercial e atualizações de segurança)</em></p>
<pre class="remontti-code-plain">18:13:33 Will log all installation process details into file: /tmp/fastnetmon_install_1170.log
18:13:33 Installer build git version is: b21331ee349eaf0bc2abc71a466802cd26ee2347 build time is: 2022-01-17T16:17:51
18:13:33 Install FastNetMon Community edition

We offer significantly improved FastNetMon Advanced edition: 
&lt;blockquote class=&quot;wp-embedded-content&quot; data-secret=&quot;ghCHMDUZME&quot;&gt;&lt;a href=&quot;https://fastnetmon.com/fastnetmon-advanced/&quot;&gt;FastNetMon Advanced&lt;/a&gt;&lt;/blockquote&gt;&lt;iframe class=&quot;wp-embedded-content&quot; sandbox=&quot;allow-scripts&quot; security=&quot;restricted&quot; style=&quot;position: absolute; clip: rect(1px, 1px, 1px, 1px);&quot; title=&quot;&#8220;FastNetMon Advanced&#8221; &#8212; FastNetMon DDoS Detection Tool&quot; src=&quot;https://fastnetmon.com/fastnetmon-advanced/embed/#?secret=9HRlASbAu2#?secret=ghCHMDUZME&quot; data-secret=&quot;ghCHMDUZME&quot; width=&quot;500&quot; height=&quot;282&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;
You could order free one-month trial for Advanced edition here: 
&lt;blockquote class=&quot;wp-embedded-content&quot; data-secret=&quot;zdVTqp3qpj&quot;&gt;&lt;a href=&quot;https://fastnetmon.com/trial/&quot;&gt;Order trial&lt;/a&gt;&lt;/blockquote&gt;&lt;iframe class=&quot;wp-embedded-content&quot; sandbox=&quot;allow-scripts&quot; security=&quot;restricted&quot; style=&quot;position: absolute; clip: rect(1px, 1px, 1px, 1px);&quot; title=&quot;&#8220;Order trial&#8221; &#8212; FastNetMon DDoS Detection Tool&quot; src=&quot;https://fastnetmon.com/trial/embed/#?secret=kKLHfdm2fM#?secret=zdVTqp3qpj&quot; data-secret=&quot;zdVTqp3qpj&quot; width=&quot;500&quot; height=&quot;282&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;

To use FastNetMon Community you must provide your valid corporate email and accept 
to receive information about our commercial edition and security updates.
You can find our privacy policy here https://fastnetmon.com/privacy-policy/

Provide your corporate email here, personal emails are not allowed: seu@email.com.br
18:13:41 Apply sysctl configuration changes
18:13:41 Disable rp_filter for all interfaces
18:13:41 Installing on Debian 11.2 platform
18:13:41 Download binary package
18:15:27 Successfully installed FastNetMon Community edition</pre>
<p>Adicione todos os prefixos do seu AS, são esses os IPs serão feito analise.</p>
<pre class="remontti-code"># vim /etc/networks_list</pre>
<p>Exemplo:</p>
<pre class="remontti-code">72.72.72.0/22</pre>
<p>Ajustando as configurações do /etc/fastnetmon.conf.<br />
Habilitamos o serviço de netflow: `netflow = off` para `netflow = on`</p>
<pre class="remontti-code"># sed -i &#039;s/netflow = off/netflow = on/&#039; /etc/fastnetmon.conf</pre>
<p>Ajustes de tempo</p>
<pre class="remontti-code"># sed -i &#039;s/average_calculation_time = 5/average_calculation_time = 15/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/average_calculation_time_for_subnets = 5/average_calculation_time_for_subnets = 15/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/netflow_sampling_ratio = 1/netflow_sampling_ratio = 1024/&#039; /etc/fastnetmon.conf</pre>
<p>Defina por quanto tempo em segundos um IP ficará em blackhole o padrão é 1900 seg. No comando estou alterando para 10min: </p>
<pre class="remontti-code"># sed -i &#039;s/ban_time = 1900/ban_time = 600/&#039; /etc/fastnetmon.conf</pre>
<p>Ative medidores de velocidade por sub-rede, para listar a velocidade da faixa em bps e pps para ambas as direções. (Parece que removeram na última versão)</p>
<pre class="remontti-code"># sed -i &#039;s/enable_subnet_counters = off/enable_subnet_counters = on/&#039; /etc/fastnetmon.conf</pre>
<p>Altera o top 7 para o top 10 ao usar o comando fastnetmon_client</p>
<pre class="remontti-code"># sed -i &#039;s/max_ips_in_list = 7/max_ips_in_list = 10/&#039; /etc/fastnetmon.conf</pre>
<p>Temos diferentes abordagens para detecção dos ataques: Pacotes por segundos, largura de banda e por fluxo (flows).</p>
<pre class="remontti-code-plain">ban_for_pps = on
ban_for_bandwidth = on
ban_for_flows = off

ban_for_tcp_bandwidth = off
ban_for_udp_bandwidth = off
ban_for_icmp_bandwidth = off

ban_for_tcp_pps = off
ban_for_udp_pps = off
ban_for_icmp_pps = off
</pre>
<p>Vamos ativar todos os filtros:</p>
<pre class="remontti-code"># sed -i &#039;s/ban_for_flows = off/ban_for_flows = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_tcp_bandwidth = off/ban_for_tcp_bandwidth = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_udp_bandwidth = off/ban_for_udp_bandwidth = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_icmp_bandwidth = off/ban_for_icmp_bandwidth = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_tcp_pps = off/ban_for_tcp_pps = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_udp_pps = off/ban_for_udp_pps = on/&#039; /etc/fastnetmon.conf
# sed -i &#039;s/ban_for_icmp_pps = off/ban_for_icmp_pps = on/&#039; /etc/fastnetmon.conf</pre>
<p>Como temos todas as detecções ativas, precisamos ajustar cada situação para sua realidade. Você precisa ter em mente qual é o maior tráfego que pode atingir por um IP da sua rede (seu maior plano) com base nisso tenha em mente que a cada 100MB gera em torno de 10.000 pps por segundo, <strong>isso não é regra</strong> mas pode ser uma base inicial. Vamos imaginar então que meu maior plano seja 900MB, farei uma ajuste no <strong>threshold_pps</strong> para 90.000 pps.</p>
<pre class="remontti-code"># sed -i &#039;s/threshold_pps = 20000/threshold_pps = 90000/&#039; /etc/fastnetmon.conf</pre>
<p>Agora em <strong>threshold_mbps</strong> seria o maior tráfego que você irá permitir, eu normalmente não altero e deixo no padrão 1gb. E em <strong>threshold_flows</strong> o fluxos de limite qual também mantenho o mesmo valor 3500.</p>
<pre class="remontti-code-plain">threshold_mbps = 1050
threshold_flows = 3500</pre>
<p>O netflow ouve a porta padrão 2055 se desejar alterar basta alterar o valor de <strong>netflow_port</strong>. Irei alterar para 52055.</p>
<pre class="remontti-code"># sed -i &#039;s/netflow_port = 2055/netflow_port = 52055/&#039; /etc/fastnetmon.conf</pre>
<p>Por o serviço ira ficar ouvindo em todos os endereços IPs do seu servidor (<strong>netflow_host = 0.0.0.0</strong>), logo o mais correto seria deixa-lo apenas para o IP privado.</p>
<pre class="remontti-code"># sed -i &#039;s/netflow_host = 0.0.0.0/netflow_host = 10.100.0.2/&#039; /etc/fastnetmon.conf</pre>
<p>Ainda em /etc/fastnetmon.conf temos <strong>notify_script_path</strong> que sempre que o fastnetmon identificar um ataque irá executar o script <strong>/usr/local/bin/notify_about_attack.sh</strong>, identificando o IP da sua rede que está sofrendo <strong>(incoming)</strong> o ataque ou que está atacando <strong>(outgoing)</strong> alguém. <strong>Ele NÃO irá identificar os IPs de origem</strong>, pois em um ataque quase sempre as origens são alteradas por milhares de IPs aleatórios.  </p>
<p>Habilite e reinicie o fastnetmon para carregar as novas configurações.</p>
<pre class="remontti-code"># systemctl enable fastnetmon
# systemctl restart fastnetmon</pre>
<p>Verifique se a porta 52055/udp esta ouvindo:</p>
<pre class="remontti-code"># netstat -putan  | grep 52055</pre>
<pre class="remontti-code-plain">udp        0      0 10.100.0.2:52055           0.0.0.0:*                           1599/fastnetmon </pre>
<p>Bom mas antes de criarmos nosso script notify_about_attack.sh, precisamos preparar algumas coisas, e antes de mais nada vamos configurar nosso Huawei para enviar os dados.</p>
<p>Acesse seu roteador Huawei:</p>
<pre class="remontti-code">&lt;NE-SEUMADRUGA&gt; system-view
[~NE-SEUMADRUGA] ip netstream export version ipfix peer-as bgp-nexthop ttl
[*NE-SEUMADRUGA] ip netstream export template sequence-number fixed
[*NE-SEUMADRUGA] ip netstream export index-switch 32
[*NE-SEUMADRUGA] ip netstream as-mode 32
[*NE-SEUMADRUGA] ip netstream timeout active 1
[*NE-SEUMADRUGA] ip netstream timeout inactive 15
[*NE-SEUMADRUGA] ip netstream export template timeout-rate 1
[*NE-SEUMADRUGA] ip netstream export template option sampler
[*NE-SEUMADRUGA] ip netstream export template option application-label
[*NE-SEUMADRUGA] ip netstream sampler fix-packets 1024 inbound
[*NE-SEUMADRUGA] ip netstream sampler fix-packets 1024 outbound
[*NE-SEUMADRUGA] ip netstream export source 10.100.0.1
[*NE-SEUMADRUGA] ip netstream export host 10.100.0.2 52055</pre>
<p>slot 0 NE8000F1A / slot 10 ou 9 NE8000 M8 / slot 3 NE40</p>
<pre class="remontti-code">[*NE-SEUMADRUGA] slot &lt;0-10&gt;
[*NE-SEUMADRUGA] ip netstream sampler to slot self
[*NE-SEUMADRUGA]  ipv6 netstream sampler to slot self</pre>
<p>Será necessário adicionar em todas suas interfaces de Uplink: </p>
<pre class="remontti-code-plain"> ip netstream inbound
 ip netstream outbound</pre>
<p>Exemplo:</p>
<pre class="remontti-code">
interface 40GE0/1/49.71
 vlan-type dot1q 71
 description BruxaDo71Telecom
 ip address 71.71.71.2 255.255.255.252
 statistic enable
 ip netstream inbound
 ip netstream outbound
</pre>
<p>Com o tcpdump vamos monitorar a interface para ver o que esta chegando na porta.</p>
<pre class="remontti-code"># tcpdump -i ens192 -n udp port 52055 -T cnfp -c 10</pre>
<p>Se seu NE estiver mandado os pacotes você terá um resultado como:</p>
<pre class="remontti-code-plain">tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens192, link-type EN10MB (Ethernet), capture size 262144 bytes
14:25:19.601113 IP 10.100.0.1.40000 &gt; 10.100.0.2.52055: NetFlow v9
14:25:19.608068 IP 10.100.0.1.40000 &gt; 10.100.0.2.52055: NetFlow v9
14:25:19.668054 IP 10.100.0.1.40000 &gt; 10.100.0.2.52055: NetFlow v9
14:25:19.691123 IP 10.100.0.1.40000 &gt; 10.100.0.2.52055: NetFlow v9
14:25:19.768055 IP 10.100.0.1.40000 &gt; 10.100.0.2.52055: NetFlow v9
14:25:19.781129 IP 10.100.0.1.40000 &gt; 10.100.0.2.52055: NetFlow v9
14:25:19.831133 IP 10.100.0.1.40000 &gt; 10.100.0.2.52055: NetFlow v9
14:25:19.858054 IP 10.100.0.1.40000 &gt; 10.100.0.2.52055: NetFlow v9
14:25:19.941124 IP 10.100.0.1.40000 &gt; 10.100.0.2.52055: NetFlow v9
14:25:19.958060 IP 10.100.0.1.40000 &gt; 10.100.0.2.52055: NetFlow v9
10 packets captured
10 packets received by filter
0 packets dropped by kernel</pre>
<p>Agora com o comando: </p>
<pre class="remontti-code"># fastnetmon_client</pre>
<p>Iremos visualizar os TOP IPs</p>
<pre class="remontti-code-plain">FastNetMon 1.1.3 master git- Pavel Odintsov: stableit.ru
IPs ordered by: packets
Incoming traffic       724347 pps   6998 mbps    161 flows
72.72.72.238            51973 pps    569 mbps      0 flows  *banned*
72.72.72.112            14390 pps    154 mbps      0 flows
72.72.72.93             14000 pps    150 mbps      0 flows
72.72.72.161            11705 pps    129 mbps      0 flows
72.72.72.118             8797 pps     86 mbps      0 flows
72.72.72.43              7602 pps     84 mbps      0 flows
72.72.72.111             6669 pps     64 mbps      0 flows

Outgoing traffic       291008 pps    705 mbps    101 flows
72.72.72.238            18009 pps     14 mbps      0 flows  *banned*
72.72.72.112             7929 pps      5 mbps      0 flows
72.72.72.93              7110 pps     10 mbps      0 flows
72.72.72.14              4910 pps     40 mbps      0 flows
72.72.72.43              4887 pps      2 mbps      0 flows
72.72.72.161             4537 pps      2 mbps      0 flows
72.72.72.111             3933 pps     14 mbps      0 flows

Internal traffic             0 pps      0 mbps

Other traffic              420 pps      0 mbps

Screen updated in:              0 sec 331 microseconds
Traffic calculated in:          0 sec 854 microseconds
Total amount of IPv6 packets related to our own network: 0
Not processed packets: 0 pps 

Subnet load:
72.72.72.0/22      pps in: 256000   out: 52000    mbps in: 9630  out: 1077
100.100.0.6/32     pps in: 0        out: 0        mbps in: 0     out: 0
</pre>
<p>Perceba que o IP <strong>72.72.72.238</strong> foi banido, pois o mesmo excedeu os pps de 50.000, no entanto este é um dos IPs que então em meu CGNAT, e vai ser natural este ter um comportamento diferente. Para que o <strong>fastnetmon ignore o mesmo</strong> você pode cria uma <strong>lista branca</strong>. Não se preocupe se isso acontecer com você o fastnetmon não ira fazer nenhuma ação, pois não configuramos nada ainda.<br />
Para criar a lista branca <strong>networks_whitelist</strong> com os IPs ou prefixo que deseja ignorar.</p>
<pre class="remontti-code"># &gt; /etc/networks_whitelist
# vim /etc/networks_whitelist</pre>
<p>Exemplo</p>
<pre class="remontti-code-plain">72.72.72.224/28
72.72.73.224/28</pre>
<p>Reinicie para carregar as novas configurações.</p>
<pre class="remontti-code"># systemctl restart fastnetmon</pre>
<h3>Bot Telegram</h3>
<p>Para receber notificações pelo Telegram juntamente com o arquivo de log, vai ser necessário criar um bot do telegram para o uso do mesmo. Se você não sabe como criar um Bot para telegram basta você falar com o <a href="https://telegram.me/BotFather" rel="noopener" target="_blank">@BotFather</a> e enviar para ele <strong>/newbot</strong>, ele irá pedir qual nome você gostaria de dar a seu bot, e em seguida ira gera um token que vamos precisar a seguir. </p>
<p>Para o Telegram vamos usar um scriptzinho que criei.</p>
<pre class="remontti-code"># cd /tmp/
# wget https://github.com/remontti/TelegramCMD/archive/master.zip
# unzip /tmp/master.zip
# chmod a+x /tmp/TelegramCMD-master/telegram
# mv /tmp/TelegramCMD-master/telegram* /usr/local/bin/
# ln -s /usr/local/bin/telegram /bin/telegram</pre>
<p>Edite o token.conf e altere para o seu TOKEN.</p>
<pre class="remontti-code"># vim /usr/local/bin/telegram.conf/token.conf</pre>
<pre class="remontti-code">######################################
# Telegram bot                       #
# Create a new bot with @BotFather   #
# get TOKEN                          #
######################################

TOKEN=&quot;123456789:FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF&quot;</pre>
<p>Esse script você pode usar para diversas coisas, ele será capaz de zipar um diretorio e lhe enviar o arquivo bem como enviar apenas uma mensagem. Como usar? É importante você saber que o IDs de grupos tem um &#8220;-&#8221; no inicio do ID, já usuários não. Para descobrir o ID do seu usuário fale com o bot <a href="https://telegram.me/myidbot" rel="noopener" target="_blank"><strong>@myidbot</strong></a> e envie para ele <strong>/getid</strong>, para saber de um grupo adicione <strong>@myidbot</strong> ao seu grupo e envie <strong>/getgroupid@myidbot</strong>. Realize um teste com um dos comandos: (Não esqueça de alterar pelo seu ID)</p>
<pre class="remontti-code-plain">Uso: telegram [Opções]
  -m: Para enviar uma mensagem
     ex: telegram -m &quot;ID Chat&quot; &quot;Meu assunto&quot; &quot;Minha mensagem...&quot;
     ex: telegram -m &quot;-123456789&quot; &quot;Notificação&quot; &quot;Mensagem para um grupo ID&quot;
     ex: telegram -m &quot;123456789&quot; &quot;Notificação&quot; &quot;Mensagem para direta/privado&quot;

  -f: Para enviar um arquivo
     ex: telegram -f &quot;ID Chat&quot; &quot;/diretorio/arquivo&quot; &quot;nome do arquivo zip&quot; &quot;Comentário&quot;
     ex: telegram -f &quot;12345689&quot; /var/log/syslog syslog &quot;Logs do sistema para user privado&quot;
     ex: telegram -f &quot;-12345689&quot; /var/log/syslog syslog &quot;Logs do sistema para um grupo&quot;</pre>
<h3>FRR</h3>
<p>Vamos realizar a instalação do <a href="http://frrouting.org/" rel="noopener" target="_blank">FRRouting</a> (FRR) para fechar sessão BGP entre o roteador de borda e servidor.</p>
<pre class="remontti-code">
# apt install curl apt-transport-https gnupg2 tree net-tools
# curl -s https://deb.frrouting.org/frr/keys.asc | apt-key add -
# echo deb https://deb.frrouting.org/frr bullseye frr-8 | tee -a /etc/apt/sources.list.d/frr.list
# apt update
# apt install frr frr-doc</pre>
<p>Parâmetros kernel</p>
<pre class="remontti-code"># echo &#039;net.ipv4.ip_forward = 1&#039; &gt;&gt; /etc/sysctl.conf
# echo &quot;net.ipv4.conf.all.rp_filter = 0&quot; &gt;&gt; /etc/sysctl.conf
# echo &quot;net.ipv4.conf.default.rp_filter = 0&quot; &gt;&gt; /etc/sysctl.conf
# echo &quot;net.ipv4.conf.lo.rp_filter = 0&quot; &gt;&gt; /etc/sysctl.conf
# echo &quot;net.ipv4.conf.`ip -br link |awk &#039;{print $1}&#039; |grep -v lo`.rp_filter = 0&quot; &gt;&gt; /etc/sysctl.conf
# sysctl -p</pre>
<p>Ative o modulo BGP</p>
<pre class="remontti-code"># sed -i &#039;s/bgpd=no/bgpd=yes/&#039; /etc/frr/daemons</pre>
<p>Reinicie o FRR</p>
<pre class="remontti-code"># systemctl restart frr</pre>
<p>Entre no shell VTY do FRR.</p>
<pre class="remontti-code"># vtysh</pre>
<p>Rode o comando: `show running-config`</p>
<pre class="remontti-code-plain">deb11# show running-config 
Building configuration...

Current configuration:
!
frr version 8.3.1
frr defaults traditional
hostname deb11
log syslog informational
no ip forwarding
no ipv6 forwarding
service integrated-vtysh-config
!
line vty
!
end</pre>
<p>Agora entre no modo de configuração, e vamos preparar nosso peer com o router de borda. No exemplo está praticamente auto explicativo, vamos fechar o peer e <strong>deixar</strong> ser anunciado <strong>apenas nossos prefixos</strong> e aplicaremos a <strong>community 65001:666</strong></p>
<pre class="remontti-code-plain">configure terminal
!
ip prefix-list FASTNETMON_EXPORT seq 5 permit 72.72.72.0/23 le 32
ip prefix-list FASTNETMON_EXPORT seq 10 permit 72.72.74.0/23 le 32
!
!
route-map MARK_FASTNETMON_IMPORT deny 10
!
route-map MARK_FASTNETMON_EXPORT permit 10
 match ip address prefix-list FASTNETMON_EXPORT
 set community 65001:666
!
router bgp 65001
 bgp router-id 10.100.0.2
 neighbor 10.100.0.1 remote-as 260072
 neighbor 10.100.0.1 description &quot;NE8K_BORDA&quot;
# neighbor 10.100.0.1 ebgp-multihop 255 # (Caso seja multihop)
 !
 address-family ipv4 unicast
  neighbor 10.100.0.1 route-map MARK_FASTNETMON_IMPORT in
  neighbor 10.100.0.1 route-map MARK_FASTNETMON_EXPORT out
 exit-address-family
!
line vty
!
end
write memory
exit</pre>
<p>Vamos ao <strong>Huawei</strong></p>
<pre class="remontti-code">&lt;NE-SEUMADRUGA&gt; system-view
Enter system view, return user view with return command.</pre>
<p>Crie uma rota estática de Blackhole</p>
<pre class="remontti-code">[~NE-SEUMADRUGA] ip route-static 192.0.2.1 255.255.255.255 NULL0 description BLACKHOLE</pre>
<p>Crie um filtro que irá aceitar qualquer rota /32</p>
<pre class="remontti-code">[*NE-SEUMADRUGA] ip ip-prefix  ACCEP_PREFIX_MASK32_FASTNETMON_IPV4 index 10 permit 0.0.0.0 0 greater-equal 32</pre>
<p>Crie os prefixos publico para rejeitar e não cair em blackhole mesmo quando atacado, caso você deixar o fastnetmon anúnciar seu NE pode rejeitar (Ex IP Servidores ou CGNAT)</p>
<pre class="remontti-code">[*NE-SEUMADRUGA] ip ip-prefix  IGNORE_PREFIX_FASTNETMON_IPV4 index 10 permit 72.72.72.224 28 greater-equal 28 less-equal 32
[*NE-SEUMADRUGA] ip ip-prefix  IGNORE_PREFIX_FASTNETMON_IPV4 index 20 permit 72.72.73.224 28 greater-equal 28 less-equal 32</pre>
<p>Crie um filtro para a community 65001:666</p>
<pre class="remontti-code">[*NE-SEUMADRUGA] ip community-filter basic COMM_FASTNETMON_BLACKHOLE index 10 permit 65001:666</pre>
<p>Vamos montar agora nosso route policy de import (rotas que iremos receber). A 1ª é ignorar os prefixos <strong>IGNORE_PREFIX_FASTNETMON_IPV4</strong></p>
<pre class="remontti-code">[*NE-SEUMADRUGA] route-policy FASTNETMON_IMPORT_IPV4 deny node 1000
[*NE-SEUMADRUGA]  if-match ip-prefix IGNORE_PREFIX_FASTNETMON_IPV4</pre>
<p>A 2º é o que vir marcado do fastnetmon com 65001:666 (COMM_FASTNETMON_BLACKHOLE) jogar para blackhole e aplicar uma community nova <strong>65444:666</strong>, como no exemplo aqui meu AS é de 32bits vou usar um AS privado, mas onde seu AS é de 16bits o mais comum de se encontrar é AS:666. Assim se você for trânsito de outro AS você pode montar em suas route policy para aceitar prefixos do AS dele com /32 marcados com AS:666 e jogar para blackhole também fica dica!</p>
<pre class="remontti-code">[*NE-SEUMADRUGA] route-policy FASTNETMON_IMPORT_IPV4 permit node 1010
[*NE-SEUMADRUGA]  if-match community-filter COMM_FASTNETMON_BLACKHOLE 
[*NE-SEUMADRUGA]  apply local-preference 999
[*NE-SEUMADRUGA]  apply ip-address next-hop 192.0.2.1
[*NE-SEUMADRUGA]  apply community 65444:666
[*NE-SEUMADRUGA]  if-match ip-prefix ACCEP_PREFIX_MASK32_FASTNETMON_IPV4</pre>
<p>E a 3ª ignoramos o resto como boas praticas.</p>
<pre class="remontti-code">[*NE-SEUMADRUGA] route-policy FASTNETMON_IMPORT_IPV4 deny node 9999</pre>
<p>Para as route policy de export (Rotas que o NE irá ensinar) colocarei apenas um Deny pois ele não precisa ensinar nada.</p>
<pre class="remontti-code">[*NE-SEUMADRUGA] route-policy FASTNETMON_EXPORT_IPV4 deny node 9999
[*NE-SEUMADRUGA] commit</pre>
<p>Vamos ao peer</p>
<pre class="remontti-code">[*NE-SEUMADRUGA] bgp 260072
[~NE-SEUMADRUGA] undo peer 10.100.0.2
[*NE-SEUMADRUGA]  peer 10.100.0.2 as-number 65001
[*NE-SEUMADRUGA]  peer 10.100.0.2 description BORDA_VS_FASTNETMON_IPV4
[*NE-SEUMADRUGA]  peer 10.100.0.2 timer connect-retry 1
[*NE-SEUMADRUGA]  peer 10.100.0.2 connect-interface 10.100.0.1
[*NE-SEUMADRUGA]  peer 10.100.0.2 timer keepalive 10 hold 30 
[*NE-SEUMADRUGA]  ipv4-family unicast
[*NE-SEUMADRUGA]   peer 10.100.0.2 enable
[*NE-SEUMADRUGA]   peer 10.100.0.2 public-as-only
[*NE-SEUMADRUGA]   peer 10.100.0.2 route-policy FASTNETMON_IMPORT_IPV4 import
[*NE-SEUMADRUGA]   peer 10.100.0.2 route-policy FASTNETMON_EXPORT_IPV4 export
[*NE-SEUMADRUGA]   peer 10.100.0.2 next-hop-local
[*NE-SEUMADRUGA]   peer 10.100.0.2 advertise-community
[*NE-SEUMADRUGA]   peer 10.100.0.2 advertise-ext-community
[*NE-SEUMADRUGA] commit
[~NE-SEUMADRUGA] run save </pre>
<p>Em caso de alguma <strong>emergência</strong>, para <strong>baixar</strong> a sessão use:</p>
<pre class="remontti-code">[~NE-SEUMADRUGA] bgp 260072
[*NE-SEUMADRUGA] peer 10.100.0.2 ignore
[*NE-SEUMADRUGA] commit</pre>
<p>Para <strong>subir</strong> novamente:</p>
<pre class="remontti-code">[~NE-SEUMADRUGA] bgp 260072
[*NE-SEUMADRUGA] undo peer 10.100.0.2 ignore
[*NE-SEUMADRUGA] commit</pre>
<p>Verifique se sua sessão subiu:</p>
<pre class="remontti-code">[*NE-SEUMADRUGA] display bgp peer | include 10.100.0.2</pre>
<pre class="remontti-code-plain"> BGP local router ID : x.x.x.x
 Local AS number : 260072
 Total number of peers : 13                 Peers in established state : 13

  Peer                             V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State  PrefRcv
  10.100.0.2                       4       65001   897801  1088107     0 2496h26m Established        0</pre>
<p>No FRR use `show bgp summary`</p>
<pre class="remontti-code"># vtysh</pre>
<pre class="remontti-code-plain"># show bgp summary
IPv4 Unicast Summary:
BGP router identifier 10.100.0.2, local AS number 65001 vrf-id 0
BGP table version 0
RIB entries 0, using 0 bytes of memory
Peers 1, using 21 KiB of memory

Neighbor        V         AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd   PfxSnt
10.100.0.1      4     260072         5         5        0    0    0 00:02:52            0        0

Total number of neighbors 1
# exit</pre>
<p>Para repassar os prefixos marcados como blackhole para sua operadora você precisará saber qual é a community que a mesma utiliza e se ela lhe oferece esse recurso, em seguida você irá adiciar a route policy da sua operadora uma nova regra:</p>
<p>No exemplo tudo que recebemos do fastnetmon passamos a aplicar a community 65444:666, logo tudo que for marcado com a mesma irei repassar para operadora com a commnunity da operadora. Para isso crie então primeiro a community-filter de Blackhole sua.</p>
<pre class="remontti-code">[~NE-SEUMADRUGA] ip community-filter basic COMM_BLACKHOLE index 10 permit 65444:666</pre>
<p>Agora na route policy da operadora crie algo semelhante ao exemplo, sendo que a community de blackhole que sua operadora passou fosse &#8220;71:666&#8221;:</p>
<pre class="remontti-code">[~NE-SEUMADRUGA] route-policy UPSTREAM_OP_BRUXADO71_EXPORT_IPV4 permit node 2070
[~NE-SEUMADRUGA]  if-match community-filter COMM_BLACKHOLE
[~NE-SEUMADRUGA]  apply community 71:666</pre>
<p>Pronto agora que ja temos nosso peer Up entre router e servidor, nosso Bot mandando mensagem, iremos criar o script que será executado sempre que um ataque for identificado <strong>BAN</strong> ou <strong>UNBAN</strong>. Irei criar um diretório /var/log/fastnetmon_attacks/ataques qual irá ficar os ataques finalizados.</p>
<pre class="remontti-code"># mkdir /var/log/fastnetmon_attacks/ataques -p
# vim /usr/local/bin/notify_about_attack.sh</pre>
<p>Altere <strong>ID_CHAT=&#8217;-1000000000000&#8242;</strong> pelo ID do seu usuário ou grupo.</p>
<pre class="remontti-code">#!/usr/bin/env bash
  
# Este script receberá os seguintes parâmetros:
#  $1 IP do cliente
#  $2 INCOMING -&gt; Vindo de fora da rede | OUTGOING -&gt; Saindo da sua rede
#  $3 Pacotes por seguncoes
#  $4 Ação (ban ou unban)

# Defina o ID do Chat ou Grupo (Grupos sempre começam com &quot;-&quot; )
ID_CHAT=&#039;-1000000000000&#039;

if [ &quot;$2&quot; = &quot;incoming&quot; ]; then
  TIPO=&quot;Sendo atacado&quot;
else 
  TIPO=&quot;Realizando um ataque&quot;
fi

# Desbanindo um IP
if [ &quot;$4&quot; = &quot;unban&quot; ]; then
  /usr/local/bin/telegram -m &quot;$ID_CHAT&quot; &quot;UNBAN IP: &lt;code&gt;$1&lt;/code&gt;&quot; &quot;&lt;code&gt;-&gt;&gt;&lt;/code&gt; Removido da blackhole&quot;
  # Remove IP do anuncio para o FRR
  vtysh --command &quot;configure terminal
  no ip route $1/32 lo
  router bgp 65001
   address-family ipv4 unicast
    no network $1/32
  &quot;
  # Movemos os logs para pasta ataques pois não queremos mais receber elas.
  mv /var/log/fastnetmon_attacks/$1* /var/log/fastnetmon_attacks/ataques
  exit 0
fi

# Banindo um IP
if [ &quot;$4&quot; = &quot;ban&quot; ]; then
  /usr/local/bin/telegram -m &quot;$ID_CHAT&quot; &quot;BAN IP: &lt;code&gt;$1&lt;/code&gt; $TIPO &lt;b&gt;[$3 pps]&lt;/b&gt;&quot; &quot;&lt;code&gt;-&gt;&gt;&lt;/code&gt; Anunciado em blackhole&quot;
  /usr/local/bin/telegram -f &quot;$ID_CHAT&quot; /var/log/fastnetmon_attacks/$1* $1 &quot;Logs do ataque ao IP $1&quot;
  # Anuncia IP ao FRR
  vtysh --command &quot;configure terminal
  ip route $1/32 lo
  router bgp 65001
   address-family ipv4 unicast
    network $1/32
  &quot;
    exit 0
fi

if [ &quot;$4&quot; == &quot;attack_details&quot; ]; then
  #/usr/local/bin/telegram -m &quot;$ID_CHAT&quot; &quot;BAN&quot; &quot;&lt;code&gt;FastNetMon: IP $1 blocked because $2 attack with power $3 pps&lt;/code&gt;&quot;
  exit 0
fi</pre>
<p>De permissão para execução</p>
<pre class="remontti-code"># chmod a+x /usr/local/bin/notify_about_attack.sh</pre>
<p>Restarte o fastnetmon</p>
<pre class="remontti-code"># systemctl restart fastnetmon</pre>
<p>Se quiser fazer um teste manual anunciando um IP (um que não esteja em uso né!!! rsrsrs) exemplo: 72.72.73.255/32<br />
Adicionando:</p>
<pre class="remontti-code"># vtysh --command &quot;configure terminal
  ip route 72.72.73.255/32 lo
  router bgp 65001
   address-family ipv4 unicast
    network 72.72.73.255/32&quot;</pre>
<p>Verificando se esta enviando:</p>
<pre class="remontti-code"># vtysh --command &quot; show ip bgp neighbors 10.100.0.1 advertised-routes&quot;</pre>
<pre class="remontti-code-plain">BGP table version is 3, local router ID is 10.100.0.2, vrf id 0
Default local pref 100, local AS 65001
Status codes:  s suppressed, d damped, h history, * valid, &gt; best, = multipath,
               i internal, r RIB-failure, S Stale, R Removed
Nexthop codes: @NNN nexthop&#039;s vrf id, &lt; announce-nh-self
Origin codes:  i - IGP, e - EGP, ? - incomplete
RPKI validation codes: V valid, I invalid, N Not found

   Network          Next Hop            Metric LocPrf Weight Path
*&gt; 72.72.73.255/32  0.0.0.0                  0         32768 i

Total number of prefixes 1</pre>
<p>Removendo:</p>
<pre class="remontti-code"># vtysh --command &quot;configure terminal
  no ip route 72.72.73.255/32 lo
  router bgp 65001
   address-family ipv4 unicast
    no network 72.72.73.255/32&quot;</pre>
<p>Finalizamos a primeira parte sem fazer nenhum estrago ao servidor (CPU) <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /> </p>
<p>Seria interessante fazer alguns testes de ataques (coisa pequena) mas com características reais de dentro da sua rede e de fora, escolha uma IP que não esteja em uso para tal! Para realizar esse ataque user o a ferramenta criada pelo ekovegeance: <a href="https://github.com/ekovegeance/DDOS" rel="noopener noreferrer" target="_blank">https://github.com/ekovegeance/DDOS</a></p>
<p>Em um servidor/desktop linux vai precisar ter instalado os pacotes bash sudo curl netcat hping3 openssl stunnel nmap whois dnsutils.<br />
<a href="https://github.com/ekovegeance/DDOS/archive/v1.2.4.zip">Baixe os arquivos</a>, extraia entre em sua pasta e execute o arquivo ddos.</p>
<pre class="remontti-code">$ wget https://github.com/ekovegeance/DDOS/archive/v1.2.4.zip
$ unzip v1.2.4.zip 
$ cd DDOS-1.2.4/
$ ./ddos</pre>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2020/01/ddos.png" data-rel="lightbox-gallery-gYw8hNXt" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/01/ddos.png" alt="" width="676" height="881" class="alignnone size-full wp-image-3988" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/01/ddos.png 676w, https://blog.remontti.com.br/wp-content/uploads/2020/01/ddos-230x300.png 230w" sizes="auto, (max-width: 676px) 100vw, 676px" /></a></p>
<h3>Gráficos Grafana</h3>
<p>Habilite o graphite no fastnetmon</p>
<pre class="remontti-code"># sed -i &#039;s/graphite = off/graphite = on/&#039; /etc/fastnetmon.conf</pre>
<p>Vamos instalar o <strong>influxdb</strong> para ser a base de dados</p>
<pre class="remontti-code"># apt install lsb-release gnupg2 curl wget
# wget -q https://repos.influxdata.com/influxdata-archive_compat.key
# echo &#039;393e8779c89ac8d958f81f942f9ad7fb82a25e133faddaf92e15b16e6ac9ce4c influxdata-archive_compat.key&#039; \
  | sha256sum -c &amp;&amp; cat influxdata-archive_compat.key \
  | gpg --dearmor \
  | tee /etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg &gt; /dev/null
# echo &#039;deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive_compat.gpg] https://repos.influxdata.com/debian stable main&#039;\
  | tee /etc/apt/sources.list.d/influxdata.list
# apt update
# apt install influxdb</pre>
<p>Edite o influxdb.conf</p>
<pre class="remontti-code"># vim /etc/influxdb/influxdb.conf</pre>
<p>Localize [[graphite]] e abaixo adicione:</p>
<pre class="remontti-code-plain">[[graphite]]
  enabled = true
  bind-address = &quot;:2003&quot;
  protocol = &quot;tcp&quot;
  consistency-level = &quot;one&quot;
  separator = &quot;.&quot;
  batch-size = 5000 # will flush if this many points get buffered
  batch-timeout = &quot;1s&quot; # will flush at least this often even if we haven&#039;t hit buffer limit
  templates = [
    &quot;fastnetmon.hosts.* app.measurement.cidr.direction.function.resource&quot;,
    &quot;fastnetmon.networks.* app.measurement.cidr.direction.resource&quot;,
    &quot;fastnetmon.total.* app.measurement.direction.resource&quot;
  ]</pre>
<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/influxdb_graphite.png" alt="" width="1038" height="639" class="alignnone size-full wp-image-6314" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/influxdb_graphite.png 1038w, https://blog.remontti.com.br/wp-content/uploads/2022/02/influxdb_graphite-300x185.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/influxdb_graphite-1024x630.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/influxdb_graphite-768x473.png 768w" sizes="auto, (max-width: 1038px) 100vw, 1038px" /></p>
<p>Reinicie o influxdb</p>
<pre class="remontti-code"># systemctl restart influxdb</pre>
<p>Em seguida o fastnetmon</p>
<pre class="remontti-code"># systemctl restart fastnetmon</pre>
<p>Agora vamos acessar o o influxdb para ver se o banco graphite foi criado.</p>
<pre class="remontti-code"># influx</pre>
<pre class="remontti-code-plain">Connected to http://localhost:8086 version 1.8.10
InfluxDB shell version: 1.8.10</pre>
<pre class="remontti-code">&gt; use graphite</pre>
<pre class="remontti-code-plain">Using database graphite</pre>
<pre class="remontti-code">&gt; show measurements</pre>
<pre class="remontti-code-plain">name: measurements
name
----
hosts
networks
total</pre>
<pre class="remontti-code">&gt; exit</pre>
<h4> Grafana</h3>
<p>Adicione o repositório do grafana e instale-o</p>
<pre class="remontti-code"># wget -q -O - https://packages.grafana.com/gpg.key | apt-key add -
# echo &quot;deb https://packages.grafana.com/oss/deb stable main&quot; | tee -a /etc/apt/sources.list.d/grafana.list
# apt update; apt install grafana</pre>
<p>Habilite serviço para inicialização e inicie o mesmo</p>
<pre class="remontti-code"># systemctl enable grafana-server
# systemctl start grafana-server</pre>
<p>Acesse em seu navegador <strong>http://ip_privado:3000</strong> e entre com <strong>usuário e senha admin</strong> em seguida defina uma nova senha.<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_01.png" alt="" width="1384" height="769" class="alignnone size-full wp-image-6318" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_01.png 1384w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_01-300x167.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_01-1024x569.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_01-768x427.png 768w" sizes="auto, (max-width: 1384px) 100vw, 1384px" /></p>
<p>No menu <strong>Configuration</strong> e vá em  <strong>Data sources</strong>, clique em <strong>Add data source</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_02.png" alt="" width="1113" height="564" class="alignnone size-full wp-image-6319" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_02.png 1113w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_02-300x152.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_02-1024x519.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_02-768x389.png 768w" sizes="auto, (max-width: 1113px) 100vw, 1113px" /></p>
<p>Localize influxDB e selecione<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_03.png" alt="" width="1370" height="366" class="alignnone size-full wp-image-6320" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_03.png 1370w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_03-300x80.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_03-1024x274.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_03-768x205.png 768w" sizes="auto, (max-width: 1370px) 100vw, 1370px" /></p>
<p>Preencha apenas:<br />
URL:<strong> http://localhost:8086</strong><br />
Database: <strong>graphite</strong><br />
E clique em <strong>Save &#038; test</strong>, você deve ter a resposta <strong>Data source is working</strong>.</p>
<p>Faça <strong><a href="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon-Dash.zip" rel="noopener" target="_blank">download aqui</a> </strong>das Dashs e importe.<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_04.png" alt="" width="207" height="187" class="alignnone size-full wp-image-6321" /><br />
Não esqueça de definir o banco InfluxDB<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_05.png" alt="" width="859" height="590" class="alignnone size-full wp-image-6323" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_05.png 859w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_05-300x206.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/grafana_fastnetmon_05-768x527.png 768w" sizes="auto, (max-width: 859px) 100vw, 859px" /></p>
<p>Você pode pesquisar por mais dashs em: <a href="https://grafana.com/grafana/dashboards/?search=fastnetmon" rel="noopener" target="_blank">https://grafana.com/grafana/dashboards/?search=fastnetmon</a></p>
<p><strong>Fastnetmon</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon.png" alt="" width="1920" height="1480" class="alignnone size-full wp-image-6329" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon.png 1920w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon-300x231.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon-1024x789.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon-768x592.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon-1536x1184.png 1536w" sizes="auto, (max-width: 1920px) 100vw, 1920px" /><br />
<strong>Fastnetmon PAINEL GERAL</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_PAINEL_GERAL.png" alt="" width="1920" height="984" class="alignnone size-full wp-image-6328" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_PAINEL_GERAL.png 1920w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_PAINEL_GERAL-300x154.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_PAINEL_GERAL-1024x525.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_PAINEL_GERAL-768x394.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_PAINEL_GERAL-1536x787.png 1536w" sizes="auto, (max-width: 1920px) 100vw, 1920px" /></p>
<p><strong>Fastnetmon TOP HOSTS (+100MB)</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_100MB.png" alt="" width="1920" height="1478" class="alignnone size-full wp-image-6331" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_100MB.png 1920w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_100MB-300x231.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_100MB-1024x788.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_100MB-768x591.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_100MB-1536x1182.png 1536w" sizes="auto, (max-width: 1920px) 100vw, 1920px" /></p>
<p><strong>Fastnetmon TOP HOSTS (+300MB)</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_300MB.png" alt="" width="1920" height="984" class="alignnone size-full wp-image-6332" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_300MB.png 1920w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_300MB-300x154.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_300MB-1024x525.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_300MB-768x394.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_HOSTS_300MB-1536x787.png 1536w" sizes="auto, (max-width: 1920px) 100vw, 1920px" /></p>
<p><strong>Fastnetmon TOP NETWORKS</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_NETWORKS.png" alt="" width="1920" height="984" class="alignnone size-full wp-image-6333" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_NETWORKS.png 1920w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_NETWORKS-300x154.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_NETWORKS-1024x525.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_NETWORKS-768x394.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_NETWORKS-1536x787.png 1536w" sizes="auto, (max-width: 1920px) 100vw, 1920px" /></p>
<p><strong>Fastnetmon TOP TRÁFEGO DE SAÍDA</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_TRAFEGO_DE_SAIDA.png" alt="" width="1920" height="984" class="alignnone size-full wp-image-6334" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_TRAFEGO_DE_SAIDA.png 1920w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_TRAFEGO_DE_SAIDA-300x154.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_TRAFEGO_DE_SAIDA-1024x525.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_TRAFEGO_DE_SAIDA-768x394.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TOP_TRAFEGO_DE_SAIDA-1536x787.png 1536w" sizes="auto, (max-width: 1920px) 100vw, 1920px" /></p>
<p><strong>Fastnetmon TRÁFEGO REDE ESPECIFICADA</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_REDE_ESPECIFICADA.png" alt="" width="1920" height="912" class="alignnone size-full wp-image-6335" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_REDE_ESPECIFICADA.png 1920w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_REDE_ESPECIFICADA-300x143.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_REDE_ESPECIFICADA-1024x486.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_REDE_ESPECIFICADA-768x365.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_REDE_ESPECIFICADA-1536x730.png 1536w" sizes="auto, (max-width: 1920px) 100vw, 1920px" /></p>
<p><strong>Fastnetmon TRÁFEGO POR IP ESPECIFICO</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_POR_IP_ESPECIFICO.png" alt="" width="1920" height="912" class="alignnone size-full wp-image-6336" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_POR_IP_ESPECIFICO.png 1920w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_POR_IP_ESPECIFICO-300x143.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_POR_IP_ESPECIFICO-1024x486.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_POR_IP_ESPECIFICO-768x365.png 768w, https://blog.remontti.com.br/wp-content/uploads/2022/02/Fastnetmon_TRAFEGO_POR_IP_ESPECIFICO-1536x730.png 1536w" sizes="auto, (max-width: 1920px) 100vw, 1920px" /></p>
<p>E como ficou o hardware agora?<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_hardware_grafana.png" alt="" width="1340" height="458" class="alignnone size-full wp-image-6338" srcset="https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_hardware_grafana.png 1340w, https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_hardware_grafana-300x103.png 300w, https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_hardware_grafana-1024x350.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2022/02/fastnetmon_hardware_grafana-768x262.png 768w" sizes="auto, (max-width: 1340px) 100vw, 1340px" /></p>
<p>Gostou? Se sentindo mais seguro agora? É consultor e ganha $ com isso!?</p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a></p>
<p>Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>Abraço!</p>
<p>Fontes:<br />
<a href="https://fastnetmon.com/install/" rel="noopener" target="_blank">https://fastnetmon.com/install/</a><br />
<a href="https://docs.frrouting.org/en/latest/bgp.html" rel="noopener" target="_blank">https://docs.frrouting.org/en/latest/bgp.html</a><br />
<a href="https://deb.frrouting.org/" rel="noopener" target="_blank">https://deb.frrouting.org/</a><br />
<a href="https://fastnetmon.com/docs/influxdb_integration/" rel="noopener" target="_blank">https://fastnetmon.com/docs/influxdb_integration/</a><br />
<a href="https://grafana.com/docs/grafana/latest/installation/debian/" rel="noopener" target="_blank">https://grafana.com/docs/grafana/latest/installation/debian/</a></p>
<h4>BÔNUS PEGANDO PREFIXO /24 DO IP ATACADO E ANUNCIANDO COM OUTRA COMMUNITY PARA MITIGAR</h4>
<pre class="remontti-code-plain">
#####################
# SCRIPT FASTNETMON
#####################

#!/usr/bin/env bash
  
# Este script receberá os seguintes parâmetros:
#  $1 IP do cliente
#  $2 INCOMING -&gt; Vindo de fora da rede | OUTGOING -&gt; Saindo da sua rede
#  $3 Pacotes por seguncoes
#  $4 Ação (ban ou unban)

# Pegando prefixo 24
ip32=$1
prefixo24=&quot;${ip32%.*}.0/24&quot;

# Defina o ID do Chat ou Grupo (Grupos sempre começam com &quot;-&quot; )
ID_CHAT=&#039;-1000000000000&#039;
 
if [ &quot;$2&quot; = &quot;incoming&quot; ]; then
  TIPO=&quot;Sendo atacado&quot;
else 
  TIPO=&quot;Realizando um ataque&quot;
fi
 
# Desbanindo um IP
if [ &quot;$4&quot; = &quot;unban&quot; ]; then
  /usr/local/bin/telegram -m &quot;$ID_CHAT&quot; &quot;UNBAN IP: &lt;code&gt;$1&lt;/code&gt;&quot; &quot;&lt;code&gt;-&gt;&gt;&lt;/code&gt; Removido da blackhole&quot;
  # Remove IP do anuncio para o FRR
  vtysh --command &quot;configure terminal
  no ip route $1/32 lo
  no ip route $prefixo24 lo
  router bgp 65001
   address-family ipv4 unicast
    no network $1/32
    no network $prefixo24
  &quot;
  # Movemos os logs para pasta ataques pois não queremos mais receber elas.
  mv /var/log/fastnetmon_attacks/$1* /var/log/fastnetmon_attacks/ataques
  exit 0
fi
 
# Banindo um IP
if [ &quot;$4&quot; = &quot;ban&quot; ]; then
  /usr/local/bin/telegram -m &quot;$ID_CHAT&quot; &quot;BAN IP: &lt;code&gt;$1&lt;/code&gt; $TIPO &lt;b&gt;[$3 pps]&lt;/b&gt;&quot; &quot;&lt;code&gt;-&gt;&gt;&lt;/code&gt; Anunciado em blackhole&quot;
  /usr/local/bin/telegram -f &quot;$ID_CHAT&quot; /var/log/fastnetmon_attacks/$1* $1 &quot;Logs do ataque ao IP $1&quot;
  # Anuncia IP ao FRR
  vtysh --command &quot;configure terminal
  ip route $1/32 lo
  ip route $prefixo24 lo
  router bgp 65001
   address-family ipv4 unicast
    network $1/32
    network $prefixo24
  &quot;
    exit 0
fi
 
if [ &quot;$4&quot; == &quot;attack_details&quot; ]; then
  #/usr/local/bin/telegram -m &quot;$ID_CHAT&quot; &quot;BAN&quot; &quot;&lt;code&gt;FastNetMon: IP $1 blocked because $2 attack with power $3 pps&lt;/code&gt;&quot;
  exit 0
fi


#####################
# FRR
#####################


!
frr version 8.5.1
frr defaults traditional
hostname fnm
log syslog informational
no ipv6 forwarding
service integrated-vtysh-config
!
router bgp 65001
 bgp router-id 172.16.1.2
 neighbor 172.16.1.1 remote-as 12345
 neighbor 172.16.1.1 description &quot;BORDA&quot;
 !
 address-family ipv4 unicast
  neighbor 172.16.1.1 route-map MARK_FASTNETMON_IMPORT in
  neighbor 172.16.1.1 route-map MARK_FASTNETMON_EXPORT out
 exit-address-family
exit
!
ip prefix-list FASTNETMON_EXPORT_32 seq 5 permit 200.0.0.0/22 le 32
!
ip prefix-list FASTNETMON_EXPORT_24 seq 5 permit 200.0.0.0/22 le 24
!
route-map MARK_FASTNETMON_IMPORT deny 10
exit
!
route-map MARK_FASTNETMON_EXPORT permit 10
 match ip address prefix-list FASTNETMON_EXPORT_24
 set community 65001:777
exit
! 
route-map MARK_FASTNETMON_EXPORT permit 20
 match ip address prefix-list FASTNETMON_EXPORT_32
 set community 65001:666
exit
!
end
write memory


#####################
# HUAWEI
#####################


#Configurando filtros e sessão BGP
ip route-static 192.0.2.1 255.255.255.255 NULL0 description BLACKHOLE

# Aceitas os prefixos 32 do AS para blackhole
ip ip-prefix  ACCEP_PREFIX_MASK32_FASTNETMON_IPV4 index 10 permit 200.0.0.0 22 greater-equal 32

# Aceitas os prefixos 24 do AS para mitigar
ip ip-prefix  ACCEP_PREFIX_MASK24_FASTNETMON_IPV4 index 10 permit 200.0.0.0 22 greater-equal 24

#Iginora Prefixos do CGNAT/Servidores
ip ip-prefix  IGNORE_PREFIX_FASTNETMON_IPV4 index 10 permit 200.0.1.0 28 greater-equal 28 less-equal 32
ip ip-prefix  IGNORE_PREFIX_FASTNETMON_IPV4 index 20 permit 200.0.2.0 26 greater-equal 26 less-equal 32

# community que o FRR ira enviar
ip community-filter basic COMM_FASTNETMON_BLACKHOLE_32 index 10 permit 65001:666
ip community-filter basic COMM_FASTNETMON_BLACKHOLE_24 index 10 permit 65001:777

# Define comm para usar nos RP das operadoras
ip community-filter basic COMM_BLACKHOLE_32 index 10 permit 65444:666
ip community-filter basic COMM_BLACKHOLE_24 index 10 permit 65444:777

# RP
route-policy FASTNETMON_IMPORT_IPV4 deny node 1000
 if-match ip-prefix IGNORE_PREFIX_FASTNETMON_IPV4

route-policy FASTNETMON_IMPORT_IPV4 permit node 1010
 if-match community-filter COMM_FASTNETMON_BLACKHOLE_32 
 apply local-preference 999
 apply ip-address next-hop 192.0.2.1
 apply community 65444:666
 if-match ip-prefix ACCEP_PREFIX_MASK32_FASTNETMON_IPV4
 
route-policy FASTNETMON_IMPORT_IPV4 permit node 1020
 if-match community-filter COMM_FASTNETMON_BLACKHOLE_24
 apply local-preference 999
 apply ip-address next-hop 192.0.2.1
 apply community 65444:777
 if-match ip-prefix ACCEP_PREFIX_MASK24_FASTNETMON_IPV4
 
route-policy FASTNETMON_IMPORT_IPV4 deny node 9999
route-policy FASTNETMON_EXPORT_IPV4 deny node 9999

# FILTRO OPERADORA

# Envia para community de blackhole da operadora 
route-policy UPSTREAM_OP_BRUXADO71_EXPORT_IPV4 permit node 2070
 if-match community-filter COMM_BLACKHOLE_32
 apply community 71:666

# Envia para community de blackhole de mitigraçação
route-policy UPSTREAM_OP_BRUXADO71_EXPORT_IPV4 permit node 2070
 if-match community-filter COMM_BLACKHOLE_24
 apply community 71:999
</pre>
<p>O post <a href="https://blog.remontti.com.br/6278">Como se proteger de ataques DDoS com FastNetMon de graça &#8211; Integração FRR vs NE-Huawei &#8211; Bonus Gráficos Grafana</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/6278/feed</wfw:commentRss>
			<slash:comments>13</slash:comments>
		
		
			</item>
		<item>
		<title>Monitorando no Zabbix as sessões BGP do RouterOS/Mikrotik (Script Python)</title>
		<link>https://blog.remontti.com.br/6075</link>
					<comments>https://blog.remontti.com.br/6075#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Wed, 17 Nov 2021 00:03:50 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mikrotik]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[bgp]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[monitoramenteo]]></category>
		<category><![CDATA[peer]]></category>
		<category><![CDATA[routeros]]></category>
		<category><![CDATA[zabbix]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=6075</guid>

					<description><![CDATA[<p>Neste tutorial vamos aprender a monitorar o status da sessão BGP no RouterOS/Mikrotik, bem como receber notificações se a sessão cair ou reconectar. PARA PARA PARA&#8230;. Quando escrevi este tutorial não existia esse tutorial&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/6075">Monitorando no Zabbix as sessões BGP do RouterOS/Mikrotik (Script Python)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/11/mikrotik_bgp_zabbix.png" alt="" width="750" height="375" class="alignnone size-full wp-image-6091" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/11/mikrotik_bgp_zabbix.png 750w, https://blog.remontti.com.br/wp-content/uploads/2021/11/mikrotik_bgp_zabbix-300x150.png 300w" sizes="auto, (max-width: 750px) 100vw, 750px" /></p>
<p>Neste tutorial vamos aprender a monitorar o status da sessão BGP no RouterOS/Mikrotik, bem como receber notificações se a sessão cair ou reconectar.</p>
<p><font color="red">PARA PARA PARA&#8230;.</font> Quando escrevi este tutorial não existia esse <a href="https://blog.remontti.com.br/6175" rel="noopener" target="_blank">tutorial aqui</a>, recomendo você lêr ele, pois descobrimos outra forma mais simples.</p>
<p>Como a mikrotik não disponibiliza essas informações via SNMP (até o momento, esperaça de pobre é a ultima que morre) teremos que usar das artimanhas, então nosso amigo <a target="_blank" href="https://github.com/gtkpad" rel="noopener">Gabriel Vargas Padilha</a> fez um script em python <a target="_blank" href="https://github.com/gtkpad/mikrotikBgpZabbixScript" rel="noopener">mikrotikBgpZabbixScript</b></a> para buscar as informações, eu montei a parte do <a target="_blank" href="https://github.com/remontti/Zabbix-Templates/edit/main/Mikrotik/BGP_ROUTEROS/" rel="noopener">Zabbix</b></a>. </p>
<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/11/dados.png" alt="" width="1305" height="272" class="alignnone size-full wp-image-6077" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/11/dados.png 1305w, https://blog.remontti.com.br/wp-content/uploads/2021/11/dados-300x63.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/11/dados-1024x213.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/11/dados-768x160.png 768w" sizes="auto, (max-width: 1305px) 100vw, 1305px" /></p>
<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/11/graficos_bgp.png" alt="" width="1666" height="724" class="alignnone size-full wp-image-6078" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/11/graficos_bgp.png 1666w, https://blog.remontti.com.br/wp-content/uploads/2021/11/graficos_bgp-300x130.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/11/graficos_bgp-1024x445.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/11/graficos_bgp-768x334.png 768w, https://blog.remontti.com.br/wp-content/uploads/2021/11/graficos_bgp-1536x668.png 1536w" sizes="auto, (max-width: 1666px) 100vw, 1666px" /></p>
<p>Se aida não tem o Zabbix instalado siga: <a target="_blank" href="https://blog.remontti.com.br/5517" rel="noopener">Instalação do Zabbix 5 LTS + Grafana + NGINX + PostgreSQL + Telegram</a></p>
<h1>Configuração</h2>
<p><strong>Requisitos: </strong><br />
&#8211; RouterOS 6.48 ou maior<br />
&#8211; Zabbix Server 5.x<br />
&#8211; Distribuição: Debian 10/11</p>
<h4>Configuração no RouterOS/Mikrotik</h4>
<p>Será necessário criar um usuário com permissões somente de leitura bem como restringindo o acesso para somente o IP do Zabbix, para fazer a conexão para coletas de dados.</p>
<pre class="remontti-code">/user add group=read address=IP_ZABBIX name=SEU_USUARIO password=SUA_SENHA</pre>
<p>Se desejar desativar as infomação de login. Isso fará com que você não veja mais nenhum login feito no router.</p>
<pre class="remontti-code">/system logging set 0 topics=info,!account</pre>
<p>OBS: Não use espaço e caracter especial nos nomes dos Peer&#8217;s e tenha nomes diferentes para cada Peer.</p>
<h4>Zabbix Serve/Linux</h4>
<p>Pacotes necessários:</p>
<pre class="remontti-code-plain"># apt install python3-pip
# pip3 install librouteros</pre>
<p>Acesse o diretório externalscripts e faça download.</p>
<pre class="remontti-code"># cd /usr/lib/zabbix/externalscripts/</pre>
<p>Faça download dos scripts </p>
<pre class="remontti-code"># apt install wget 
# wget https://raw.githubusercontent.com/gtkpad/mikrotikBgpZabbixScript/main/main.py -O mikrotikBgp.py
# wget https://raw.githubusercontent.com/gtkpad/mikrotikBgpZabbixScript/main/Mikrotik.py</pre>
<p>De permissão para os arquivos para execução e altere o dono para o usuário zabbix.</p>
<pre class="remontti-code"># touch mikrotikBgp.log 
# chmod +x mikrotikBgp.py 
# chown zabbix. mikrotikBgp.py Mikrotik.py mikrotikBgp.log 
# systemctl  restart zabbix-server</pre>
<p>Informações de uso do script:</p>
<pre class="remontti-code"># ./mikrotikBgp.py &lt;IP&gt; &lt;USER&gt; &lt;PASS&gt; &lt;API_PORT&gt; &lt;METHOD&gt;
# ./mikrotikBgp.py &lt;IP&gt; &lt;USER&gt; &lt;PASS&gt; &lt;API_PORT&gt; &lt;METHOD&gt; &lt;PEER_NAME&gt;
# ./mikrotikBgp.py &lt;IP&gt; &lt;USER&gt; &lt;PASS&gt; &lt;API_PORT&gt; &lt;METHOD&gt; &lt;PEER_NAME&gt; &lt;PEER_INFO&gt;</pre>
<p><strong>METHOD&#8217;s</strong><br />
<strong>getPeer</strong> &#8211; Retorna todos os peerings em formato json.<br />
<strong>getPeerInfo</strong> &#8211; Retorna o valor especifico de um peer.</p>
<p>Exemplos de uso:</p>
<pre class="remontti-code"># cd /usr/lib/zabbix/externalscripts
# ./mikrotikBgp.py 10.20.30.40 usuario senha 8728 getPeers</pre>
<pre class="remontti-code-plain">{
   &quot;data&quot;:[
      {
         &quot;{#PEER_NAME}&quot;:&quot;VS_BORDA_IPV4&quot;,
         &quot;{#PEER_AS}&quot;:12345,
         &quot;{#PEER_ADDR}&quot;:&quot;10.20.30.5&quot;
      },
      {
         &quot;{#PEER_NAME}&quot;:&quot;VS_BORDA_IPV6&quot;,
         &quot;{#PEER_AS}&quot;:12345,
         &quot;{#PEER_ADDR}&quot;:&quot;fd00:bacb:20:30::1&quot;
      },
      {
         &quot;{#PEER_NAME}&quot;:&quot;NAT_PPPOES_IPV4&quot;,
         &quot;{#PEER_AS}&quot;:65530,
         &quot;{#PEER_ADDR}&quot;:&quot;10.20.30.14&quot;
      }
   ]
}</pre>
<pre class="remontti-code">
# ./mikrotikBgp.py 10.20.30.40 usuario senha 8728 getPeerInfo VS_BORDA_IPV4
# ./mikrotikBgp.py 10.20.30.40 usuario senha 8728 getPeerInfo VS_BORDA_IPV4 name
# ./mikrotikBgp.py 10.20.30.40 usuario senha 8728 getPeerInfo VS_BORDA_IPV4 instance
# ./mikrotikBgp.py 10.20.30.40 usuario senha 8728 getPeerInfo VS_BORDA_IPV4 remote-address
# ./mikrotikBgp.py 10.20.30.40 usuario senha 8728 getPeerInfo VS_BORDA_IPV4 remote-as
# ./mikrotikBgp.py 10.20.30.40 usuario senha 8728 getPeerInfo VS_BORDA_IPV4 uptime
# ./mikrotikBgp.py 10.20.30.40 usuario senha 8728 getPeerInfo VS_BORDA_IPV4 established
# ./mikrotikBgp.py 10.20.30.40 usuario senha 8728 getPeerInfo VS_BORDA_IPV4 prefix-count
# ./mikrotikBgp.py 10.20.30.40 usuario senha 8728 getPeerInfo VS_BORDA_IPV4 advertisements</pre>
<p>Agora acesse seu Zabbix, e importe o Template:<br />
Faça download do template <a href="https://raw.githubusercontent.com/remontti/Zabbix-Templates/main/Mikrotik/BGP_ROUTEROS/RR%20Mikrotik%20-%20BGP%20-%20Script%20Python.xml" rel="noopener" target="_blank"><strong>RR Mikrotik &#8211; BGP &#8211; Script Python.xml</strong></a> e importe.</p>
<p>Crie um novo host, ou inclua o agent.<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/11/zb1.png" alt="" width="1283" height="673" class="alignnone size-full wp-image-6081" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/11/zb1.png 1283w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb1-300x157.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb1-1024x537.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb1-768x403.png 768w" sizes="auto, (max-width: 1283px) 100vw, 1283px" /></p>
<p>Selecione o Template RR Mikrotik &#8211; BGP &#8211; Script. Você encontra <a href="https://github.com/remontti/Zabbix-Templates/tree/main/Mikrotik" rel="noopener" target="_blank">outros templates aqui</a> também.<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/11/zb2.png" alt="" width="1016" height="237" class="alignnone size-full wp-image-6082" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/11/zb2.png 1016w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb2-300x70.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb2-768x179.png 768w" sizes="auto, (max-width: 1016px) 100vw, 1016px" /></p>
<p>Por fim, herde os macros do template, e clique em modificar para informar os seus dados em seguida clique em salvar<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/11/zb3.png" alt="" width="1200" height="596" class="alignnone size-full wp-image-6083" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/11/zb3.png 1200w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb3-300x149.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb3-1024x509.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb3-768x381.png 768w" sizes="auto, (max-width: 1200px) 100vw, 1200px" /></p>
<p>OBS: A descoberta esta ajustada para 6h, se desejar que seja mais rápido execute manualmente, para realizar esse procedimento faça:<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/11/zb4.png" alt="" width="1618" height="484" class="alignnone size-full wp-image-6085" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/11/zb4.png 1618w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb4-300x90.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb4-1024x306.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb4-768x230.png 768w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb4-1536x459.png 1536w" sizes="auto, (max-width: 1618px) 100vw, 1618px" /></p>
<h4>Grafana Modelo</h4>
<p>Apenas uma idéia para você montar uma dash bacaninha:<br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/11/zb5.png" alt="" width="1779" height="288" class="alignnone size-full wp-image-6086" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/11/zb5.png 1779w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb5-300x49.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb5-1024x166.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb5-768x124.png 768w, https://blog.remontti.com.br/wp-content/uploads/2021/11/zb5-1536x249.png 1536w" sizes="auto, (max-width: 1779px) 100vw, 1779px" /></p>
<p>Vou deixar aqui <a href="https://raw.githubusercontent.com/remontti/Zabbix-Templates/main/Mikrotik/BGP_ROUTEROS/Grafana_Modelo.json">dash Modelo</a><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/11/grafana.png" alt="" width="1090" height="218" class="alignnone size-full wp-image-6087" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/11/grafana.png 1090w, https://blog.remontti.com.br/wp-content/uploads/2021/11/grafana-300x60.png 300w, https://blog.remontti.com.br/wp-content/uploads/2021/11/grafana-1024x205.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/11/grafana-768x154.png 768w" sizes="auto, (max-width: 1090px) 100vw, 1090px" /></p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a><br />
Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>O post <a href="https://blog.remontti.com.br/6075">Monitorando no Zabbix as sessões BGP do RouterOS/Mikrotik (Script Python)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/6075/feed</wfw:commentRss>
			<slash:comments>15</slash:comments>
		
		
			</item>
		<item>
		<title>Atualizando Zabbix 4.x no Debian 9/10 para Zabbix 5.x</title>
		<link>https://blog.remontti.com.br/5025</link>
					<comments>https://blog.remontti.com.br/5025#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Thu, 20 Aug 2020 00:57:35 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[pluguins]]></category>
		<category><![CDATA[update]]></category>
		<category><![CDATA[upgrade]]></category>
		<category><![CDATA[zabbix]]></category>
		<category><![CDATA[zabbix4]]></category>
		<category><![CDATA[zabbix5]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=5025</guid>

					<description><![CDATA[<p>Primeira informação que você deve saber é que no Debian 9 a versão do PHP no repositório é a versão 7.0, e para rodar o Zabbix 5 é necessário a versão >7.1 Logue em&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/5025">Atualizando Zabbix 4.x no Debian 9/10 para Zabbix 5.x</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/09/capa_zabbix_upgrade.png" alt="" width="720" height="340" class="alignnone size-full wp-image-5028" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/09/capa_zabbix_upgrade.png 720w, https://blog.remontti.com.br/wp-content/uploads/2020/09/capa_zabbix_upgrade-300x142.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/09/capa_zabbix_upgrade-520x245.png 520w" sizes="auto, (max-width: 720px) 100vw, 720px" /><br />
Primeira informação que você deve saber é que no Debian 9 a versão do PHP no repositório é  a versão <strong>7.0</strong>, e para rodar o Zabbix 5 é necessário a versão <strong>>7.1</strong></p>
<p>Logue em seu servidor e de cara já vire root com <strong>su &#8211;</strong> e atualize tudo nele!</p>
<pre class="remontti-code"># su - 
# apt update; apt upgrade -y
# apt install wget</pre>
<p>Faça backup de seus hosts, templates, mapas, etc&#8230; Nunca se sabe o que pode acontecer!<br />
Backup rápido com o projeto do <a href="https://github.com/maxhq/zabbix-backup" rel="noopener noreferrer" target="_blank">maxhq</a></p>
<pre class="remontti-code"># cd /root
# wget https://raw.githubusercontent.com/maxhq/zabbix-backup/master/zabbix-dump
# chmod +x /root/zabbix-dump
# /root/zabbix-dump</pre>
<p>Se estiver atualizando o zabbix em um servidor com Debian 9 (<em>para o Debian 10 pule esta parte lá para: atualizando repositório do zabbix</em>) é necessário incluir um repositório extra para instalarmos a versão mais nova do PHP.</p>
<h4>Atualizando o PHP no Debian 9</h4>
<pre class="remontti-code"># apt install lsb-release apt-transport-https ca-certificates
# wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
# echo &quot;deb https://packages.sury.org/php/ $(lsb_release -sc) main&quot; &gt; /etc/apt/sources.list.d/php7.list</pre>
<p>Recarregue o repositório e atualize os pacotes.</p>
<pre class="remontti-code"># apt update; apt upgrade -y</pre>
<p>Desativamos o mod do php7.0 no apache.</p>
<pre class="remontti-code"># a2dismod php7.0</pre>
<p>Instalaremos o php7.4</p>
<pre class="remontti-code"># apt install php7.4 libapache2-mod-php7.4 apache2 php7.4 libapache2-mod-php7.4 php7.4-cli php7.4-mysql php7.4-mbstring php7.4-gd php7.4-xml php7.4-bcmath php7.4-ldap</pre>
<p>Reinicie o apache </p>
<pre class="remontti-code"># systemctl restart apache2</pre>
<h4>Atualizando repositório do Zabbix</h4>
<p><strong>Para Debian 9:</strong></p>
<pre class="remontti-code"># cd /tmp
# wget https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-1+stretch_all.deb
# dpkg -i zabbix-release_5.0-1+stretch_all.deb</pre>
<p><strong>Para Debian 10:</strong></p>
<pre class="remontti-code"># cd /tmp
# wget https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-1+buster_all.deb
# dpkg -i zabbix-release_5.0-1+buster_all.deb</pre>
<p>Faça um backup dos arquivos de configurações da versão atual:</p>
<pre class="remontti-code"># cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.antigo
# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.antigo</pre>
<p>Atualize o zabbix:</p>
<pre class="remontti-code"># apt update; apt upgrade -y</pre>
<p>Uma mensagem solicitando se você deseja substituir o arquivo zabbix_server.conf para o mais novo. Vamos responder que <strong>SIM (Y)</strong>, pois em muitas vezes temos algumas &#8220;variáveis&#8221; de configurações que não terá na versão anterior, como já criamos um backup do arquivo atual, vamos optar que ele instale o novo, isso fará ele perder a conexão com o banco de dados, mas a frente nos ajustamos isso:</p>
<pre class="remontti-code">Ficheiro de configuração &#039;/etc/zabbix/zabbix_server.conf&#039;
 ==&gt; Modificado (por si ou por um script) desde a instalação.
 ==&gt; O distribuidor do pacote lançou uma versão atualizada.
   O que deseja fazer? As suas opções são:
    Y ou I  : instalar a versão do pacote do maintainer
    N ou O  : manter a versão actualmente instalada
      D     : mostrar diferenças entre as versões
      Z     : iniciar uma shell para examinar a situação
 A ação padrão é manter sua versão atual.
*** zabbix_server.conf (Y/I/N/O/D/Z) [padrão=N] ? Y</pre>
<p><strong>Atenção, no Debian 9</strong> será necessário remover o pacote zabbix-frontend-php e instalar o zabbix-frontend-php-deprecated, se for Debian 10 apenas pule esta parte.</p>
<pre class="remontti-code"># apt remove zabbix-frontend-php
# apt install zabbix-frontend-php-deprecated</pre>
<p>Vamos comparar o novo arquivo com o velho, a variável <strong>DBPassword</strong> não está mais informando a senha do banco de dado, e é possivel que você tenha feito mais ajutes, os comandos a baixo irão criar um arquivo em /tmp para comparamos os dois arquivos.</p>
<pre class="remontti-code"># cat /etc/zabbix/zabbix_server.conf |grep -v &quot;#&quot; |awk &#039;NF&gt;0&#039; &gt;&gt; /tmp/zs1
# cat /etc/zabbix/zabbix_server.conf.antigo |grep -v &quot;#&quot; |awk &#039;NF&gt;0&#039;  &gt;&gt; /tmp/zs2
# diff /tmp/zs1 /tmp/zs2</pre>
<p>Retornará algo como: </p>
<pre class="remontti-code">6a7
&gt; DBPassword=SSSEEENNNHHHAAA</pre>
<p>Edite então /etc/zabbix/zabbix_server.conf e informe principalmente o DBPassword=</p>
<p>Caso tenha outras configurações diferente ajuste, você também pode dar um &#8220;cat&#8221; e comprar os dois arquivos&#8230;</p>
<pre class="remontti-code"># cat /etc/zabbix/zabbix_server.conf |grep -v &quot;#&quot; |awk &#039;NF&gt;0&#039;</pre>
<pre class="remontti-code">LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
FpingLocation=/usr/bin/fping
Fping6Location=/usr/bin/fping6
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1</pre>
<pre class="remontti-code"># cat /etc/zabbix/zabbix_server.conf.antigo |grep -v &quot;#&quot; |awk &#039;NF&gt;0&#039;</pre>
<pre class="remontti-code">LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=SSSEEENNNHHHAAA
StartPollers=50
StartIPMIPollers=10
StartPollersUnreachable=3
StartTrappers=20
StartPingers=100
StartDiscoverers=50
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
CacheSize=512M
StartDBSyncers=8
HistoryCacheSize=512M
Timeout=4
AlertScriptsPath=/opt/telegram
ExternalScripts=/usr/lib/zabbix/externalscripts
FpingLocation=/usr/bin/fping
Fping6Location=/usr/bin/fping6
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1</pre>
<p>Tudo ajustado reinicie os serviços do zabbix:</p>
<pre class="remontti-code"># systemctl restart zabbix-server zabbix-agent</pre>
<p>Acompanhe a atualização do banco de dados.</p>
<pre class="remontti-code"># tail -f /var/log/zabbix/zabbix_server.log | grep database</pre>
<p>Aguarde chegar&#8230; &#8220;completed 100%&#8221;</p>
<pre class="remontti-code">22319:20200902:170716.115 completed 91% of database upgrade
22319:20200902:170716.510 completed 92% of database upgrade
22319:20200902:170716.695 completed 93% of database upgrade
22319:20200902:170716.811 completed 94% of database upgrade
22319:20200902:170717.160 completed 95% of database upgrade
22319:20200902:170717.221 completed 96% of database upgrade
22319:20200902:170717.276 completed 97% of database upgrade
22319:20200902:170717.353 completed 98% of database upgrade
22319:20200902:170717.356 completed 99% of database upgrade
22319:20200902:170717.359 completed 100% of database upgrade
22319:20200902:170717.359 database upgrade fully completed
22319:20200902:170717.371 database is not upgraded to use double precision values</pre>
<p>Ao concluir já pode acessar em seu navegador o zabbix. Pode ser que ele abra todo &#8220;bugado&#8221;, caso isso acontecer limpe os caches do navegador.</p>
<p>Se você fez alguma alteração no zabbix_agentd.conf, ou não lembra faça o mesmo que o procedimento anterio:</p>
<pre class="remontti-code"># cat /etc/zabbix/zabbix_agentd.conf |grep -v &quot;#&quot; |awk &#039;NF&gt;0&#039; &gt;&gt; /tmp/za1
# cat /etc/zabbix/zabbix_agentd.conf.antigo |grep -v &quot;#&quot; |awk &#039;NF&gt;0&#039;  &gt;&gt; /tmp/za2
# diff /tmp/za1 /tmp/za2</pre>
<p> Remova os pacotes que já não são mais necessários:</p>
<pre class="remontti-code"># apt autoremove</pre>
<p>Se você usou um tutorial antigo aqui do blog onde criamos o script no terminal para envio de mensagem, pode se deparar com o seguinte erro:</p>
<pre class="remontti-code">Cannot execute command &quot;/usr/lib/zabbix/alertscripts/telegram-cmd&quot;: [2] No such file or directory</pre>
<p>Migre para a nova Mídia do Telegram, (remova o renomeie a antiga) <strong><a href="https://blog.remontti.com.br/wp-content/uploads/2020/09/telegram_midia.zip" rel="noopener noreferrer" target="_blank">baixe a nova aqui e importe</a></strong>, e ajustes no seu usuário o tipo de mídia nova e em ações. </p>
<h4>Atualizando plugins do Grafana</h4>
<p>Nas versões mais novas do grafana os plugins não assinados precisam ser autorizados no grafana.ini, e o plugin zabbix não é, para isso faça:</p>
<pre class="remontti-code"># vim /etc/grafana/grafana.ini</pre>
<p>Localize &#8220;<strong>;allow_loading_unsigned_plugins = </strong>&#8221; descemente e adicione<strong> alexanderzobnin-zabbix-datasource</strong>, se allow_loading_unsigned_plugins não existir basta adiciona-la.</p>
<pre class="remontti-code">[plugins]
allow_loading_unsigned_plugins = alexanderzobnin-zabbix-datasource</pre>
<p>Atualize todos os Plugins</p>
<pre class="remontti-code"># grafana-cli plugins update-all</pre>
<p>Reinicie o serviço do grafana</p>
<pre class="remontti-code"># systemctl restart grafana-server</pre>
<p>Ula la! Servidor atualizado! Curtiu? Quer me ajudar manter o blog? <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a></p>
<p>Participe do canal no <a href="https://t.me/blogremontti" rel="noopener noreferrer" target="_blank">telegram</a> para ficar atualizado sempre que publicar um novo tutorial. </p>
<p>Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>Abraço!</p>
<p>O post <a href="https://blog.remontti.com.br/5025">Atualizando Zabbix 4.x no Debian 9/10 para Zabbix 5.x</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/5025/feed</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Instalação do Zabbix 5.0 LTS + notificações pelo Telegram nativo + Grafana 7/8 + Debian 10/11</title>
		<link>https://blog.remontti.com.br/4348</link>
					<comments>https://blog.remontti.com.br/4348#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Fri, 22 May 2020 03:21:04 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[bot]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[debian10 buste]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[grafana7]]></category>
		<category><![CDATA[telegram]]></category>
		<category><![CDATA[webhook]]></category>
		<category><![CDATA[zabbix]]></category>
		<category><![CDATA[zabbix5]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=4348</guid>

					<description><![CDATA[<p>Aqui está o nosso kit de primeiros socorros! 😀 O Zabbix é uma solução de nível enterprise, de código aberto. O Zabbix é um software que monitora vários parâmetros da rede, dos servidores e&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/4348">Instalação do Zabbix 5.0 LTS + notificações pelo Telegram nativo + Grafana 7/8 + Debian 10/11</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Aqui está o nosso kit de primeiros socorros! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f600.png" alt="😀" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/zabbix-grafana-telegram.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/zabbix-grafana-telegram.png" alt="" width="719" height="341" class="aligncenter size-full wp-image-4402" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/zabbix-grafana-telegram.png 719w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zabbix-grafana-telegram-300x142.png 300w" sizes="auto, (max-width: 719px) 100vw, 719px" /></a><br />
O <strong>Zabbix</strong> é uma solução de nível enterprise, de código aberto. O Zabbix é um software que monitora vários parâmetros da rede, dos servidores e da saúde dos serviços. Utiliza-se de um mecanismo flexível de notificação que permite configurar alertas por e-mail entre outros como Telegram, para praticamente qualquer evento. As notificações permitem que se reaja rapidamente à problemas no ambiente. O Zabbix oferece excelentes recursos de relatórios e visualização de dados armazenados. Isso faz com que o Zabbix seja a ferramenta ideal para planejamento de capacidade.</p>
<p>O <strong>Grafana</strong> é um software livre que permite a visualização de formato de dados métricos. Ele permite criar painéis e gráficos a partir de várias fontes, mas aqui iremos vamos aprender a integra-lo com o Zabbix.</p>
<h4>Este tutorial está também disponível no youtube:</h4>
<div class="video-container"><iframe loading="lazy" title="Instalação do Zabbix 5 + notificações pelo Telegram nativo + Grafana 7 + Debian 10 Buster" width="500" height="375" src="https://www.youtube.com/embed/-ylbrUyNRZE?feature=oembed&#038;wmode=opaque" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
<h4>Requisitos:</h4>
<p><a href="https://blog.remontti.com.br/2966" rel="noopener noreferrer" target="_blank">* Debian 10 (Buster) -> Instalação Limpa</a><br />
<a href="https://blog.remontti.com.br/3006" rel="noopener noreferrer" target="_blank">* Passo-a-passo como criar um servidor WEB Apache + PHP + MariaDB + phpMyAdmin no Debian 10 Buster &#8220;LAMP&#8221;</a> (Opcional phpMyAdmin)</p>
<h1>Zabbix</h1>
<p>Para instalação do Zabbix vamos incluir o repositório do oficial do Zabbix.</p>
<pre class="remontti-code"># su -
# cd /tmp
# apt install wget</pre>
<p><strong>Debian 10</strong></p>
<pre class="remontti-code"># wget https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-1+buster_all.deb
# dpkg -i zabbix-release_5.0-1+buster_all.deb</pre>
<p><strong>Debian 11</strong></p>
<pre class="remontti-code"># wget https://repo.zabbix.com/zabbix/5.0/debian/pool/main/z/zabbix-release/zabbix-release_5.0-1+bullseye_all.deb
# dpkg -i zabbix-release_5.0-1+bullseye_all.deb</pre>
<p>Atualize o repositório e realize a instalação </p>
<pre class="remontti-code"># apt update ; apt upgrade
# apt install zabbix-server-mysql zabbix-frontend-php zabbix-apache-conf zabbix-agent</pre>
<p>Vamos criar uma base de dados chamada <strong>zabbix</strong> e um usuário também chamado de zabbix no MariaDB.<br />
Não esqueça de alterar a senha: Use o gerador de senha: <a href="https://senhasegura.remontti.com.br/" rel="noopener noreferrer" target="_blank">https://senhasegura.remontti.com.br/</a></p>
<pre class="remontti-code"># mariadb -u root -p</pre>
<p>Senha</p>
<pre class="remontti-code">create database zabbix character set utf8 collate utf8_bin;
create user zabbix@localhost identified by &#039;SUA_SENHA&#039;;
grant all privileges on zabbix.* to zabbix@localhost;
quit;</pre>
<p>Importe o esquema de tabelas e dados padrões. (Demora um pouco!)</p>
<pre class="remontti-code"># zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mariadb -uzabbix -p zabbix</pre>
<p>Digite a senha de seu usuário zabbix criada no passo anterior para importar as tabelas.</p>
<p>Edite o arquivo zabbix_server.conf para informar os dados para conexão com o MySQL.</p>
<pre class="remontti-code"># vim /etc/zabbix/zabbix_server.conf</pre>
<p>Procure por <strong># DBPassword=</strong> descomente e sete sua senha.</p>
<pre class="remontti-code">#...
DBPassword=SUA_SENHA
#...</pre>
<p>Ajuste o <a href="https://secure.php.net/manual/pt_BR/timezones.america.php" rel="noopener noreferrer" target="_blank">timezone</a> pela sua região</a>.</p>
<pre class="remontti-code"># vim /etc/zabbix/apache.conf</pre>
<p>Este é modelo padrão, altere então para sua região, também irei alterar alguns valores padrões se quiser pode remover as conf do mod_php5.c </p>
<p>Se você quiser um modelo para acessa-lo por ex: zabbix.remontti.com.br, vou deixar um em seguida como proceder, bem como fechar o acesso apenas a determinado IP ou bloco.</p>
<pre class="remontti-code"># Define /zabbix alias, this is the default
&lt;IfModule mod_alias.c&gt;
    Alias /zabbix /usr/share/zabbix
&lt;/IfModule&gt;

&lt;Directory &quot;/usr/share/zabbix&quot;&gt;
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all

    &lt;IfModule mod_php5.c&gt;
        php_value max_execution_time 300
        php_value memory_limit 128M
        php_value post_max_size 16M
        php_value upload_max_filesize 2M
        php_value max_input_time 300
        php_value max_input_vars 10000
        php_value always_populate_raw_post_data -1
        # php_value date.timezone Europe/Rig
    &lt;/IfModule&gt;
    &lt;IfModule mod_php7.c&gt;
        php_value max_execution_time 300
        php_value memory_limit 512M
        php_value post_max_size 48M
        php_value upload_max_filesize 24M
        php_value max_input_time 300
        php_value max_input_vars 10000
        php_value always_populate_raw_post_data -1
        php_value date.timezone America/Sao_Paulo
    &lt;/IfModule&gt;
&lt;/Directory&gt;

&lt;Directory &quot;/usr/share/zabbix/conf&quot;&gt;
    Order deny,allow
    Deny from all
    &lt;files *.php&gt;
        Order deny,allow
        Deny from all
    &lt;/files&gt;
&lt;/Directory&gt;

&lt;Directory &quot;/usr/share/zabbix/app&quot;&gt;
    Order deny,allow
    Deny from all
    &lt;files *.php&gt;
        Order deny,allow
        Deny from all
    &lt;/files&gt;
&lt;/Directory&gt;

&lt;Directory &quot;/usr/share/zabbix/include&quot;&gt;
    Order deny,allow
    Deny from all
    &lt;files *.php&gt;
        Order deny,allow
        Deny from all
    &lt;/files&gt;
&lt;/Directory&gt;

&lt;Directory &quot;/usr/share/zabbix/local&quot;&gt;
    Order deny,allow
    Deny from all
    &lt;files *.php&gt;
        Order deny,allow
        Deny from all
    &lt;/files&gt;
&lt;/Directory&gt;</pre>
<p>Caso você queira o modelo acima então mova o /etc/zabbix/apache.conf para /etc/zabbix/apache.conf.old. Faça uma apontamento em seu DNS do subdomínio zabbix para o IP do seu servidor. Agora crie um novo arquivo:</p>
<pre class="remontti-code"># mv /etc/zabbix/apache.conf /etc/zabbix/apache.conf.default
# vim /etc/zabbix/apache.conf</pre>
<p>Altere em <strong>Require ip</strong> para os ips que terão acesso.</p>
<pre class="remontti-code">&lt;VirtualHost *:80&gt;
        ServerName zabbix.remontti.com.br
        ServerAlias localhost
        ServerAdmin noc@remontti.com.br
        DocumentRoot /usr/share/zabbix
        ErrorDocument 403 http://www.remontti.com.br
        &lt;Directory &quot;/usr/share/zabbix&quot;&gt;
            Options FollowSymLinks
            AllowOverride all
            Require ip 127.0.0.1 ::1 200.200.200.0/26 2001:db8::/32 192.168.0.0/16

            &lt;IfModule mod_php7.c&gt;
                php_value max_execution_time 300
                php_value memory_limit 512M
                php_value post_max_size 48M
                php_value upload_max_filesize 24M
                php_value max_input_time 300
                php_value max_input_vars 10000
                php_value always_populate_raw_post_data -1
                php_value date.timezone America/Sao_Paulo
            &lt;/IfModule&gt;
        &lt;/Directory&gt;

        &lt;Directory &quot;/usr/share/zabbix/conf&quot;&gt;
            Order deny,allow
            Deny from all
            &lt;files *.php&gt;
                Order deny,allow
                Deny from all
            &lt;/files&gt;
        &lt;/Directory&gt;

        &lt;Directory &quot;/usr/share/zabbix/app&quot;&gt;
            Order deny,allow
            Deny from all
            &lt;files *.php&gt;
                Order deny,allow
                Deny from all
            &lt;/files&gt;
        &lt;/Directory&gt;

        &lt;Directory &quot;/usr/share/zabbix/include&quot;&gt;
            Order deny,allow
            Deny from all
            &lt;files *.php&gt;
                Order deny,allow
                Deny from all
            &lt;/files&gt;
        &lt;/Directory&gt;

        &lt;Directory &quot;/usr/share/zabbix/local&quot;&gt;
            Order deny,allow
            Deny from all
            &lt;files *.php&gt;
                Order deny,allow
                Deny from all
            &lt;/files&gt;
        &lt;/Directory&gt;

        LogLevel warn

        ErrorLog ${APACHE_LOG_DIR}/zabbix_error.log
        CustomLog ${APACHE_LOG_DIR}/zabbix_access.log combined
&lt;/VirtualHost&gt;</pre>
<p>Por segurança recomendo remover a assinatura do servidor, evitando os &#8220;espertinhos&#8221;</p>
<pre class="remontti-code"># sed -i &#039;s/ServerTokens OS/ServerTokens Prod/&#039; /etc/apache2/conf-available/security.conf
 # sed -i &#039;s/ServerSignature On/ServerSignature Off/&#039; /etc/apache2/conf-available/security.conf</pre>
<p>Ative a o serviço junto com a inicialização do sistema, e restarte os mesmos.</p>
<pre class="remontti-code"># systemctl enable zabbix-server zabbix-agent
# systemctl restart zabbix-server zabbix-agent apache2</pre>
<p>Acesse em seu navegador <strong>http://seu_ip/zabbix</strong> ou <strong>http://zabbix.seudominio.com.br</strong></p>
<p>Next Step<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-1.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-1.png" alt="" width="1220" height="734" class="aligncenter size-full wp-image-4358" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-1.png 1220w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-1-300x180.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-1-1024x616.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-1-768x462.png 768w" sizes="auto, (max-width: 1220px) 100vw, 1220px" /></a></p>
<p>Se tudo estiver ok: Next step<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-2.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-2.png" alt="" width="1213" height="1224" class="aligncenter size-full wp-image-4359" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-2.png 1213w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-2-297x300.png 297w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-2-1015x1024.png 1015w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-2-150x150.png 150w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-2-768x775.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-2-80x80.png 80w" sizes="auto, (max-width: 1213px) 100vw, 1213px" /></a></p>
<p>Informe a senha do banco de dados criada anteriormente para o zabbix, e clique em Next step.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-3.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-3.png" alt="" width="1220" height="685" class="aligncenter size-full wp-image-4360" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-3.png 1220w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-3-300x168.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-3-1024x575.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-3-768x431.png 768w" sizes="auto, (max-width: 1220px) 100vw, 1220px" /></a></p>
<p>Next step<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-4.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-4.png" alt="" width="1220" height="685" class="aligncenter size-full wp-image-4361" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-4.png 1220w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-4-300x168.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-4-1024x575.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-4-768x431.png 768w" sizes="auto, (max-width: 1220px) 100vw, 1220px" /></a></p>
<p>Next step<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-5.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-5.png" alt="" width="1220" height="685" class="aligncenter size-full wp-image-4362" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-5.png 1220w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-5-300x168.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-5-1024x575.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-5-768x431.png 768w" sizes="auto, (max-width: 1220px) 100vw, 1220px" /></a></p>
<p>Finish<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-6.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-6.png" alt="" width="1220" height="685" class="aligncenter size-full wp-image-4363" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-6.png 1220w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-6-300x168.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-6-1024x575.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-6-768x431.png 768w" sizes="auto, (max-width: 1220px) 100vw, 1220px" /></a></p>
<p>Entre com Usuário <strong>Admin</strong> e senha <strong>zabbix</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-7.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-7.png" alt="" width="1220" height="685" class="aligncenter size-full wp-image-4364" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-7.png 1220w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-7-300x168.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-7-1024x575.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-7-768x431.png 768w" sizes="auto, (max-width: 1220px) 100vw, 1220px" /></a></p>
<p>Ualaaa <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-8.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-8.png" alt="" width="1401" height="1137" class="aligncenter size-full wp-image-4365" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-8.png 1401w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-8-300x243.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-8-1024x831.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zb5-8-768x623.png 768w" sizes="auto, (max-width: 1401px) 100vw, 1401px" /></a></p>
<p>Para dexa-lo em Português / Tema escuro:<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/zabbix-black.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/zabbix-black.png" alt="" width="1680" height="836" class="aligncenter size-full wp-image-4388" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/zabbix-black.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zabbix-black-300x149.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zabbix-black-1024x510.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zabbix-black-768x382.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/zabbix-black-1536x764.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<hr>
<p><strong>Possível bug na instalação</strong><br />
<img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2021/04/BUG_ZABBIX.jpg" alt="" width="1264" height="446" class="alignnone size-full wp-image-5704" srcset="https://blog.remontti.com.br/wp-content/uploads/2021/04/BUG_ZABBIX.jpg 1264w, https://blog.remontti.com.br/wp-content/uploads/2021/04/BUG_ZABBIX-300x106.jpg 300w, https://blog.remontti.com.br/wp-content/uploads/2021/04/BUG_ZABBIX-1024x361.jpg 1024w, https://blog.remontti.com.br/wp-content/uploads/2021/04/BUG_ZABBIX-768x271.jpg 768w" sizes="auto, (max-width: 1264px) 100vw, 1264px" /><br />
Caso se deparar com essa tela não se assuste, faça o seguinte:</p>
<pre class="remontti-code"># touch /etc/zabbix/web/zabbix.conf.php
# chown www-data. /etc/zabbix/web/zabbix.conf.php</pre>
<p>De um [Back]  depois [Next] q é sucesso!</p>
<hr>
<h1>Alertas no Telegram</h1>
<p>No Zabbix 5 temos o Telegram/Webhook, então bora aprender mexer nisso! Mas antes de mais nada será necessário criarmos um bot no Telegram.</p>
<p><strong>Criando Bot no telegram</strong></p>
<p>Abra o Telegram e procure por <a href="https://t.me/BotFather" rel="noopener noreferrer" target="_blank"><strong>@BotFather</strong></a>.<br />
Inicie a conversa com ele.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram1.jpg" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram1-169x300.jpg" alt="" width="169" height="300" class="alignnone size-medium wp-image-2823" srcset="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram1-169x300.jpg 169w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram1-576x1024.jpg 576w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram1.jpg 720w" sizes="auto, (max-width: 169px) 100vw, 169px" /></a> <a href="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram2.jpg" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram2-169x300.jpg" alt="" width="169" height="300" class="alignnone size-medium wp-image-2826" srcset="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram2-169x300.jpg 169w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram2-576x1024.jpg 576w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram2.jpg 720w" sizes="auto, (max-width: 169px) 100vw, 169px" /></a> <a href="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram3.jpg" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram3-169x300.jpg" alt="" width="169" height="300" class="alignnone size-medium wp-image-2827" srcset="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram3-169x300.jpg 169w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram3-576x1024.jpg 576w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram3.jpg 720w" sizes="auto, (max-width: 169px) 100vw, 169px" /></a></p>
<p>&#8211; Digite o comando <strong>/newbot</strong> para iniciar a criação de um novo bot.<br />
&#8211; Após o comando você vai dar um nome para seu bot. Ex.: <em>&#8220;Bot Legal RR&#8221;</em>.<br />
&#8211; Em seguida é necessário digitar o nome de usuário para o bot, sendo obrigatório terminar com <strong>bot</strong>. Ex.: <em>&#8220;legallrr_bot&#8221;</em>.<br />
&#8211; Ao finalizar você receber informações com seu TOKEN, que vamos utilizar em seguida.</p>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram4.jpg" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram4-169x300.jpg" alt="" width="169" height="300" class="alignnone size-medium wp-image-2830" srcset="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram4-169x300.jpg 169w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram4-576x1024.jpg 576w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram4.jpg 720w" sizes="auto, (max-width: 169px) 100vw, 169px" /></a> <a href="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram5.jpg" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram5-169x300.jpg" alt="" width="169" height="300" class="alignnone size-medium wp-image-2833" srcset="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram5-169x300.jpg 169w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram5-576x1024.jpg 576w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram5.jpg 720w" sizes="auto, (max-width: 169px) 100vw, 169px" /></a> <a href="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram6.jpg" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram6-169x300.jpg" alt="" width="169" height="300" class="alignnone size-medium wp-image-2835" srcset="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram6-169x300.jpg 169w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram6-576x1024.jpg 576w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram6.jpg 720w" sizes="auto, (max-width: 169px) 100vw, 169px" /></a></p>
<p>Neste exemplo nosso token para acessar a API HTTP ficou:<br />
<strong>757396508:AAHpaoyVN-95maOCax1vDPDQBnSaZd9P5r0</strong></p>
<p>Agora que o token abra o menu <strong>Administração</strong> &#8211;> <strong>Tipos de mídias</strong></p>
<p>Localize o Telegram e clique nele<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-1.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-1.png" alt="" width="1680" height="968" class="aligncenter size-full wp-image-4386" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-1.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-1-300x173.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-1-1024x590.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-1-768x443.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-1-1536x885.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>Edite o ParseMode para HTML e Token para o token q você acabou de criar. Marque Process tags.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-2.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-2.png" alt="" width="1680" height="885" class="aligncenter size-full wp-image-4387" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-2.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-2-300x158.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-2-1024x539.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-2-768x405.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-2-1536x809.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>Neste momento que escrevo na própria descrição da mídia telegram ele recomenda você add o bot @myidbot para descobrir o seu ID, mas parace que este bot está &#8220;dormindo&#8221;. Vamos ao metodos tradicional. Você pode receber notificações direta do seu bot ou então adiciono-lo em um grupo. </p>
<p>Procure pelo seu bot e comece uma conversa com ele e envie uma mensagem de teste para o mesmo, pois vamos precisar descobrir o ID do seu usuário, para que ele possa lhe enviar as mensagens.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram7.jpg" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram7-169x300.jpg" alt="" width="169" height="300" class="alignnone size-medium wp-image-2837" srcset="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram7-169x300.jpg 169w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram7-576x1024.jpg 576w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram7.jpg 720w" sizes="auto, (max-width: 169px) 100vw, 169px" /></a> <a href="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram8.jpg" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram8-169x300.jpg" alt="" width="169" height="300" class="alignnone size-medium wp-image-2838" srcset="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram8-169x300.jpg 169w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram8-576x1024.jpg 576w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram8.jpg 720w" sizes="auto, (max-width: 169px) 100vw, 169px" /></a></p>
<p>Abra em seu seu navegador a seguinte URL <em>https://api.telegram.org/bot<strong>TOKEN</strong>/getUpdates</em> para descobrir o ID do usuário que enviou a mensagem ou de um grupo.<br />
Ex.: <font size="2"><em>https://api.telegram.org/bot<strong><font color="red">757396508:AAHpaoyVN-95maOCax1vDPDQBnSaZd9P5r0</font></strong>/getUpdates</em></font></p>
<p><strong>:: Chat privado ::</strong></p>
<pre class="remontti-code">{&quot;ok&quot;:true,&quot;result&quot;:[{
	&quot;update_id&quot;:649208620,&quot;message&quot;:{
		&quot;message_id&quot;:2,&quot;from&quot;:{&quot;id&quot;:221122111,&quot;is_bot&quot;:false,&quot;first_name&quot;:&quot;Rudimar&quot;,&quot;last_name&quot;:&quot;Remontti&quot;,&quot;username&quot;:&quot;remontti&quot;,&quot;language_code&quot;:&quot;pt-br&quot;},
		&quot;chat&quot;:{&quot;id&quot;:999999999,&quot;first_name&quot;:&quot;Rudimar&quot;,&quot;last_name&quot;:&quot;Remontti&quot;,&quot;username&quot;:&quot;remontti&quot;,&quot;type&quot;:&quot;private&quot;},
		&quot;date&quot;:1541210279,&quot;text&quot;:&quot;Testando&quot;
	}
}]}</pre>
<p>ID do chat privado: <strong>999999999</strong></p>
<p>Se desejar criar um grupo também, basta adicionar seu bot a ele, após adiciona-lo envia uma mensagem como <strong>/teste</strong> para que possamos coletar o ID do grupo.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram9.jpg" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram9-169x300.jpg" alt="" width="169" height="300" class="alignnone size-medium wp-image-2843" srcset="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram9-169x300.jpg 169w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram9-576x1024.jpg 576w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram9.jpg 720w" sizes="auto, (max-width: 169px) 100vw, 169px" /></a> <a href="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram10.jpg" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram10-169x300.jpg" alt="" width="169" height="300" class="alignnone size-medium wp-image-2844" srcset="https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram10-169x300.jpg 169w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram10-576x1024.jpg 576w, https://blog.remontti.com.br/wp-content/uploads/2018/11/zabbix_bot_telegram10.jpg 720w" sizes="auto, (max-width: 169px) 100vw, 169px" /></a></p>
<p><strong>:: Chat em Grupo ::</strong></p>
<pre class="remontti-code">{&quot;ok&quot;:true,&quot;result&quot;:[{
	&quot;update_id&quot;:649208622,&quot;message&quot;:{&quot;message_id&quot;:4,&quot;from&quot;:{
		&quot;id&quot;:221122111,&quot;is_bot&quot;:false,&quot;first_name&quot;:&quot;Rudimar&quot;,&quot;last_name&quot;:&quot;Remontti&quot;,&quot;username&quot;:&quot;remontti&quot;,&quot;language_code&quot;:&quot;pt-br&quot;},
		&quot;chat&quot;:{&quot;id&quot;:-88888888888,&quot;title&quot;:&quot;Grupo Legal&quot;,&quot;type&quot;:&quot;group&quot;,&quot;all_members_are_administrators&quot;:true
	},&quot;date&quot;:1541210975,&quot;text&quot;:&quot;/teste&quot;,&quot;entities&quot;:[{&quot;offset&quot;:0,&quot;length&quot;:6,&quot;type&quot;:&quot;bot_command&quot;}
}]}</pre>
<p>ID do chat grupo: <strong>-88888888888</strong></p>
<p>Atenção para os <strong>grupos</strong> que sempre tem um sinal &#8220;-&#8221; na frente do ID.</p>
<p>Com o ID do grupo/usuário precisamos vincular ao usuário do Zabbix (Neste caso Admin)<br />
<strong>Administração</strong> ⇒ <strong>Usuários</strong> Clique no usuário <strong>Admin</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-3.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-3.png" alt="" width="1680" height="541" class="aligncenter size-full wp-image-4389" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-3.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-3-300x97.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-3-1024x330.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-3-768x247.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-3-1536x495.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>Com as opções do usuário aberto clique na aba <strong>Mídia</strong> em seguita clique no <strong>Adicionar</strong>, selecione o Tipo Telegram e insira o em Enviar para o ID.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-5.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-5.png" alt="" width="1680" height="624" class="aligncenter size-full wp-image-4390" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-5.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-5-300x111.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-5-1024x380.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-5-768x285.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-5-1536x571.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a> </p>
<p>Atualize<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-6.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-6.png" alt="" width="1680" height="269" class="aligncenter size-full wp-image-4391" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-6.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-6-300x48.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-6-1024x164.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-6-768x123.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-6-1536x246.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>Agora vamos criar a ação que fará o envios dos alertas.<br />
<strong>Configurações</strong> ⇒ <strong>Ações</strong> ⇒ <strong>Criar ação</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-7.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-7.png" alt="" width="1680" height="495" class="aligncenter size-full wp-image-4392" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-7.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-7-300x88.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-7-1024x302.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-7-768x226.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-7-1536x453.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>De um nome para sua ação<br />
Em Condição clique em adicionar: Selecione <strong>Incidente suprimido</strong> e marque <strong>Não</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-8.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-8.png" alt="" width="1680" height="527" class="aligncenter size-full wp-image-4393" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-8.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-8-300x94.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-8-1024x321.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-8-768x241.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-8-1536x482.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>Na aba <strong>Operações</strong> primeiro item <strong>Operações</strong> clique em <strong>adicionar</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-9.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-9.png" alt="" width="1680" height="470" class="aligncenter size-full wp-image-4394" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-9.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-9-300x84.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-9-1024x286.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-9-768x215.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-9-1536x430.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p><strong>Enviar para usuário</strong>: Selecione o <strong>Admin</strong><br />
Enviar apenas para: <strong>Telegram</strong><br />
Marque <strong>Custom message</strong>, preencha com:<br />
<strong>Assunto</strong>:</p>
<pre class="remontti-code"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/274c.png" alt="❌" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Problema: &lt;b&gt;{HOST.NAME}&lt;/b&gt;</pre>
<p><strong>Mensagem</strong></p>
<pre class="remontti-code">&lt;code&gt;{EVENT.NAME}&lt;/code&gt;
&lt;b&gt;{ITEM.NAME1}&lt;/b&gt; &lt;i&gt;{ITEM.VALUE1}&lt;/i&gt;

&lt;a href=&quot;{HOST.IP}&quot;&gt;{HOST.IP}&lt;/a&gt;
&lt;i&gt;{EVENT.SEVERITY}&lt;/i&gt;</pre>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-10.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-10.png" alt="" width="1680" height="836" class="aligncenter size-full wp-image-4395" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-10.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-10-300x149.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-10-1024x510.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-10-768x382.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-10-1536x764.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>No item <strong>Operações de recuperação</strong> faremos praticamente o mesmo:</p>
<p><strong>Assunto</strong>:</p>
<pre class="remontti-code"><img src="https://s.w.org/images/core/emoji/17.0.2/72x72/2705.png" alt="✅" class="wp-smiley" style="height: 1em; max-height: 1em;" /> Resolvido: &lt;b&gt;{HOST.NAME}&lt;/b&gt;</pre>
<p><strong>Mensagem padrão</strong></p>
<pre class="remontti-code">&lt;code&gt;{EVENT.NAME}&lt;/code&gt;
&lt;b&gt;{ITEM.NAME1}&lt;/b&gt; &lt;i&gt;{ITEM.VALUE1}&lt;/i&gt;

&lt;a href=&quot;{HOST.IP}&quot;&gt;{HOST.IP}&lt;/a&gt;
&lt;i&gt;{EVENT.SEVERITY}&lt;/i&gt;</pre>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-11.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-11.png" alt="" width="1680" height="836" class="aligncenter size-full wp-image-4396" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-11.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-11-300x149.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-11-1024x510.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-11-768x382.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-11-1536x764.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>No item <strong>Operações de atualização</strong><br />
<strong>Assunto</strong>:</p>
<pre class="remontti-code">Problema atualizado: {EVENT.NAME}</pre>
<p><strong>Mensagem padrão</strong></p>
<pre class="remontti-code">{USER.FULLNAME} {EVENT.UPDATE.ACTION} problema em {EVENT.UPDATE.DATE} {EVENT.UPDATE.TIME}.
{EVENT.UPDATE.MESSAGE}
O status atual do problema é {EVENT.STATUS}, reconhecido: {EVENT.ACK.STATUS}.</pre>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-12.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-12.png" alt="" width="1680" height="836" class="aligncenter size-full wp-image-4397" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-12.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-12-300x149.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-12-1024x510.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-12-768x382.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-12-1536x764.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>Operações configurada, clique em atualizar.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-13.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-13.png" alt="" width="1680" height="544" class="aligncenter size-full wp-image-4398" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-13.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-13-300x97.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-13-1024x332.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-13-768x249.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/tele-13-1536x497.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>Pronto! Agora precisamos gerar um incidente para ver se nosso alerta será enviado para o Telegram.</p>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2019/07/zabbix-4.2-debian-10-buster-telegram-bot-14.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/zabbix-4.2-debian-10-buster-telegram-bot-14-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-3080" srcset="https://blog.remontti.com.br/wp-content/uploads/2019/07/zabbix-4.2-debian-10-buster-telegram-bot-14-576x1024.png 576w, https://blog.remontti.com.br/wp-content/uploads/2019/07/zabbix-4.2-debian-10-buster-telegram-bot-14-169x300.png 169w, https://blog.remontti.com.br/wp-content/uploads/2019/07/zabbix-4.2-debian-10-buster-telegram-bot-14.png 720w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>O sistema de envio de mensagem está concluído! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<h1>Grafana 7</h1>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana.png" alt="" width="1680" height="1050" class="aligncenter size-full wp-image-4367" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-300x188.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-1024x640.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-768x480.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-1536x960.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>Pacotes necessários:</p>
<pre class="remontti-code"># apt install gnupg2 apt-transport-https software-properties-common</pre>
<p>Vamos baixar a key do repositório e adiciona-lo </p>
<pre class="remontti-code"># wget -q -O - https://packages.grafana.com/gpg.key | apt-key add -
# echo &quot;deb https://packages.grafana.com/oss/deb stable main&quot; | tee -a /etc/apt/sources.list.d/grafana.list</pre>
<p>Atualize o repositório e instale o grafana</p>
<pre class="remontti-code"># apt update
# apt install grafana</pre>
<hr>
<p><strong>OBS Julho/2021: </strong><br />
Atualmente o grafana que está sendo instalado é a versão 8, o mesmo na data de hoje está passando por um <a href="https://github.com/alexanderzobnin/grafana-zabbix/issues/1221" rel="noopener" target="_blank">bug com o plugin do Zabbix</a> caso você queira instalar a ultima versão 7.x faça o seguinte:<br />
Solução fazer downgrade para última versão 7:</p>
<pre class="remontti-code"># vim /etc/apt/sources.list.d/grafana.list</pre>
<p>Comente a linha do repositório (quando o <a href="https://github.com/alexanderzobnin/grafana-zabbix/issues/1221" rel="noopener" target="_blank">bug</a> for corrigido você pode descomenta-la para fazer o upgrade para versão 8). </p>
<pre class="remontti-code">#deb https://packages.grafana.com/oss/deb stable main</pre>
<pre class="remontti-code"># apt update
# cd /tmp/
# wget https://dl.grafana.com/oss/release/grafana_7.5.9_amd64.deb
# apt install ./grafana_7.5.9_amd64.deb
# grafana-cli plugins update-all
# systemctl restart grafana-server</pre>
<hr>
<p>Antes de iniciar o grafana, se deseja alterar a porta padrão <strong>3000</strong> (recomendo) edite:</p>
<pre class="remontti-code"># vim /etc/grafana/grafana.ini</pre>
<p>Localize <strong>http_port</strong> e defina a porta de sua escolha.</p>
<pre class="remontti-code"># The http port  to use
;http_port = 3000</pre>
<p>Exemplo:</p>
<pre class="remontti-code">http_port = 53000</pre>
<p>Localize em [plugins] <strong>;allow_loading_unsigned_plugins</strong> descomente removendo o &#8220;;&#8221; e adicionando:</p>
<pre class="remontti-code">allow_loading_unsigned_plugins = alexanderzobnin-zabbix-datasource</pre>
<p><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana7_zabbix.png" alt="" width="1451" height="155" class="alignnone size-full wp-image-5022" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana7_zabbix.png 1451w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana7_zabbix-300x32.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana7_zabbix-1024x109.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana7_zabbix-768x82.png 768w" sizes="auto, (max-width: 1451px) 100vw, 1451px" /><br />
Caso contrário o plugin de integração com o zabbix não irá funcionar.</p>
<p>Já instalamos também o plugin Zabbix com ferramenta grafana-cli:</p>
<pre class="remontti-code"># grafana-cli plugins install alexanderzobnin-zabbix-app</pre>
<p>É recomendado que mensalmente você faça atualizações dos plugins instalados, com o comando:</p>
<pre class="remontti-code"># grafana-cli plugins update-all</pre>
<p>Agora sim colocamos o Grafana para iniciar junto com a inicialização, ativamos e inicializamos o serviço:</p>
<pre class="remontti-code"># systemctl daemon-reload
# systemctl enable grafana-server
# systemctl start grafana-server</pre>
<p>Acesse em seu navegador <strong>http://IP_URL:3000</strong> ou pela porta que você alterou. O nome de usuário padrão é admin e a senha padrão é admin.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-1.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-1.png" alt="" width="1370" height="781" class="aligncenter size-full wp-image-4368" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-1.png 1370w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-1-300x171.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-1-1024x584.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-1-768x438.png 768w" sizes="auto, (max-width: 1370px) 100vw, 1370px" /></a></p>
<p>Ao fazer login pela primeira vez, você será solicitado a alterar sua senha.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-2.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-2.png" alt="" width="1370" height="732" class="aligncenter size-full wp-image-4369" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-2.png 1370w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-2-300x160.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-2-1024x547.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-2-768x410.png 768w" sizes="auto, (max-width: 1370px) 100vw, 1370px" /></a></p>
<p>Uhull <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-3.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-3.png" alt="" width="1370" height="720" class="aligncenter size-full wp-image-4370" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-3.png 1370w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-3-300x158.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-3-1024x538.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-3-768x404.png 768w" sizes="auto, (max-width: 1370px) 100vw, 1370px" /></a></p>
<h4>Integração do grafana com o Zabbix</h4>
<p>Acesse o Configuration &#8211;> Plugins:<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-7.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-7.png" alt="" width="1366" height="633" class="aligncenter size-full wp-image-4374" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-7.png 1366w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-7-300x139.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-7-1024x475.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-7-768x356.png 768w" sizes="auto, (max-width: 1366px) 100vw, 1366px" /></a></p>
<p>Localize o Zabbix e clique no mesmo<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-5.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-5.png" alt="" width="1370" height="688" class="aligncenter size-full wp-image-4372" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-5.png 1370w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-5-300x151.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-5-1024x514.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-5-768x386.png 768w" sizes="auto, (max-width: 1370px) 100vw, 1370px" /></a></p>
<p>Agora ative clicando em <strong>Enable</strong>.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-6.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-6.png" alt="" width="1370" height="688" class="aligncenter size-full wp-image-4373" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-6.png 1370w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-6-300x151.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-6-1024x514.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-6-768x386.png 768w" sizes="auto, (max-width: 1370px) 100vw, 1370px" /></a></p>
<p>Volte em Configuration &#8211;> Data Sources<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-8.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-8.png" alt="" width="1366" height="633" class="aligncenter size-full wp-image-4375" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-8.png 1366w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-8-300x139.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-8-1024x475.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-8-768x356.png 768w" sizes="auto, (max-width: 1366px) 100vw, 1366px" /></a></p>
<p>Clique em <strong>Add data source</strong>.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-9.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-9.png" alt="" width="1370" height="639" class="aligncenter size-full wp-image-4376" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-9.png 1370w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-9-300x140.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-9-1024x478.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-9-768x358.png 768w" sizes="auto, (max-width: 1370px) 100vw, 1370px" /></a></p>
<p>Uma nova tela com varias fontes, localize Zabbix e clique em <strong>Select</strong><br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-10.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-10.png" alt="" width="1370" height="639" class="aligncenter size-full wp-image-4377" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-10.png 1370w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-10-300x140.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-10-1024x478.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-10-768x358.png 768w" sizes="auto, (max-width: 1370px) 100vw, 1370px" /></a></p>
<p>Nas opções <strong>HTTP</strong> em <strong>URL</strong> informe o endereço do seu servidor Zabbix <strong>http://IP_URL/zabbix/api_jsonrpc.php</strong>. Em <strong>Access</strong> selecione <strong>Browser</strong>. Em <strong>Zabbix API details</strong> informe seu usuário e senha do Zabbix e selecione a versão correspondente.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_conexao.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_conexao.png" alt="" width="641" height="840" class="alignnone size-full wp-image-4032" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_conexao.png 641w, https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_conexao-229x300.png 229w" sizes="auto, (max-width: 641px) 100vw, 641px" /></a></p>
<p>Role até o final e e clique em <strong>Save &#038; Test</strong> Se tudo ocorreu bem uma altera positivo com<strong>&#8220;Zabbix API version: 5.x.x&#8221;</strong> aparecerá.</p>
<p>Você pode também pode fazer uma conexão MySQL (MariaDB) com o banco de dados do zabbix, para tornar as coisas mais rápidas. Para isso basta &#8220;Add data source&#8221; pesquisar por mysql, e informar os dados de conexões, provavelmente seu grafana esteja junto com seu zabbix, então basta informa nome do banco, usuário e senha.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-12.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-12.png" alt="" width="1370" height="1180" class="aligncenter size-full wp-image-4378" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-12.png 1370w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-12-300x258.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-12-1024x882.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-12-768x661.png 768w" sizes="auto, (max-width: 1370px) 100vw, 1370px" /></a></p>
<p>Vá para as configurações do data source do zabbix, localize <strong>Direct DB Connection</strong>, ative-o e selecione <strong>MySQL</strong>.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-13.png" data-rel="lightbox-gallery-DQLdbj5h" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-13.png" alt="" width="1366" height="633" class="aligncenter size-full wp-image-4379" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-13.png 1366w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-13-300x139.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-13-1024x475.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/05/grafana-13-768x356.png 768w" sizes="auto, (max-width: 1366px) 100vw, 1366px" /></a></p>
<p>Agora vem a parte mais &#8220;chata/legal&#8221; que é você montar seus gráficos, como isso é algo bem peculiar de cada um, o intuito aqui era ensinar instalar. Recomendo a leitura de <a href="https://alexanderzobnin.github.io/grafana-zabbix/guides/gettingstarted/" rel="noopener noreferrer" target="_blank">Introdução ao Grafana-Zabbix</a> do autor do plugin.</p>
<p>Simples né? Gostou e quer me ajudar? <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a></p>
<p>Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>Abraço!</p>
<h3>Bônus &#8211; Proxy grafana</h3>
<pre class="remontti-code"># a2enmod rewrite
# a2enmod headers
# a2enmod proxy
# a2enmod proxy_http
# mkdir /var/www/grafana
</pre>
<pre class="remontti-code"># vim /etc/apache2/sites-available/grafana.conf</pre>
<pre class="remontti-code">&lt;VirtualHost *:80&gt;
	Protocols h2 http/1.1
	ServerName grafana.remontti.com.br
	ServerAdmin noc@remontti.com.br
	DocumentRoot /var/www/grafana

	ErrorDocument 403 http://www.remontti.com.br

	&lt;Directory /var/www/grafana/&gt;
		Options Indexes FollowSymLinks
		AllowOverride all
		Require ip 127.0.0.1 ::1 200.200.200.0/26 2001:db8:cafe::/48
	&lt;/Directory&gt;

	LogLevel warn

	ProxyPreserveHost On
	ProxyPass / http://localhost:53000/
	ProxyPassReverse / http://localhost:53000/

	ErrorLog ${APACHE_LOG_DIR}/grafana_error.log
	CustomLog ${APACHE_LOG_DIR}/grafana_access.log combined
	TransferLog ${APACHE_LOG_DIR}/grafana_access.log

&lt;/VirtualHost&gt;</pre>
<pre class="remontti-code"># a2ensite grafana
# systemctl restart apache2</pre>
<p>Fontes:<br />
https://www.zabbix.com/download<br />
https://www.zabbix.com/documentation/<br />
https://grafana.com/docs/grafana/latest/installation/debian/<br />
https://grafana.com/grafana/plugins/alexanderzobnin-zabbix-app<br />
https://alexanderzobnin.github.io/grafana-zabbix/configuration/<br />
https://core.telegram.org/bots</p>
<p>O post <a href="https://blog.remontti.com.br/4348">Instalação do Zabbix 5.0 LTS + notificações pelo Telegram nativo + Grafana 7/8 + Debian 10/11</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/4348/feed</wfw:commentRss>
			<slash:comments>71</slash:comments>
		
		
			</item>
		<item>
		<title>Instalação do Grafana e integrando com Zabbix (Debian 10)</title>
		<link>https://blog.remontti.com.br/4014</link>
					<comments>https://blog.remontti.com.br/4014#comments</comments>
		
		<dc:creator><![CDATA[Rudimar Remontti]]></dc:creator>
		<pubDate>Sat, 08 Feb 2020 20:54:59 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutoriais]]></category>
		<category><![CDATA[4.4]]></category>
		<category><![CDATA[grafana]]></category>
		<category><![CDATA[integração]]></category>
		<category><![CDATA[monitoramenteo]]></category>
		<category><![CDATA[zabbix]]></category>
		<category><![CDATA[zabbix4]]></category>
		<category><![CDATA[zabbix4.4]]></category>
		<category><![CDATA[zabbix5]]></category>
		<guid isPermaLink="false">https://blog.remontti.com.br/?p=4014</guid>

					<description><![CDATA[<p>Esse é especial ao amigos que compraram uma TV nova para sala do NOC e estão querendo por aquele gráfico lindão nela! Bom, seus problemas acabaram! 😛 O Grafana é um software livre que&#46;&#46;&#46;</p>
<p>O post <a href="https://blog.remontti.com.br/4014">Instalação do Grafana e integrando com Zabbix (Debian 10)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Esse é especial ao amigos que compraram uma TV nova para sala do NOC e estão querendo por aquele gráfico lindão nela! Bom, seus problemas acabaram! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f61b.png" alt="😛" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/banner.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/banner.png" alt="" width="942" height="582" class="alignnone size-full wp-image-4040" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/banner.png 942w, https://blog.remontti.com.br/wp-content/uploads/2020/02/banner-300x185.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/02/banner-768x474.png 768w" sizes="auto, (max-width: 942px) 100vw, 942px" /></a></p>
<p>O Grafana é um software livre que permite a visualização de formato de dados métricos. Ele permite criar painéis e gráficos a partir de várias fontes, e neste tutorial vamos aprender a integrar com o Zabbix.</p>
<p>Requisitos:<br />
<a href="https://blog.remontti.com.br/2966" rel="noopener noreferrer" target="_blank">* Debian 10 (Buster) -> Instalação Limpa</a><br />
<a href="https://blog.remontti.com.br/3995" rel="noopener noreferrer" target="_blank">* Zabbix 4.4</a> (<a href="https://blog.remontti.com.br/?s=zabbix" rel="noopener noreferrer" target="_blank">ou outra versão de sua escolha</a>)</p>
<p>Sem lenga lenga vamos aos que interessa. Pacotes necessários:</p>
<pre class="remontti-code"># apt install gnupg2 apt-transport-https software-properties-common wget</pre>
<p>Vamos baixar a key do repositório e adiciona-lo </p>
<pre class="remontti-code"># wget -q -O - https://packages.grafana.com/gpg.key | apt-key add -
# echo &quot;deb https://packages.grafana.com/oss/deb stable main&quot; | tee -a /etc/apt/sources.list.d/grafana.list</pre>
<p>Atualize o repositório e instale o grafana</p>
<pre class="remontti-code"># apt update
# apt install grafana</pre>
<p>Configure o servidor Grafana para iniciar na inicialização, e inicie o serviço:</p>
<pre class="remontti-code"># systemctl daemon-reload
# systemctl enable grafana-server
# systemctl start grafana-server</pre>
<p>Grafana vai estará rodando na porta 3000, então acesse em seu navegador <strong>http://IP_URL:3000</strong> O nome de usuário padrão é admin e a senha padrão é admin.<br />
<div id="attachment_4016" style="width: 1690px" class="wp-caption alignnone"><a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" aria-describedby="caption-attachment-4016" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster.png" alt="" width="1680" height="875" class="size-full wp-image-4016" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster-300x156.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster-1024x533.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster-768x400.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster-1536x800.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a><p id="caption-attachment-4016" class="wp-caption-text">admin / admin</p></div></p>
<p>Ao fazer login pela primeira vez, você será solicitado a alterar sua senha.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster1.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster1.png" alt="" width="1680" height="826" class="alignnone size-full wp-image-4017" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster1.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster1-300x148.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster1-1024x503.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster1-768x378.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster1-1536x755.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster2.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster2.png" alt="" width="1680" height="865" class="alignnone size-full wp-image-4018" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster2.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster2-300x154.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster2-1024x527.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster2-768x395.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/02/grafana_zabbix_debian_buster2-1536x791.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a> </p>
<h3>Integração Zabbix</h3>
<p>Use a ferramenta grafana-cli para instalar o plugin Zabbix a partir da linha de comando:</p>
<pre class="remontti-code"># grafana-cli plugins install alexanderzobnin-zabbix-app
# systemctl restart grafana-server</pre>
<p>Acesse o Configurações &#8211;> Plugins:<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/menu_plugins.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/menu_plugins.png" alt="" width="204" height="245" class="alignnone size-full wp-image-4026" /></a><br />
Localize o Zabbix e clique no mesmo<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/plugin_zabbix.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/plugin_zabbix.png" alt="" width="976" height="432" class="alignnone size-full wp-image-4027" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/plugin_zabbix.png 976w, https://blog.remontti.com.br/wp-content/uploads/2020/02/plugin_zabbix-300x133.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/02/plugin_zabbix-768x340.png 768w" sizes="auto, (max-width: 976px) 100vw, 976px" /></a></p>
<p>Agora ative clicando em <strong>Enable</strong>.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/zabbix_grafana.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/zabbix_grafana.png" alt="" width="959" height="529" class="alignnone size-full wp-image-4029" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/zabbix_grafana.png 959w, https://blog.remontti.com.br/wp-content/uploads/2020/02/zabbix_grafana-300x165.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/02/zabbix_grafana-768x424.png 768w" sizes="auto, (max-width: 959px) 100vw, 959px" /></a></p>
<p>Configurações &#8211;> Data Sources<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/menu.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/menu.png" alt="" width="217" height="244" class="alignnone size-full wp-image-4023" /></a></p>
<p>Clique em <strong>Add data source</strong> uma nova tela com varias fontes, localize Zabbix e o selecione.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_select.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_select.png" alt="" width="975" height="327" class="alignnone size-full wp-image-4031" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_select.png 975w, https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_select-300x101.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_select-768x258.png 768w" sizes="auto, (max-width: 975px) 100vw, 975px" /></a></p>
<p>Nas opções <strong>HTTP</strong> em <strong>URL</strong> informe o endereço do seu servidor Zabbix <strong>http://IP_URL/zabbix/api_jsonrpc.php</strong>. Em <strong>Access</strong> selecione <strong>Browser</strong>. Em <strong>Zabbix API details</strong> informe seu usuário e senha do Zabbix e selecione a versão correspondente.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_conexao.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_conexao.png" alt="" width="641" height="840" class="alignnone size-full wp-image-4032" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_conexao.png 641w, https://blog.remontti.com.br/wp-content/uploads/2020/02/zb_conexao-229x300.png 229w" sizes="auto, (max-width: 641px) 100vw, 641px" /></a></p>
<p>Role até o final e e clique em <strong>Save &#038; Test</strong> Se tudo ocorreu bem uma altera positivo com<strong>&#8220;Zabbix API version: 4.4.x&#8221;</strong> aparecerá.</p>
<p>Você pode também pode fazer uma conexão MySQL (MariaDB) com o banco de dados do zabbix, para tornar as coisas mais rápidas. Para isso basta &#8220;Add data source&#8221; pesquisar por mysql, e informar os dados de conexões, provavelmente seu grafana esteja junto com seu zabbix, então basta informa nome do banco, usuário e senha.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/mysql_cx.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/mysql_cx.png" alt="" width="651" height="489" class="alignnone size-full wp-image-4034" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/mysql_cx.png 651w, https://blog.remontti.com.br/wp-content/uploads/2020/02/mysql_cx-300x225.png 300w" sizes="auto, (max-width: 651px) 100vw, 651px" /></a></p>
<p>Vá para as configurações do data source do zabbix, localize <strong>Direct DB Connection</strong>, ative-o e selecione <strong>MySQL</strong>.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/mysql_direct.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/mysql_direct.png" alt="" width="600" height="773" class="alignnone size-full wp-image-4035" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/mysql_direct.png 600w, https://blog.remontti.com.br/wp-content/uploads/2020/02/mysql_direct-233x300.png 233w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>Salve </p>
<p>Agora vem a parte mais chata que é você montar seus gráficos, como isso é algo bem peculiar de cada um, o intuito aqui era ensinar instalar.<br />
Recomendo a leitura de <a href="https://alexanderzobnin.github.io/grafana-zabbix/guides/gettingstarted/" rel="noopener noreferrer" target="_blank">Introdução ao Grafana-Zabbix</a> do autor do plugin.</p>
<p>Mas &#8220;basicamente&#8221; agora o que você que está começando é clicar adicionar uma nova dashboard, um exemplo bem simplesinho aqui rsrs</p>
<p>Clique em Add Query<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/nova.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/nova.png" alt="" width="967" height="424" class="alignnone size-full wp-image-4037" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/nova.png 967w, https://blog.remontti.com.br/wp-content/uploads/2020/02/nova-300x132.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/02/nova-768x337.png 768w" sizes="auto, (max-width: 967px) 100vw, 967px" /></a></p>
<p>Vamos criar este mesmo gráfico la no grafana.<br />
<a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo1.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo1.png" alt="" width="1680" height="875" class="alignnone size-full wp-image-4038" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo1.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo1-300x156.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo1-1024x533.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo1-768x400.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo1-1536x800.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p><a href="https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo.png" data-rel="lightbox-gallery-ZvKSZ9RU" data-rl_title="" data-rl_caption="" title=""><img loading="lazy" decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo.png" alt="" width="1680" height="918" class="alignnone size-full wp-image-4039" srcset="https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo.png 1680w, https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo-300x164.png 300w, https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo-1024x560.png 1024w, https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo-768x420.png 768w, https://blog.remontti.com.br/wp-content/uploads/2020/02/modelo-1536x839.png 1536w" sizes="auto, (max-width: 1680px) 100vw, 1680px" /></a></p>
<p>Simples né? Gostou e quer me ajudar? <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<p><strong>Se quiser fazer uma doação para o café ficarei muito feliz pelo seu reconhecimento!</strong><br />
<a href="https://blog.remontti.com.br/doar"><img decoding="async" src="https://blog.remontti.com.br/wp-content/uploads/2019/07/quero-doar-remontti.png" /></a></p>
<p>Se não puder doar pode deixar seu agradecimento nos comentário também ficarei feliz em saber que ajudei. Se tiver qualquer pergunta deixe-a também. Se preferir entrar em Contato <a href="https://blog.remontti.com.br/meucontato" rel="noopener noreferrer" target="_blank">clique aqui.</a></p>
<p>Abraço!</p>
<p>Fontes:<br />
https://grafana.com/docs/grafana/latest/installation/debian/<br />
https://grafana.com/grafana/plugins/alexanderzobnin-zabbix-app<br />
https://alexanderzobnin.github.io/grafana-zabbix/configuration/</p>
<p>O post <a href="https://blog.remontti.com.br/4014">Instalação do Grafana e integrando com Zabbix (Debian 10)</a> apareceu primeiro em <a href="https://blog.remontti.com.br">Remontti</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.remontti.com.br/4014/feed</wfw:commentRss>
			<slash:comments>12</slash:comments>
		
		
			</item>
	</channel>
</rss>
