<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gabriel Tetzner Menegueti</title>
    <description>The latest articles on DEV Community by Gabriel Tetzner Menegueti (@gabrieltetzner).</description>
    <link>https://dev.to/gabrieltetzner</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F842043%2F00bf364b-61b8-4fb2-99b3-95b898351632.jpeg</url>
      <title>DEV Community: Gabriel Tetzner Menegueti</title>
      <link>https://dev.to/gabrieltetzner</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gabrieltetzner"/>
    <language>en</language>
    <item>
      <title>Setting up a VPN with Wireguard Server on AWS EC2.</title>
      <dc:creator>Gabriel Tetzner Menegueti</dc:creator>
      <pubDate>Fri, 04 Aug 2023 15:32:54 +0000</pubDate>
      <link>https://dev.to/gabrieltetzner/setting-up-a-vpn-with-wireguard-server-on-aws-ec2-4a49</link>
      <guid>https://dev.to/gabrieltetzner/setting-up-a-vpn-with-wireguard-server-on-aws-ec2-4a49</guid>
      <description>&lt;h2&gt;
  
  
  Github
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Tetzdesen/wireguard-tutorial" rel="noopener noreferrer"&gt;wireguard-tutorial&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;An account on a cloud platform that offers a virtual machine (e.g. AWS, Azure, Google Cloud, etc.).&lt;/li&gt;
&lt;li&gt;Ubuntu 20.04 Server Virtual Machine.&lt;/li&gt;
&lt;li&gt;A public IP address assigned to your VM.&lt;/li&gt;
&lt;li&gt;UDP port 51820 open to incoming traffic from all sources (0.0.0.0/0).&lt;/li&gt;
&lt;li&gt;The region chosen to raise the machine in this tutorial was South America (São Paulo, Brazil) (sa-east-1), but choose your preferred region.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv6c4hdbq0ghqu6j83062.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv6c4hdbq0ghqu6j83062.png" alt="Image 01"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyqsuwf4g1p89hr88xnkx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyqsuwf4g1p89hr88xnkx.png" alt="Image 02"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Caption: Configuring the opening of port 51820 UDP for the instance launched on AWS.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Caption: Instance configuration with public IP and port 51820 UDP open.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In this tutorial, we will set up a WireGuard VPN server on an Ubuntu 20.04 instance running on AWS.&lt;/p&gt;

&lt;p&gt;WireGuard is a user-friendly VPN solution that utilizes end-to-end encryption, making it more efficient than IPSEC and faster than OpenVPN.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;1. Server WireGuard Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Launch an Instance on AWS EC2&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First, we need to launch an Ubuntu 20.04 instance on AWS.&lt;/p&gt;

&lt;p&gt;Note: The usage is from Ubuntu 20.04, but can be from a recent version.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 2: Install WireGuard&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After your instance is up and running, we can proceed to install WireGuard using the following commands in the terminal:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo apt update


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Next we will install the Wireguard package:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo apt install wireguard


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F59b987pw7so01ybfgasb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F59b987pw7so01ybfgasb.png" alt="Image 03"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Caption: Running the apt update and apt install wireguard commands on the AWS instance.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Step 3: Configuring Wireguard Server on AWS instance&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;With the package installed, we now need to set up the WireGuard server on the AWS instance.&lt;/p&gt;

&lt;p&gt;But, we need to create the directory for generating the wireguard files, run the command: &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo mkdir /etc/wireguard/


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Great! Now let's generate the appropriate private and public keys for the Wireguard server:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ wg genkey | sudo tee /etc/wireguard/privatekey | wg pubkey | sudo tee /etc/wireguard/publickey


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For a greater understanding, a Wireguard tunnel is encrypted using an asymmetric, i.e. dual key, encryption system. Your private key is unique and should never be shared, unlike the public key which is what will be shared to the VPN clients.&lt;/p&gt;

&lt;p&gt;Now we will need to create and configure the Wireguard interface file that will serve as the gateway within our VPN.&lt;/p&gt;

&lt;p&gt;Create and edit the file wg0.conf:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo nano /etc/wireguard/wg0.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;wg0 is the configuration file for the wg0 interface.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Enter the following settings:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

[Interface]
Address = 10.0.0.1/24
SaveConfig = true
ListenPort = 51820
PrivateKey = private_key
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwc424fql8ugr2elcxiz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxwc424fql8ugr2elcxiz.png" alt="Image 04"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Caption: Configuring wg0.conf file on wireguard server.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Note: In the text above, the phrase "-o eth0" means that it is your machine's default network interface (and that would be the one that knows the AWS outgoing gateway), i.e. if it is different, you should replace it with the appropriate name. To check which is the correct interface this is, just run the command:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ ip -c a


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;You should see something like this, like:&lt;/p&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4h51277amj0mnh9xaiwq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4h51277amj0mnh9xaiwq.png" alt="Image 05"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Caption: Checking the machine's default network interface.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To continue, replace  with the private key you generated earlier. The AllowedIPs option specifies the IP address range that will be routed through the VPN.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 4: Start the WireGuard Service&lt;/strong&gt;&lt;br&gt;
Once the configuration is complete, we can start the WireGuard service:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo systemctl enable wg-quick@wg0
$ sudo systemctl start wg-quick@wg0


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;Step 5: Enable IP Forwarding&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To allow traffic to pass through the VPN, we need to enable IP forwarding with the following commands:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo sysctl -p


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Let me explain each setting:&lt;/p&gt;



&lt;ul&gt;
&lt;li&gt;The [Interface] section defines the server's network information, including the IP address of the wg0 interface that the WireGuard server will use, the network CIDR block (10.0.0.0/24), and the port the server will listen on for incoming connections (51820).&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;The SaveConfig option is set to true, so that the settings can be saved and retained after a system restart.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;The PrivateKey option is the private key for the WireGuard server, which is used for authentication and encryption of connections. It is important that this key is kept secure and not shared with anyone.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;The PostUp and PostDown options are the commands that will be executed after creating the wg0 interface and after removing it, respectively. These commands add and remove the necessary firewall rules to allow traffic to pass through the tunnel created by the VPN and to redirect traffic to the outgoing interface of the virtual machine.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Now let's turn on this wg0 interface, use the following command:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo wg-quick up wg0


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;strong&gt;2. Client WireGuard Configuration&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;At the client:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run the following commands:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo apt update


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo apt install wireguard


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Create the wireguard directory:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo mkdir /etc/wireguard/


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Generate the client's private and public keys:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ wg genkey | sudo tee /etc/wireguard/privatekey | wg pubkey | sudo tee /etc/wireguard/publickey


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Create and edit the wg0.conf file on the client:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo nano /etc/wireguard/wg0.conf


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Set the following settings:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

[Interface]
PrivateKey = privatekey_client
Address = 10.0.0.2/24

[Peer]
PublicKey = publickey_server
Endpoint = ipaddress_server:51820
AllowedIPs = 0.0.0.0/0


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03hqn09ek0mpdtb3y2hh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03hqn09ek0mpdtb3y2hh.png" alt="Image 06"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Caption: Setting up client wireguard file.&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Note: The file here is named as wg7, but could be wg0.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;






&lt;ul&gt;
&lt;li&gt;The [Interface] section defines the client's network information, including the IP address of the wg0 interface that the Wireguard client will use, i.e. 10.0.0.2/24 and the client's private key.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;In the peer configuration, you should point to the server's public key by replacing it in the PublicKey field. The endpoint would be the public IP address of your WireGuard server, along with the configured port. Lastly, specify the allowed network, which in this tutorial is set as 0.0.0.0/0, meaning that all your traffic will be routed through the WireGuard server.&lt;/li&gt;
&lt;/ul&gt;



&lt;ul&gt;
&lt;li&gt;Once this is done, you must now add your client's public key to your wireguard server, to do this, use the following command:&lt;/li&gt;
&lt;/ul&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo wg set wg0 peer clientpublickey allowed-ips 10.0.0.2


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Now bring up the wireguard tunnel as a client:&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ sudo wg-quick up wg0


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8tvoq2inv8hm5vp8k1fx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8tvoq2inv8hm5vp8k1fx.png" alt="Image 07"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Caption: Raising wireguard tunnel on client.&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;3. Tests&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To perform some initial tests, you should:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ping to the wireguard gateway server:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;At the client:&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

$ ping 10.0.0.1


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbwn70dcgnr6mvm8d7n7s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbwn70dcgnr6mvm8d7n7s.png" alt="Image 08"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Caption: Running a ping test to the gateway (server IP address).&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Make sure your public IP is the same as the machine on AWS or another cloud provider:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(&lt;a href="https://whatismyipaddress.com/" rel="noopener noreferrer"&gt;https://whatismyipaddress.com/&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzpx9ssc3tb4ub0mcu4af.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzpx9ssc3tb4ub0mcu4af.png" alt="Image 09"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Your IP address should be the same as the public IPv4 of your AWS machine (As the region I picked up the machine was in São Paulo, it got the address from there).&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;4. References&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://linuxize.com/post/how-to-set-up-wireguard-vpn-on-debian-10/" rel="noopener noreferrer"&gt;https://linuxize.com/post/how-to-set-up-wireguard-vpn-on-debian-10/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.cyberciti.biz/faq/debian-10-set-up-wireguard-vpn-server/" rel="noopener noreferrer"&gt;https://www.cyberciti.biz/faq/debian-10-set-up-wireguard-vpn-server/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.wireguard.com/" rel="noopener noreferrer"&gt;https://www.wireguard.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.expressvpn.com/pt/what-is-vpn" rel="noopener noreferrer"&gt;https://www.expressvpn.com/pt/what-is-vpn&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>wireguard</category>
      <category>network</category>
      <category>vpn</category>
    </item>
    <item>
      <title>Os primeiros passos com freeRouter</title>
      <dc:creator>Gabriel Tetzner Menegueti</dc:creator>
      <pubDate>Thu, 06 Oct 2022 16:20:57 +0000</pubDate>
      <link>https://dev.to/gabrieltetzner/os-primeiros-passos-com-freerouter-eni</link>
      <guid>https://dev.to/gabrieltetzner/os-primeiros-passos-com-freerouter-eni</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Sobre&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;freeRouter é definido como um roteador livre e grátis, também é um canivete suíço de rede, ele é desenvolvido para suportar protocolos de roteamento, cripto, encaminhamento, encapsulamento e túnel. freeRouter não trabalha com roteamento global, cada interface roteada deve estar em uma tabela de roteamento virtual.&lt;/p&gt;

&lt;h2&gt;
  
  
  Começo
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Requisitos
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Requisitos é ter um sistema operacional com o java instalado.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Instalação
&lt;/h3&gt;

&lt;p&gt;A maneira mais fácil de rodar o freeRouter é ele virtualizado em um jar.&lt;/p&gt;

&lt;p&gt;Porém existem outras maneiras, já que isso é necessário para os testes que só possam serem executados em um ambiente específico.&lt;/p&gt;

&lt;p&gt;As outras maneiras são:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rodando em uma VM.&lt;/li&gt;
&lt;li&gt;Rodando em uma VM na nuvem.&lt;/li&gt;
&lt;li&gt;Rodando em um equipamento físico.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Observações
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Neste tutorial, vamos rodar o freeRouter através de um jar, nos outros casos, a instalação ocorre através de um script de instalação, recomendo não fazer isso em sua máquina, pois o freeRouter toma conta da sua máquina e você perde seu sistema.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A maneira através do jar é segura também, já que estaremos isolando um ambiente da sua máquina, ou seja, emulado.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Rodando o freeRouter em um arquivo jar.
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Linux
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Instalando o java
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt-get install default-jre-headless --no-install-recommends

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  Baixando o arquivo .jar
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# wget freertr.org/rtr.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Agora vamos montar uma topologia linear com dois roteadores freeRouter rodando e configurando uma conexão entre duas interfaces ethernet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Topology
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5gc588b2ncuthrkz8jpb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5gc588b2ncuthrkz8jpb.png" alt="Image description" width="800" height="194"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Criando arquivos da configuração da topologia
&lt;/h3&gt;

&lt;h4&gt;
  
  
  R1-HW.txt
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo nano r1-hw.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int eth1 ethernet 0000.1111.0001 127.0.0.1 26011 127.0.0.1 26021
tcp2vrf 1123 v1 23
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Isto é necessário, para determinar que você terá uma interface ethernet1 do tipo Ethernet com um endereço físico definido, porém você acaba definindo esta configuração de uma maneira lógica, a outra parte é a ligação da sua interface via uma porta, ou seja, sua interface é ligada via sockets para uma outra ponta que será uma outra interface que você definir, no caso do nosso tutorial. O tcp2vrf vai fazer uma ligação entre uma porta da nossa máquina host para uma porta utilizada dentro do nosso roteador, nesse caso como estaremos utilizando o serviço de acesso via telnet, precisaremos dessa configuração para acessar via nossa rede local.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  R1-SW.txt
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo nano r1-sw.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hostname r1
buggy
!
logging file debug ../binTmp/zzz39r1-log.run
!
vrf definition v1
 exit
!
interface ethernet1
 vrf for v1
 ipv4 address 1.1.1.1 255.255.255.0
 no shutdown
 no log-link-change
 exit
!
!
server telnet tester
 security protocol telnet
 no exec authorization
 no login authentication
 vrf v1
 exit
!
!
end

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Aqui definimos várias configurações de software, primeiro o hostname que será o nome que ele vai atribuir ao seu roteador, a vrf, que vai criar uma tabela de roteamento separada para o nosso uso, a interface ethernet1 com as configurações de vrf forwarding definidas, o endereçamento IPv4 e que esta interface vai está ligada, e por último o server telnet para ter o acesso ao roteador.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  R2-HW.txt
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo nano r2-hw.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;int eth1 ethernet 0000.2222.0001 127.0.0.1 26021 127.0.0.1 26011
tcp2vrf 2223 v1 23
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  R2-SW.txt
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo nano r2-sw.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hostname r2
buggy
!
logging file debug ../binTmp/zzz39r1-log.run
!
vrf definition v1
 exit
!
interface ethernet1
 vrf for v1
 ipv4 address 1.1.1.2 255.255.255.0
 no shutdown
 no log-link-change
 exit
!
!
server telnet tester
 security protocol telnet
 no exec authorization
 no login authentication
 vrf v1
 exit
!
!
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Executando o freeRouter
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Execute os dois roteadores  na sua pasta das configurações
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ java -jar rtr.jar routersc r1-hw.txt r1-sw.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ java -jar rtr.jar routersc r2-hw.txt r2-sw.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;R1&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4nj0ss2l4m276gpq49gm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4nj0ss2l4m276gpq49gm.png" alt="Image description" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksv92fsdtcxuf493jg6j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fksv92fsdtcxuf493jg6j.png" alt="Image description" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;R2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fasp5k5ap1ciji403j2ub.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fasp5k5ap1ciji403j2ub.png" alt="Image description" width="800" height="433"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxcb0167wst8ipx70mfp0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxcb0167wst8ipx70mfp0.png" alt="Image description" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Acesso aos roteadores
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Mesmo com o acesso a partir da execução do jar, é possível acessar o freeRouter através de um telnet, lembrando que na configuração sw.txt, definimos um server telnet através da porta 23 mapeando para a nossa máquina a porta 1123 e 2223.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;R1&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ telnet 127.0.0.1 1123
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;R2
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ telnet 127.0.0.1 2223
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Teste de conectividade
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Faça um teste de conectividade simples entre as duas interfaces Ethernet:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;R1:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r1# ping 1.1.1.2 vrf v1 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;É esperado que seu ping funcione para a outra interface Ethernet:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pinging 1.1.1.2, src=null, vrf=v1, cnt=5, len=64, df=false, tim=1000, gap=0, ttl=255, tos=0, sgt=0, flow=0, fill=0, alrt=-1, sweep=false, multi=false
!!!!!
result=100.0%, recv/sent/lost/err=5/5/0/0, took 66, min/avg/max/dev rtt=0/1.2/4/2.1, ttl 255/255/255/0.0, tos 0/0.0/0/0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Obrigado pela sua atenção pessoal. Em breve teremos vídeos sobre os tipos de conexões e outras soluções que o freeRtr entrega, e explicando alguma dessas configurações.
&lt;/h3&gt;

&lt;h2&gt;
  
  
  Meus contatos
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Email&lt;/strong&gt;: &lt;a href="mailto:tetzdesen@gmail.com"&gt;tetzdesen@gmail.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Linkedin&lt;/strong&gt;: &lt;a href="https://www.linkedin.com/in/gabriel-tetzner/"&gt;https://www.linkedin.com/in/gabriel-tetzner/&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Github&lt;/strong&gt;: &lt;a href="https://github.com/Tetzdesen"&gt;https://github.com/Tetzdesen&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>freerouter</category>
      <category>network</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Capturando tráfego com tcpdump</title>
      <dc:creator>Gabriel Tetzner Menegueti</dc:creator>
      <pubDate>Thu, 11 Aug 2022 16:34:00 +0000</pubDate>
      <link>https://dev.to/gabrieltetzner/capturando-trafego-com-tcpdump-pji</link>
      <guid>https://dev.to/gabrieltetzner/capturando-trafego-com-tcpdump-pji</guid>
      <description>&lt;h2&gt;
  
  
  Sobre
&lt;/h2&gt;

&lt;p&gt;Tutorial desenvolvido para capturar tráfego de rede com a ferramenta tcpdump.&lt;/p&gt;

&lt;h2&gt;
  
  
  AVISO
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Não me responsabilizo pelo o uso desses tutoriais/estudos para fins malignos. Esses tutoriais/estudos são voltados para pessoas de interesse na área de Segurança da Informação e Perícia Forense Computacional.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Todos esses tutoriais/estudos foram testados em ambientes isolados por mim.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Lembrem-se de que usar essas informações para hackear ou invadir dispositivos alheios é CRIME previsto na &lt;a href="http://www.planalto.gov.br/ccivil_03/_ato2019-2022/2021/lei/L14155.htm"&gt;Lei 14.155/2021&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Ambientes usados
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Maquina Virtual Kali Linux (Atacante)&lt;/li&gt;
&lt;li&gt;Maquina Virtual com Windows (Alvo)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Instalação
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt update -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt install tcpdump -y
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Iniciando captura do tráfego
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Capturar pacotes de host específico
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo tcpdump -v host (ipaddress) -w captura.pcap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Capturar pacotes da rede específica
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo tcpdump -v net (networkaddress/mask) -w captura.pcap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ou
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ tcpdump captura.pcap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Teste
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo tcpdump -v host 192.168.15.143 -w capturas.pcap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Recomendação
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Visualizar com Wireshark ou programas com o mesmo proposito.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Imagens do tráfego capturado
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu8nf2as6jyeh5bdl8oo0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu8nf2as6jyeh5bdl8oo0.jpg" alt="Image description" width="800" height="246"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8hncnf4ofb3ptt8poh0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj8hncnf4ofb3ptt8poh0.jpg" alt="Image description" width="800" height="142"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>redes</category>
      <category>wireshark</category>
      <category>tcpdump</category>
    </item>
    <item>
      <title>Monitorando sua máquina com o Prometheus</title>
      <dc:creator>Gabriel Tetzner Menegueti</dc:creator>
      <pubDate>Tue, 03 May 2022 17:46:00 +0000</pubDate>
      <link>https://dev.to/gabrieltetzner/monitorando-sua-maquina-com-o-prometheus-1eo0</link>
      <guid>https://dev.to/gabrieltetzner/monitorando-sua-maquina-com-o-prometheus-1eo0</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Sobre&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Tutorial desenvolvido para o monitoramento de recursos de uma máquina, utilizando um exportador do prometheus (node exporter).&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Dependências e tecnologias&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fstatic%2Fv1%3Flabel%3DDOCKER%26message%3DDOCKER%26color%3Dblue%26style%3Dfor-the-badge%26logo%3DDOCKER" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fstatic%2Fv1%3Flabel%3DDOCKER%26message%3DDOCKER%26color%3Dblue%26style%3Dfor-the-badge%26logo%3DDOCKER" alt="Badge"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fstatic%2Fv1%3Flabel%3DPrometheus%26message%3DPrometheus%26color%3Dblue%26style%3Dfor-the-badge%26logo%3DPROMETHEUS" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fstatic%2Fv1%3Flabel%3DPrometheus%26message%3DPrometheus%26color%3Dblue%26style%3Dfor-the-badge%26logo%3DPROMETHEUS" alt="Badge"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fstatic%2Fv1%3Flabel%3DGrafana%26message%3DGrafana%26color%3Dblue%26style%3Dfor-the-badge%26logo%3DGRAFANA" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fstatic%2Fv1%3Flabel%3DGrafana%26message%3DGrafana%26color%3Dblue%26style%3Dfor-the-badge%26logo%3DGRAFANA" alt="Badge"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.docker.com/" rel="noopener noreferrer"&gt;Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/compose/" rel="noopener noreferrer"&gt;Docker-Compose&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://prometheus.io/" rel="noopener noreferrer"&gt;Prometheus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://grafana.com/" rel="noopener noreferrer"&gt;Grafana&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Configurações
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Atualize os repositórios&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt update
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Instale Docker e Docker-compose&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo apt install docker.io
$ sudo apt install docker-compose
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Crie um diretório do arquivo docker-compose&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo mkdir docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Crie o arquivo do docker-compose&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cd docker
$ touch docker-compose.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Abre o arquivo e cole a seguinte configuração&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;version: '3'
services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    ports:
    - 9090:9090
    command:
    - --config.file=/etc/prometheus/prometheus.yml
    volumes:
    - /etc/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
    restart: always

  grafana:
    image: grafana/grafana:latest
    container_name: grafana-server
    user: "1000"
    environment:
    - GF_SECURITY_ADMIN_PASSWORD=tutorial2022
    depends_on:
    - prometheus
    ports:
    - 3000:3000
    restart: always

  node-exporter:
    image: prom/node-exporter
    container_name: node-exporter
    restart: always
    ports: 
    - 9100:9100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Crie o diretório do arquivo de configuração Prometheus&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo mkdir /etc/prometheus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Depois crie o arquivo de configuração do Prometheus
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo touch /etc/prometheus/prometheus.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Abre o arquivo e cole a seguinte configuração&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;global:
    scrape_interval: 5s
    evaluation_interval: 5s
scrape_configs:
  - job_name: 'prometheus'
    scrape_interval: 5s
    static_configs:
         - targets: ['yourip:9090']
    metrics_path: "/metrics"

  - job_name: node-exporter
    scrape_interval: 5s
    static_configs:
         - targets: ['yourip:9100']
    metrics_path: "/metrics"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cheque seu IP
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ifconfig
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Com seu editor de texto preferido mude o IP na configuração do prometheus&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo nano /etc/prometheus/prometheus.yml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Levante os container's no diretório docker&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ sudo docker-compose up -d
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Cheque se Server Prometheus foi levantado
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Acesse &lt;a href="http://localhost:9090" rel="noopener noreferrer"&gt;http://localhost:9090&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Verifique os targets&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cheque se o Grafana Server foi levantado
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Acesse &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;Usuário: admin&lt;/li&gt;
&lt;li&gt;Senha: tutorial2022&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  Verificação
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Verificação Prometheus
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Coloque as configurações de seu endereço de servidor Prometheus.&lt;/li&gt;
&lt;li&gt;Endereço do servidor: &lt;a href="http://seuip:9090" rel="noopener noreferrer"&gt;http://seuip:9090&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Salve as configurações.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Verificação Grafana
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Acesse o dashboard do node exporter e faça o download
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://grafana.com/grafana/dashboards/1860" rel="noopener noreferrer"&gt;Node Dashboard&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Importe o Dashboard no Grafana&lt;/p&gt;


&lt;img alt="img-grafana 01" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FTetzdesen%2FMonitoramento-Com-Prometheus%2Fmain%2Fgrafana-img%2Fimg-01.png%3Ftoken%3DGHSAT0AAAAAABTRLL5ZYLYHRFV6CKZUUAL6YTQSCBQ"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Verifique o Dashboard&lt;/p&gt;


&lt;img alt="img-grafana 02" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2FTetzdesen%2FMonitoramento-Com-Prometheus%2Fmain%2Fgrafana-img%2Fimg-02.png%3Ftoken%3DGHSAT0AAAAAABTRLL5YQQM6GFOF6RKK4JDYYTQSC2Q"&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>prometheus</category>
      <category>docker</category>
    </item>
  </channel>
</rss>
