<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Vibek Dutta on Medium]]></title>
        <description><![CDATA[Stories by Vibek Dutta on Medium]]></description>
        <link>https://medium.com/@VibekD1996?source=rss-2ed24239d477------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HnOqFPJ-j3TIfMawuBNFpA.jpeg</url>
            <title>Stories by Vibek Dutta on Medium</title>
            <link>https://medium.com/@VibekD1996?source=rss-2ed24239d477------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 01:34:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@VibekD1996/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ Netbird & Networking Fundamentals — A Complete Practical Guide]]></title>
            <link>https://medium.com/@VibekD1996/netbird-networking-fundamentals-a-complete-practical-guide-47e8ca84dd38?source=rss-2ed24239d477------2</link>
            <guid isPermaLink="false">https://medium.com/p/47e8ca84dd38</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[vpn]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[bird-net]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Vibek Dutta]]></dc:creator>
            <pubDate>Sat, 13 Jun 2026 13:57:01 GMT</pubDate>
            <atom:updated>2026-06-13T13:57:01.330Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong><em>Goal:</em></strong><em> Understand Netbird, networking concepts, and how to build VPN mesh networks with confidence.</em></blockquote><h3>📚 TABLE OF CONTENTS</h3><ol><li>Networking Foundations (The “Why”)</li><li>Traditional VPN vs. Netbird (The “What”)</li><li>How Netbird Works (The “How”)</li><li>Hands-On: Installing &amp; Using Netbird</li><li>Connecting to Your Project</li><li>Quick Reference Cheat Sheet</li></ol><h3>PHASE 1: Networking Foundations</h3><p>Before Netbird makes sense, you need to understand the building blocks. This guide uses <strong>real-world analogies</strong> and <strong>dry-run examples</strong> you can actually try.</p><h3>🔹 1.1 IP Address — “Who Are You?”</h3><p><strong>Analogy:</strong> Your home address. Without it, mail can’t reach you.</p><p><strong>Dry Run:</strong></p><pre># Check YOUR IP address<br>ip addr show<br># or<br>ifconfig<br># or — just the IPs, no noise<br>hostname -I</pre><pre># Example output:<br># eth0: inet 192.168.1.50/24</pre><p><strong>What this means:</strong></p><ul><li>192.168.1.50 = Your device&#39;s unique address on the local network</li><li>/24 = Subnet mask (explained next)</li></ul><p><strong>Types of IPs:</strong></p><p>TypeExamplePurposePrivate IP192.168.x.x, 10.x.x.x, 172.16-31.x.xInternal network only (RFC 1918)Public IP203.0.113.45Visible on the internetLoopback127.0.0.1Talk to yourself (localhost)CGNAT range100.64.0.0/10Carrier-grade NAT — <strong>this is what Netbird borrows for its mesh IPs!</strong></p><p><strong>More practical examples you can run right now:</strong></p><pre># 1. Talk to yourself — works even with no network cable<br>ping -c 2 127.0.0.1</pre><pre># 2. Find which IP a domain resolves to<br>dig +short google.com<br># 142.250.80.46</pre><pre># 3. Find YOUR public IP (what the world sees)<br>curl ifconfig.me</pre><pre># 4. See which interface would be used to reach a destination<br>ip route get 8.8.8.8<br># 8.8.8.8 via 192.168.1.1 dev eth0 src 192.168.1.50<br>#                                  ^^^^^^^^^^^^^^^^<br>#                                  &quot;I will leave from this IP&quot;</pre><p><strong>Practical exercise — count your devices:</strong></p><pre># Scan your LAN to see every device with an IP (requires nmap)<br>sudo nmap -sn 192.168.1.0/24</pre><pre># Example output:<br># Nmap scan report for 192.168.1.1   (router)<br># Nmap scan report for 192.168.1.10  (printer)<br># Nmap scan report for 192.168.1.50  (your laptop)<br># Nmap scan report for 192.168.1.51  (your phone)</pre><h3>🔹 1.2 Subnet — “Your Neighborhood”</h3><p><strong>Analogy:</strong> Your apartment building. Everyone in the building can knock on each other’s door without going outside.</p><p><strong>Dry Run:</strong></p><pre># See your subnet<br>ip route show</pre><pre># Example output:<br># 192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.50</pre><p><strong>Breaking down </strong><strong>192.168.1.0/24:</strong></p><pre>IP:     192.168.1.0<br>Mask:   /24 = 255.255.255.0</pre><pre>Binary breakdown:<br>192.168.1. = Network portion (fixed, first 24 bits)<br>.0-.255    = Host portion (available for devices)</pre><pre>Available IPs: 192.168.1.1 to 192.168.1.254<br>(.0 = network address, .255 = broadcast — both reserved)</pre><p><strong>CIDR sizes you’ll actually encounter:</strong></p><p>CIDRSubnet MaskUsable HostsTypical Use/32255.255.255.2551A single host (firewall rules, routes)/30255.255.255.2522Point-to-point links between routers/24255.255.255.0254Home / small office LAN/16255.255.0.065,534Large org network, <strong>Netbird mesh (100.64.0.0/16)</strong>/8255.0.0.0~16.7MEntire 10.0.0.0/8 private space</p><p><strong>Practical exercise — do the subnet math:</strong></p><pre># Install ipcalc and let it do the math for you<br>sudo apt install ipcalc<br>ipcalc 192.168.1.50/24</pre><pre># Output:<br># Network:   192.168.1.0/24<br># HostMin:   192.168.1.1<br># HostMax:   192.168.1.254<br># Broadcast: 192.168.1.255<br># Hosts/Net: 254</pre><pre># Try a trickier one — is 10.0.32.100 in the same subnet as 10.0.33.5?<br>ipcalc 10.0.32.100/24      # Network: 10.0.32.0/24 → NO, .33.x is outside<br>ipcalc 10.0.32.100/16      # Network: 10.0.0.0/16  → YES, both inside</pre><blockquote><em>⚠️ </em><strong><em>Common real-world bug:</em></strong><em> two machines have IPs </em><em>10.0.32.100/24 and </em><em>10.0.33.5/24 and &quot;can&#39;t ping each other&quot; even though they&#39;re plugged into the same switch. They&#39;re in </em>different<em> /24 subnets — either fix the mask to </em><em>/16 or add a router between them. This exact class of bug is why static-route scripts (like the BX50 validation scripts) are fragile.</em></blockquote><p><strong>Practical Example:</strong></p><pre>Your Laptop:     192.168.1.50<br>Your Phone:      192.168.1.51<br>Your Printer:    192.168.1.10<br>Your Router:     192.168.1.1</pre><pre>All in the SAME subnet → can talk directly (via ARP + the switch)</pre><p><strong>What if they’re in DIFFERENT subnets?</strong></p><pre>Your Laptop:     192.168.1.50<br>Office Server:   10.0.0.25</pre><pre>Different subnets → NEED a router/gateway to talk</pre><pre># Prove it: watch ARP for same-subnet, and the gateway for cross-subnet<br>ip neigh show<br># 192.168.1.1  dev eth0 lladdr aa:bb:cc:dd:ee:ff REACHABLE   ← gateway MAC<br># 192.168.1.10 dev eth0 lladdr 11:22:33:44:55:66 REACHABLE   ← printer, direct</pre><pre># Same subnet → kernel ARPs for the device itself<br># Different subnet → kernel sends the frame to the GATEWAY&#39;s MAC instead</pre><h3>🔹 1.3 Gateway — “The Doorman”</h3><p><strong>Analogy:</strong> The doorman at your apartment building. If you want to visit someone in another building, the doorman directs you.</p><p><strong>Dry Run:</strong></p><pre># See your default gateway<br>ip route | grep default</pre><pre># Example output:<br># default via 192.168.1.1 dev eth0</pre><p><strong>What happens when you ping a different subnet:</strong></p><pre>You (192.168.1.50) want to reach Server (10.0.0.25)</pre><pre>1. You check: Is 10.0.0.25 in my subnet (192.168.1.0/24)? NO<br>2. You send the packet to your Gateway (192.168.1.1)<br>3. Gateway forwards it toward the destination<br>4. Response comes back the same way</pre><p><strong>Practical exercise — watch every hop with traceroute:</strong></p><pre>traceroute 8.8.8.8<br># 1  192.168.1.1      1.2 ms   ← your gateway (first hop, always)<br># 2  100.72.16.1      8.4 ms   ← your ISP (note: CGNAT range!)<br># 3  72.14.204.99    15.1 ms   ← ISP backbone<br># ...<br># 9  8.8.8.8         22.7 ms   ← Google DNS</pre><pre># Each line = one router your packet passed through.<br># Later, traceroute to a Netbird peer shows ONE hop — the tunnel hides the path:<br># traceroute 100.64.0.4<br># 1  100.64.0.4  35 ms        ← looks directly connected!</pre><p><strong>Practical exercise — break and fix your routing (in a VM!):</strong></p><pre># Delete the default route — internet dies instantly<br>sudo ip route del default</pre><pre>ping -c1 8.8.8.8<br># connect: Network is unreachable   ← no doorman, no way out</pre><pre># Add it back<br>sudo ip route add default via 192.168.1.1 dev eth0<br>ping -c1 8.8.8.8   # works again</pre><blockquote><em>This is exactly what the BX50 </em><em>disable_networking() function does with<br></em><em>route del default gw 10.0.32.1 wlan0 — it fires the doorman so the kiosk<br>can&#39;t reach anything outside its own subnet.</em></blockquote><h3>🔹 1.4 WAN (Wide Area Network) — “The Highway”</h3><p><strong>Analogy:</strong> The highway system connecting cities. Your local roads (LAN) connect to highways (WAN) via on-ramps (routers/gateways).</p><pre>┌─────────────────┐         ┌─────────────────┐<br>│   YOUR HOME     │         │   OFFICE        │<br>│                 │         │                 │<br>│  Laptop .50     │         │  Server .25     │<br>│  Phone  .51     │         │  Printer .30    │<br>│       │         │         │       │         │<br>│   ┌───┴───┐     │         │   ┌───┴───┐     │<br>│   │Router │─────┼─WAN─────┼───│Router │     │<br>│   │.1     │     │         │   │.1     │     │<br>│   └───┬───┘     │         │   └───┬───┘     │<br>│  192.168.1.0/24 │         │  10.0.0.0/24    │<br>└─────────────────┘         └─────────────────┘</pre><p><strong>Without a VPN:</strong> These two networks can’t talk directly. They’re on different highways with no connecting road.</p><p><strong>Prove it to yourself:</strong></p><pre># From home, try to ping the office server&#39;s PRIVATE IP<br>ping -c 2 10.0.0.25<br># Destination Host Unreachable (or 100% packet loss)<br>#<br># Why? Private IPs are NOT routable on the internet.<br># Your ISP&#39;s routers literally drop packets destined for 10.x/192.168.x.</pre><h3>🔹 1.5 Firewall — “The Security Guard”</h3><p><strong>Analogy:</strong> A security guard with a checklist. Every packet (visitor) gets checked against rules.</p><p><strong>Dry Run:</strong></p><pre># See firewall rules (iptables)<br>sudo iptables -L -v -n</pre><pre># See firewall rules (ufw - simpler)<br>sudo ufw status verbose</pre><pre># Example output:<br># To                         Action      From<br># --                         ------      ----<br># 22/tcp                     ALLOW       Anywhere      # SSH<br># 80/tcp                     ALLOW       Anywhere      # HTTP<br># 443/tcp                    ALLOW       Anywhere      # HTTPS</pre><p><strong>How a firewall thinks:</strong></p><pre>Packet arrives: &quot;Hi, I&#39;m from 203.0.113.45, going to port 22&quot;</pre><pre>Firewall checks rules:<br>  Rule 1: ALLOW port 22 from ANYWHERE? → YES → LET IT PASS</pre><pre>Packet arrives: &quot;Hi, I&#39;m from 203.0.113.45, going to port 3306 (MySQL)&quot;</pre><pre>Firewall checks rules:<br>  Rule 1: ALLOW port 3306? → NO<br>  Rule 2: DENY all others? → YES → DROP PACKET</pre><p><strong>Default policies matter:</strong></p><ul><li>ACCEPT everything except what&#39;s blocked = Permissive</li><li>DROP everything except what&#39;s allowed = Secure (recommended)</li></ul><p><strong>Practical exercise — write real rules:</strong></p><pre># Allow SSH only from your office subnet, nothing else<br>sudo ufw default deny incoming<br>sudo ufw default allow outgoing<br>sudo ufw allow from 10.0.32.0/24 to any port 22 proto tcp<br>sudo ufw enable</pre><pre># Allow your AAS API port only over the Netbird interface<br>sudo ufw allow in on wt0 to any port 8080 proto tcp<br># → API is reachable from mesh peers, INVISIBLE from the public internet</pre><p><strong>Practical exercise — experience a firewall block from both sides:</strong></p><pre># Terminal 1 (server): start a listener on port 9000<br>python3 -m http.server 9000</pre><pre># Terminal 2 (another machine): it works<br>curl <a href="http://192.168.1.50:9000/">http://192.168.1.50:9000</a>     # → directory listing</pre><pre># Terminal 1: now block it<br>sudo ufw deny 9000/tcp</pre><pre># Terminal 2: try again<br>curl <a href="http://192.168.1.50:9000/">http://192.168.1.50:9000</a><br># curl: (28) Connection timed out      ← DROP: silently eaten (guard says nothing)<br># vs.<br># curl: (7) Connection refused         ← REJECT or nothing listening (guard says &quot;no&quot;)</pre><blockquote><em>💡 </em><strong><em>Debugging gold:</em></strong><em> </em><em>timeout usually means a firewall is DROPping you;<br></em><em>connection refused means you reached the host but nothing is listening<br>(or the firewall REJECTed). Knowing the difference cuts debugging time in half.</em></blockquote><p><strong>Check what’s actually listening before blaming the firewall:</strong></p><pre>ss -tulpn<br># Netid State  Local Address:Port  Process<br># tcp   LISTEN 0.0.0.0:22          sshd        ← listening on ALL interfaces<br># tcp   LISTEN 127.0.0.1:3306      mysqld      ← localhost ONLY — unreachable<br>#                                                 remotely no matter what the<br>#                                                 firewall says!</pre><h3>🔹 1.6 NAT (Network Address Translation) — “The Mail Forwarding Service”</h3><p><strong>Analogy:</strong> You live in an apartment building with one main address. The mailroom forwards mail to individual apartments.</p><p><strong>Why NAT exists:</strong></p><ul><li>IPv4 has ~4.3 billion addresses — not enough for every device</li><li>Your ISP gives you ONE public IP</li><li>Your router uses NAT to let 50 devices share that one IP</li></ul><p><strong>Dry Run — See NAT in action:</strong></p><pre># See your public IP (what the internet sees)<br>curl ifconfig.me<br># Returns: 203.0.113.45 (your router&#39;s public IP)</pre><pre># See your private IP (what your network sees)<br>ip addr show eth0<br># Returns: 192.168.1.50</pre><pre># They&#39;re DIFFERENT → you are behind NAT. (If they match, you have a<br># public IP directly — common on cloud VMs.)</pre><p><strong>How NAT works:</strong></p><pre>Your Laptop (192.168.1.50) wants to visit google.com</pre><pre>1. Laptop sends packet: &quot;From 192.168.1.50:54321 → To 142.250.80.46:443&quot;<br>2. Router sees: &quot;This is a private IP, I need to translate it&quot;<br>3. Router rewrites: &quot;From 203.0.113.45:54321 → To 142.250.80.46:443&quot;<br>4. Google responds to 203.0.113.45:54321<br>5. Router remembers: &quot;Port 54321 belongs to 192.168.1.50&quot;<br>6. Router forwards response to your laptop</pre><p><strong>Watch the translation table live (on a Linux router):</strong></p><pre>sudo conntrack -L | head -5<br># tcp 6 431999 ESTABLISHED<br>#   src=192.168.1.50 dst=142.250.80.46 sport=54321 dport=443      ← inside view<br>#   src=142.250.80.46 dst=203.0.113.45 sport=443 dport=54321      ← outside view<br>#<br># One line per connection — this IS the NAT table.</pre><p><strong>The PROBLEM with NAT for VPNs:</strong></p><pre>You want to SSH into your home laptop from a coffee shop.</pre><pre>Coffee Shop → Internet → Your Router (203.0.113.45) → ???</pre><pre>Your router gets the packet but:<br>- &quot;Which device inside should get this?&quot;<br>- NAT table only tracks OUTGOING connections<br>- INCOMING connections get dropped (security feature!)</pre><pre>SOLUTION: Port forwarding OR VPN</pre><p><strong>Practical comparison — port forwarding vs. mesh VPN:</strong></p><pre>PORT FORWARDING (the old fix):<br>  Router config: &quot;external port 2222 → 192.168.1.50:22&quot;<br>  ssh -p 2222 you@203.0.113.45</pre><pre>  Downsides:<br>  - One rule per service per device (gets messy fast)<br>  - Your SSH is now exposed to the ENTIRE internet (bots scan port 2222 too)<br>  - Breaks when your ISP changes your public IP<br>  - Impossible if your ISP uses CGNAT (you don&#39;t control the outer NAT!)</pre><pre>NETBIRD (the modern fix):<br>  ssh you@100.64.0.2</pre><pre>  - Zero router config<br>  - Nothing exposed publicly<br>  - Survives IP changes and works behind CGNAT</pre><p><strong>NAT strictness levels (this decides P2P success):</strong></p><p>NAT TypeBehaviorP2P Hole PunchingFull ConeSame external port for everyone, accepts from anyone✅ EasyRestricted ConeSame port, but only accepts from IPs you contacted✅ WorksPort RestrictedSame port, only from exact IP:port you contacted✅ Usually worksSymmetric<strong>Different external port per destination</strong>❌ Fails → TURN relay</p><pre># Discover your NAT type<br>sudo apt install stun-client<br>stun stun.l.google.com<br># &quot;Independent Mapping, Independent Filter&quot;  → cone NAT, P2P will work<br># &quot;Dependent Mapping&quot;                        → symmetric NAT, expect Relayed</pre><h3>🔹 1.7 Peer-to-Peer (P2P) — “Calling Your Friend Directly”</h3><p><strong>Analogy:</strong> Calling your friend on the phone. You talk directly — no operator in the middle.</p><p><strong>vs. Client-Server:</strong></p><pre>CLIENT-SERVER (like visiting a website):<br>  You → Internet → Google Server → Internet → You</pre><pre>PEER-TO-PEER (like a phone call):<br>  You ←────────────────────────────→ Your Friend<br>       Direct connection, no middleman</pre><p><strong>Feel the difference yourself (two machines on one LAN):</strong></p><pre># Machine A (192.168.1.50): become a &quot;server&quot; for 60 seconds<br>python3 -m http.server 8000</pre><pre># Machine B: connect as a &quot;client&quot;<br>curl <a href="http://192.168.1.50:8000/">http://192.168.1.50:8000</a>        # works — A chose to listen, B chose to call</pre><pre># Now reverse it WITHOUT touching machine A:<br># Machine B: python3 -m http.server 8000<br># Machine A: curl <a href="http://192.168.1.51:8000/">http://192.168.1.51:8000</a>   # also works<br>#<br># On a LAN, every device can be both client AND server.<br># P2P VPNs like Netbird recreate this freedom across the internet.</pre><p><strong>Why P2P is hard on the internet:</strong></p><pre>Your Laptop (Home)                    Your Friend&#39;s Laptop (Office)<br>192.168.1.50                          10.0.0.25<br>    │                                      │<br>    ▼                                      ▼<br>Router (NAT)                        Router (NAT)<br>203.0.113.45                        198.51.100.20</pre><pre>Problem: Both are behind NAT! They can&#39;t reach each other directly.<br>They only know their PRIVATE IPs, not how to reach each other through<br>the public internet.</pre><p><strong>This is the EXACT problem Netbird solves.</strong></p><h3>PHASE 2: Traditional VPN vs. Netbird</h3><h3>🔹 2.1 Traditional VPN (Hub-and-Spoke)</h3><p><strong>Analogy:</strong> Everyone drives to a central post office to exchange mail.</p><pre>┌─────────────┐<br>                    │   VPN       │<br>                    │  SERVER     │<br>                    │  (Hub)      │<br>                    │ 10.8.0.1    │<br>                    └──────┬──────┘<br>                           │<br>           ┌───────────────┼───────────────┐<br>           │               │               │<br>           ▼               ▼               ▼<br>      ┌─────────┐    ┌─────────┐    ┌─────────┐<br>      │ Laptop  │    │  Phone  │    │  Server │<br>      │10.8.0.2 │    │10.8.0.3 │    │10.8.0.4 │<br>      └─────────┘    └─────────┘    └─────────┘</pre><pre>Traffic flow: Laptop → VPN Server → Server<br>              (Even if Laptop and Server are in the same city!)</pre><p><strong>Problems:</strong></p><ol><li><strong>Slow:</strong> All traffic goes through the central server</li><li><strong>Bottleneck:</strong> Server gets overwhelmed</li><li><strong>Single point of failure:</strong> Server dies = no VPN</li><li><strong>Complex setup:</strong> Certificates, configs, key management</li></ol><p><strong>Real numbers — why the hub hurts:</strong></p><pre>Scenario: Laptop in Mumbai, Server in Mumbai, VPN hub in Frankfurt.</pre><pre>Direct path:        Mumbai → Mumbai            ~2 ms<br>Hub-and-spoke path: Mumbai → Frankfurt → Mumbai ~250 ms  (125x slower!)</pre><pre>And bandwidth: a 100 Mbps hub serving 50 devices = ~2 Mbps each<br>under load. With mesh P2P, each pair gets their full link speed.</pre><h3>🔹 2.2 Netbird (Mesh Network)</h3><p><strong>Analogy:</strong> A group chat where everyone can DM each other directly.</p><pre>┌──────────┐<br>         │  Laptop  │◄───────────────────┐<br>         │100.64.0.2│                     │<br>         └────┬─────┘                     │<br>              │                           │<br>              │    Direct P2P             │<br>              │    when possible          │<br>              │                           │<br>    ┌─────────┼─────────┐                 │<br>    │         │         │                 │<br>    ▼         ▼         ▼                 │<br>┌──────────┐ ┌──────────┐ ┌──────────┐    │<br>│  Phone   │◄┤  Relay   ├►│  Server  │    │<br>│100.64.0.3│ │(fallback)│ │100.64.0.4│    │<br>└──────────┘ └──────────┘ └────┬─────┘    │<br>                               │          │<br>                               └──────────┘<br>                               (Direct P2P)</pre><p><strong>Netbird’s Magic:</strong></p><ol><li><strong>Direct P2P when possible</strong> — fast, no bottleneck</li><li><strong>Automatic relay fallback</strong> — works even behind strict firewalls</li><li><strong>Zero config</strong> — install, login, done</li><li><strong>WireGuard encryption</strong> — modern, fast, secure</li></ol><blockquote><em>💡 </em><strong><em>Important distinction:</em></strong><em> Netbird’s Management Server only handles<br></em>coordination<em> (who’s in the network, keys, ACLs). Your actual </em><strong><em>data never<br>touches it</em></strong><em>. Even if the management server goes down, established P2P<br>tunnels keep working — only new peers can’t join until it’s back.</em></blockquote><h3>🔹 2.3 The Technologies Behind Netbird</h3><p>TechnologyWhat It DoesAnalogy<strong>WireGuard</strong>Encrypts traffic between peersSealed envelope<strong>STUN</strong>Discovers your public IP/port”What’s my address?”<strong>ICE</strong>Tries multiple connection methodsTrying front door, back door, window<strong>TURN</strong>Relays traffic when P2P failsUsing a messenger when you can’t meet<strong>NAT Traversal</strong>Punches holes through routersNegotiating with doormen</p><p><strong>Same stack, familiar faces:</strong> this is the <em>exact</em> technology combo behind<br>WhatsApp/Zoom calls (ICE/STUN/TURN for connecting two phones behind NAT) and<br>Tailscale (WireGuard mesh). Netbird is the open-source, self-hostable take.</p><h3>PHASE 3: How Netbird Works — Deep Dive with Dry Run</h3><h3>🎯 Scenario: Connect 3 Devices</h3><pre>┌─────────────────────────────────────────────────────────────┐<br>│  DEVICE A: Your Laptop (Home)                               │<br>│  Private IP: 192.168.1.50                                   │<br>│  Public IP: 203.0.113.45 (behind home router)               │<br>│                                                             │<br>│  DEVICE B: AWS Server (Cloud)                               │<br>│  Public IP: 54.123.45.67 (directly on internet)             │<br>│                                                             │<br>│  DEVICE C: Raspberry Pi (Factory - like your BX50)          │<br>│  Private IP: 10.0.32.100                                    │<br>│  Public IP: 198.51.100.20 (behind factory firewall)         │<br>└─────────────────────────────────────────────────────────────┘</pre><p><strong>Goal:</strong> All 3 devices should talk to each other as if on the same LAN.</p><h3>Step 1: Install Netbird on All Devices</h3><p><strong>Device A (Your Laptop):</strong></p><pre># Linux<br>curl -fsSL https://pkgs.netbird.io/install.sh | sh</pre><pre># macOS<br>brew install netbirdio/tap/netbird</pre><pre># Windows<br># Download from <a href="https://netbird.io/">https://netbird.io/</a></pre><p><strong>Device B (AWS Server):</strong></p><pre>curl -fsSL https://pkgs.netbird.io/install.sh | sh</pre><p><strong>Device C (Raspberry Pi):</strong></p><pre>curl -fsSL https://pkgs.netbird.io/install.sh | sh</pre><h3>Step 2: Login &amp; Join the Network</h3><p><strong>On each device:</strong></p><pre>sudo netbird up</pre><p><strong>What happens behind the scenes:</strong></p><pre>1. Netbird client starts<br>2. Generates a WireGuard key pair (public + private)<br>3. Opens browser for OAuth login (or uses setup key)<br>4. Registers with Netbird Management Server:</pre><pre>   &quot;Hi, I&#39;m Device A!<br>    My public WireGuard key: abc123...<br>    My public IP (from STUN): 203.0.113.45:51234<br>    My OS: Linux<br>    Please add me to network &#39;my-network&#39;&quot;</pre><pre>5. Management Server responds:</pre><pre>   &quot;Welcome! Your Netbird IP is: 100.64.0.2<br>    Here are the other peers in your network:<br>    - Device B: 100.64.0.3, public key: xyz789...<br>    - Device C: 100.64.0.4, public key: def456...&quot;</pre><p><strong>Verify what just happened on your machine:</strong></p><pre># A new network interface appeared<br>ip addr show wt0<br># wt0: inet 100.64.0.2/16</pre><pre># The WireGuard config Netbird built for you (keys, peers, endpoints)<br>sudo wg show<br># interface: wt0<br>#   public key: abc123...<br>#   listening port: 51820<br># peer: xyz789...                       ← Device B<br>#   endpoint: 54.123.45.67:51820<br>#   allowed ips: 100.64.0.3/32<br>#   latest handshake: 12 seconds ago    ← tunnel is ALIVE<br>#   transfer: 1.2 MiB received, 800 KiB sent</pre><pre># Routes Netbird added automatically<br>ip route show | grep wt0<br># 100.64.0.0/16 dev wt0</pre><h3>Step 3: Peer Discovery &amp; NAT Traversal (The Magic)</h3><p><strong>Device A wants to talk to Device C (Raspberry Pi behind factory firewall):</strong></p><pre>┌──────────────────────────────────────────────────────────────┐<br>│  PHASE 1: STUN - &quot;What&#39;s my public address?&quot;                 │<br>├──────────────────────────────────────────────────────────────┤<br>│                                                              │<br>│  Device A ──► STUN Server (stun.netbird.io)                  │<br>│  &quot;What&#39;s my public IP and port?&quot;                             │<br>│                                                              │<br>│  STUN Server responds:                                       │<br>│  &quot;Your public address is 203.0.113.45:51234&quot;                 │<br>│                                                              │<br>│  Device A tells Management Server:                           │<br>│  &quot;My public endpoint is 203.0.113.45:51234&quot;                  │<br>│                                                              │<br>└──────────────────────────────────────────────────────────────┘</pre><pre>┌──────────────────────────────────────────────────────────────┐<br>│  PHASE 2: ICE - &quot;Let&#39;s try to connect directly&quot;              │<br>├──────────────────────────────────────────────────────────────┤<br>│                                                              │<br>│  Device A knows:                                             │<br>│  - Device C&#39;s public key: def456...                          │<br>│  - Device C&#39;s public endpoint: 198.51.100.20:62345           │<br>│  - Device C&#39;s Netbird IP: 100.64.0.4                         │<br>│                                                              │<br>│  Device A sends UDP packet to 198.51.100.20:62345            │<br>│  &quot;Hi Device C, this is Device A, let&#39;s establish WireGuard&quot;  │<br>│                                                              │<br>│  Device C&#39;s firewall: &quot;Hmm, this is unsolicited...&quot;          │<br>│  Device C ALSO sends UDP packet to 203.0.113.45:51234        │<br>│  &quot;Hi Device A, this is Device C, let&#39;s establish WireGuard&quot;  │<br>│                                                              │<br>│  Device A&#39;s firewall: &quot;Hmm, this is unsolicited...&quot;          │<br>│                                                              │<br>│  BUT! Both firewalls see OUTGOING UDP to those addresses!    │<br>│  When the response comes back, firewall allows it!           │<br>│  ┌──────────────────────────────────────────────────────┐    │<br>│  │  THIS IS NAT HOLE PUNCHING!                          │    │<br>│  │  Both sides send packets OUT, creating a &quot;hole&quot;      │    │<br>│  │  in their firewalls for return traffic.              │    │<br>│  └──────────────────────────────────────────────────────┘    │<br>│                                                              │<br>│  Result: Direct P2P connection established! 🎉               │<br>│                                                              │<br>└──────────────────────────────────────────────────────────────┘</pre><p><strong>See ICE candidates in real Netbird output:</strong></p><pre>sudo netbird status -d<br># peer: raspberry-pi.netbird.cloud<br>#   ICE candidate (Local): srflx        ← &quot;server reflexive&quot; = my STUN-discovered<br>#   ICE candidate (Remote): srflx          public address was used</pre><pre># Candidate types decoded:<br>#   host  = my actual local IP worked (same LAN, or public IP)  — best<br>#   srflx = STUN-discovered address worked (hole punch)          — great<br>#   relay = TURN relay needed                                    — fallback</pre><h3>Step 4: When P2P Fails — Relay (TURN)</h3><p><strong>Scenario: Factory has a STRICT firewall (symmetric NAT)</strong></p><pre>┌──────────────────────────────────────────────────────────────┐<br>│  STRICT FIREWALL SCENARIO                                    │<br>├──────────────────────────────────────────────────────────────┤<br>│                                                              │<br>│  Device C&#39;s factory firewall is &quot;symmetric NAT&quot;:             │<br>│  - Different public port for EVERY destination               │<br>│  - Only allows responses from the EXACT destination          │<br>│                                                              │<br>│  Device C → STUN Server: uses port 62345                     │<br>│  Device C → Device A: would need port 62346 (different!)     │<br>│                                                              │<br>│  Device A sends to 198.51.100.20:62345                       │<br>│  But Device C&#39;s firewall expects traffic on 62346!           │<br>│  → P2P FAILS ❌                                              │<br>│                                                              │<br>│  ┌──────────────────────────────────────────────────────┐    │<br>│  │  FALLBACK: TURN Relay Server                         │    │<br>│  │                                                      │    │<br>│  │  Device A ──► TURN Relay ◄─── Device C               │    │<br>│  │                                                      │    │<br>│  │  Both connect OUT to the relay (firewall allows)     │    │<br>│  │  Relay forwards traffic between them                 │    │<br>│  │  Slower, but it WORKS! ✅                            │    │<br>│  └──────────────────────────────────────────────────────┘    │<br>│                                                              │<br>└──────────────────────────────────────────────────────────────┘</pre><p><strong>Measure the difference yourself:</strong></p><pre># Latency to a P2P peer vs a Relayed peer<br>ping -c 5 100.64.0.3    # P2P peer:     avg ~15 ms<br>ping -c 5 100.64.0.4    # Relayed peer: avg ~80 ms (round-trips via relay)</pre><pre># Throughput test (install iperf3 on both peers)<br># On peer:    iperf3 -s<br># On laptop:  iperf3 -c 100.64.0.3<br># P2P:     ~300-900 Mbps (limited by your actual link)<br># Relayed: often 10-50 Mbps (limited by relay capacity)<br>#<br># Rule of thumb: Relayed is fine for SSH/API calls,<br># painful for file sync/video.</pre><h3>Step 5: WireGuard Encryption</h3><p><strong>Once connected (P2P or Relay), all traffic is encrypted:</strong></p><pre>┌──────────────────────────────────────────────────────────────┐<br>│  WIREGUARD ENCRYPTION                                        │<br>├──────────────────────────────────────────────────────────────┤<br>│                                                              │<br>│  Before WireGuard (plain text):                              │<br>│  ┌─────────────────────────────────────┐                     │<br>│  │  SSH packet:                        │                     │<br>│  │  From: 192.168.1.50                 │                     │<br>│  │  To: 10.0.32.100                    │                     │<br>│  │  Data: &quot;ssh user@server&quot;            │                     │<br>│  └─────────────────────────────────────┘                     │<br>│                                                              │<br>│  After WireGuard (encrypted):                                │<br>│  ┌─────────────────────────────────────┐                     │<br>│  │  UDP packet:                        │                     │<br>│  │  From: 203.0.113.45:51234           │                     │<br>│  │  To: 198.51.100.20:62345            │                     │<br>│  │  Data: &quot;🔒[encrypted gibberish]&quot;    │                     │<br>│  └─────────────────────────────────────┘                     │<br>│                                                              │<br>│  Even if someone intercepts the packet:                      │<br>│  - They see UDP traffic between two IPs                      │<br>│  - They CANNOT see:                                          │<br>│    * That it&#39;s SSH                                           │<br>│    * The actual content                                      │<br>│    * The original source/destination IPs                     │<br>│                                                              │<br>│  WireGuard uses:                                             │<br>│  - Curve25519 for key exchange                               │<br>│  - ChaCha20 for encryption                                   │<br>│  - Poly1305 for authentication                               │<br>│  (Same crypto as TLS 1.3, but simpler &amp; faster)              │<br>│                                                              │<br>└──────────────────────────────────────────────────────────────┘</pre><p><strong>Prove the encryption with tcpdump:</strong></p><pre># Terminal 1: watch the PHYSICAL interface (what the internet sees)<br>sudo tcpdump -i eth0 -X udp port 51820 | head -20<br># ...payload is pure binary noise — no readable content, ever.</pre><pre># Terminal 2: watch the TUNNEL interface (inside the envelope)<br>sudo tcpdump -i wt0 -A | head -20<br># ...here you CAN see plaintext (e.g., HTTP headers to a peer) —<br># because wt0 shows traffic AFTER decryption, on your own machine only.</pre><pre># Generate some traffic to observe:<br>curl <a href="http://100.64.0.3:8080/api/status">http://100.64.0.3:8080/api/status</a></pre><h3>Step 6: The Result — All Devices on One Virtual Network</h3><pre>┌──────────────────────────────────────────────────────────────┐<br>│  FINAL NETWORK TOPOLOGY                                      │<br>├──────────────────────────────────────────────────────────────┤<br>│                                                              │<br>│   Netbird Virtual Network: 100.64.0.0/16                     │<br>│                                                              │<br>│   ┌─────────────┐         ┌─────────────┐                    │<br>│   │  Device A   │◄───────►│  Device B   │                    │<br>│   │  100.64.0.2 │  P2P    │  100.64.0.3 │                    │<br>│   │  (Laptop)   │         │  (AWS)      │                    │<br>│   └──────┬──────┘         └─────────────┘                    │<br>│          │                                                   │<br>│          │ P2P or Relay                                      │<br>│          ▼                                                   │<br>│   ┌─────────────┐                                            │<br>│   │  Device C   │                                            │<br>│   │  100.64.0.4 │                                            │<br>│   │  (Raspberry)│                                            │<br>│   └─────────────┘                                            │<br>│                                                              │<br>│   From Device A, you can now:                                │<br>│   $ ssh user@100.64.0.4    ← SSH to Raspberry Pi             │<br>│   $ curl http://100.64.0.3  ← HTTP to AWS server             │<br>│   $ ping 100.64.0.3         ← Ping test                      │<br>│                                                              │<br>│   All traffic is encrypted and routed automatically!         │<br>│                                                              │<br>└──────────────────────────────────────────────────────────────┘</pre><p><strong>Real workflows this unlocks immediately:</strong></p><pre># 1. Browse a remote dashboard as if it were local<br>firefox http://100.64.0.3:3000          # Grafana on the AWS box</pre><pre># 2. rsync files to the factory Pi — no SFTP server exposure needed<br>rsync -avz ./firmware/ user@100.64.0.4:/opt/firmware/</pre><pre># 3. Connect to a remote database WITHOUT exposing port 5432 publicly<br>psql -h 100.64.0.3 -U aas_user aas_db</pre><pre># 4. VS Code Remote-SSH to any peer<br>code --remote ssh-remote+user@100.64.0.4 /home/user/project</pre><pre># 5. Use MagicDNS-style names instead of IPs<br>ssh user@raspberry-pi.netbird.cloud</pre><h3>PHASE 4: Hands-On Commands</h3><h3>🔹 4.1 Installation</h3><pre># One-liner install (Linux)<br>curl -fsSL https://pkgs.netbird.io/install.sh | sh</pre><pre># Start the service<br>sudo netbird service install<br>sudo netbird service start</pre><pre># Connect to Netbird Cloud (managed)<br>sudo netbird up<br># → Opens browser for login</pre><pre># Or use a setup key (for headless servers)<br>sudo netbird up --setup-key &lt;YOUR-SETUP-KEY&gt;</pre><pre># Useful flags for fleet devices (like BX50 kiosks):<br>sudo netbird up --setup-key &lt;KEY&gt; \<br>  --hostname bx50-factory-07 \          # readable name in the dashboard<br>  --allow-server-ssh=false              # don&#39;t enable Netbird&#39;s SSH server</pre><p><strong>About setup keys (critical for automation):</strong></p><pre>Created in the Netbird dashboard → Setup Keys. Two flavors:</pre><pre>  One-off:    valid for ONE device, then dead. Good for manual installs.<br>  Reusable:   enroll many devices (set usage limit + expiry).<br>              Perfect for ansible-provisioned fleets.</pre><pre>Pro tips:<br>  - Attach an auto-group to the key (e.g. &quot;bx50-devices&quot;) so every<br>    kiosk lands in the right ACL group automatically.<br>  - Mark fleet keys as &quot;ephemeral peer = off&quot; so devices persist<br>    across reboots.</pre><h3>🔹 4.2 Checking Status</h3><pre># See your Netbird status<br>sudo netbird status</pre><pre># Example output:<br># Daemon version: 0.27.0<br># CLI version: 0.27.0<br># Management: Connected to api.netbird.io:443<br># Signal: Connected to signal.netbird.io:443<br># Relays: 2/2 Available<br># Nameservers: 0/0 Available<br># FQDN: laptop.netbird.cloud<br># Netbird IP: 100.64.0.2/16<br># Interface type: Kernel<br># Quantum resistance: false<br># Routes: -<br># Peers count: 2/2 Connected<br>#<br>#  Peer connection details:<br>#  peer: aws-server.netbird.cloud<br>#    Netbird IP: 100.64.0.3<br>#    Public key: abc123...<br>#    Status: Connected<br>#    Conn type: P2P          ← Direct connection! Fast!<br>#    Direct: true<br>#    ICE candidate (Local): host<br>#    ICE candidate (Remote): srflx<br>#<br>#  peer: raspberry-pi.netbird.cloud<br>#    Netbird IP: 100.64.0.4<br>#    Public key: def456...<br>#    Status: Connected<br>#    Conn type: Relayed      ← Through relay, but works!<br>#    Direct: false<br>#    Relay server: relay.netbird.io:443</pre><p><strong>Key things to notice:</strong></p><ul><li>Conn type: P2P = Direct connection, fastest</li><li>Conn type: Relayed = Through TURN relay, slower but reliable</li><li>ICE candidate = Shows how the connection was established</li></ul><pre># Machine-readable status — perfect for monitoring scripts<br>sudo netbird status --json | jq &#39;.peers.details[] | {fqdn, status, connType: .connectionType}&#39;</pre><pre># Example monitoring one-liner: alert if any peer is disconnected<br>sudo netbird status --json | jq -e &#39;[.peers.details[].status] | all(. == &quot;Connected&quot;)&#39; \<br>  || echo &quot;ALERT: a peer is down!&quot;</pre><h3>🔹 4.3 Testing Connectivity</h3><pre># From your laptop, ping the Raspberry Pi<br>ping 100.64.0.4</pre><pre># SSH into the AWS server<br>ssh user@100.64.0.3</pre><pre># Check which route Netbird uses<br>ip route get 100.64.0.4<br># Should show: dev wt0 (the WireGuard interface)</pre><pre># See the WireGuard interface<br>ip addr show wt0<br># wt0 = WireGuard TUN interface created by Netbird</pre><pre># Check the WireGuard handshake directly — the ultimate truth<br>sudo wg show wt0 latest-handshakes<br># def456...  1718185000<br># Handshake within last ~2 minutes = tunnel healthy.<br># Very old / zero = tunnel dead even if status says &quot;Connected&quot;.</pre><pre># Layer-by-layer test when something &quot;doesn&#39;t work&quot;:<br>ping 100.64.0.4                      # 1. Can I reach the peer at all? (L3)<br>nc -zv 100.64.0.4 8080               # 2. Is the PORT open? (L4)<br>curl -v <a href="http://100.64.0.4:8080/">http://100.64.0.4:8080/</a>      # 3. Does the SERVICE respond? (L7)<br># Failure at step 1 = Netbird/network issue.<br># Failure at step 2 = peer&#39;s firewall or service not listening.<br># Failure at step 3 = the app itself.</pre><h3>🔹 4.4 Debugging Connection Issues</h3><pre># Detailed status with debug info<br>sudo netbird status -d</pre><pre># View logs<br>sudo journalctl -u netbird -f</pre><pre># Check if STUN is working<br>nc -u stun.l.google.com 19302<br># (Should get a response with your public IP)</pre><pre># Test UDP connectivity<br>nc -u -v 100.64.0.4 12345</pre><pre># Force disconnect and reconnect<br>sudo netbird down<br>sudo netbird up</pre><pre># See routing table<br>ip route show table all | grep wt0</pre><p><strong>Real troubleshooting scenarios:</strong></p><pre>SYMPTOM: &quot;Peers count: 2/2 Connected&quot; but ping fails<br>  → Check ACL policies in the dashboard — connected ≠ allowed.<br>    Default policy allows all; custom policies may block ICMP.</pre><pre>SYMPTOM: Everything Relayed, never P2P<br>  → Both peers behind symmetric NAT (corporate/4G). Try:<br>    sudo netbird status -d | grep &quot;ICE candidate&quot;<br>    If both show &quot;relay&quot;, check whether UDP outbound is blocked:<br>    nc -u -v stun.netbird.io 3478</pre><pre>SYMPTOM: SSH works but large file transfers stall<br>  → Classic MTU problem. WireGuard adds ~60 bytes of overhead.<br>    Test:  ping -M do -s 1372 100.64.0.4    # 1372 + 28 = 1400<br>    Fix:   sudo ip link set wt0 mtu 1280    # conservative value</pre><pre>SYMPTOM: netbird up hangs on login (headless device)<br>  → No browser available. Use a setup key instead:<br>    sudo netbird up --setup-key &lt;KEY&gt;</pre><pre>SYMPTOM: peer unreachable after laptop sleep/resume<br>  → Tunnel state went stale. Quick fix:<br>    sudo netbird down &amp;&amp; sudo netbird up</pre><h3>🔹 4.5 Beyond Basics: Subnet Routes, ACLs &amp; Exit Nodes</h3><p>These three features turn Netbird from “VPN between my devices” into real<br>infrastructure:</p><p><strong>a) Subnet routing — reach devices that DON’T run Netbird:</strong></p><pre>Factory LAN: 10.0.32.0/24<br>  - BX50 kiosk    10.0.32.100   (runs Netbird ✅)<br>  - PLC           10.0.32.50    (can&#39;t install anything ❌)<br>  - IP camera     10.0.32.60    (can&#39;t install anything ❌)</pre><pre>Solution: make the kiosk a ROUTING PEER for 10.0.32.0/24.</pre><pre>Dashboard → Networks → Add route:<br>  Network: 10.0.32.0/24, Routing peer: bx50-factory-07</pre><pre>On the kiosk, enable forwarding:<br>  sudo sysctl -w net.ipv4.ip_forward=1</pre><pre>Now FROM YOUR LAPTOP (anywhere in the world):<br>  ping 10.0.32.50            # reaches the PLC, via the kiosk!<br>  vlc rtsp://10.0.32.60/cam  # view the factory camera</pre><p><strong>b) Access control policies — not everyone should see everything:</strong></p><pre>Groups (assigned via setup keys or manually):<br>  &quot;admins&quot;        → your laptop<br>  &quot;bx50-devices&quot;  → all factory kiosks<br>  &quot;servers&quot;       → AAS API + DB servers</pre><pre>Policies:<br>  admins        → bx50-devices : ALL ports        (full debug access)<br>  bx50-devices  → servers      : TCP 8080, 443    (API calls only)<br>  bx50-devices  → bx50-devices : DENY             (kiosks can&#39;t see each other!)</pre><pre>This means a compromised kiosk CANNOT reach other kiosks or<br>SSH into your servers — only the API port it needs.</pre><p><strong>c) Exit node — route ALL internet traffic via a peer:</strong></p><pre># Make the AWS server an exit node (dashboard → enable exit node)<br># Then on your laptop in a sketchy airport WiFi:<br>netbird up --exit-node aws-server<br>curl ifconfig.me     # → 54.123.45.67 (the AWS IP, not the airport&#39;s)<br># Works like a classic &quot;full tunnel&quot; VPN when you need one.</pre><h3>🔹 4.6 Self-Hosting Netbird (Advanced)</h3><p>If you don’t want to use Netbird’s cloud service:</p><pre># Clone the self-hosted repo<br>git clone https://github.com/netbirdio/netbird.git<br>cd netbird/infrastructure_files</pre><pre># Configure<br>export NETBIRD_DOMAIN=&quot;vpn.yourcompany.com&quot;<br>export NETBIRD_LETSENCRYPT_EMAIL=&quot;admin@yourcompany.com&quot;</pre><pre># Deploy with Docker Compose<br>./getting-started.sh</pre><pre># This sets up:<br># - Management Server (coordinates peers)<br># - Signal Server (helps with P2P negotiation)<br># - STUN/TURN Server (for NAT traversal)<br># - Dashboard (web UI for managing peers)<br># - IDP (Identity Provider for authentication)</pre><pre># Point clients at YOUR server instead of Netbird Cloud:<br>sudo netbird up --management-url <a href="https://vpn.yourcompany.com/">https://vpn.yourcompany.com:443</a> \<br>                --setup-key &lt;KEY&gt;</pre><p><strong>Self-hosting requirements checklist:</strong></p><pre>□ A VM with a PUBLIC IP (the one machine that must NOT be behind NAT)<br>□ DNS A record: vpn.yourcompany.com → that IP<br>□ Open ports: 443/tcp (mgmt+signal+dashboard), 3478/udp (STUN),<br>              49152-65535/udp (TURN relay range)<br>□ ~2 GB RAM is plenty for hundreds of peers (coordination is cheap —<br>  remember, peer data traffic doesn&#39;t flow through it unless relayed)</pre><h3>PHASE 5: Connecting to Your Project</h3><h3>🔹 5.1 Your Current Setup (from ansible analysis)</h3><p>From your aas-ansible roles:</p><pre># In cloudLinkValidation.sh.j2 and obtValidation.sh.j2:</pre><pre>enable_networking() {<br>    # Replace resolv.conf<br>    # Add static routes for required subnets<br>}</pre><pre>disable_networking() {<br>    route del default gw 10.0.32.1 wlan0<br>}</pre><pre># VPN toggle:<br>vpn_output=$(sudo -u scuser -i bash -x -c &quot;${QC_RUNNER} -v \&quot;enable\&quot;&quot; 2&gt;&amp;1)</pre><p><strong>What this does currently:</strong></p><ol><li>Enables/disables network connectivity on BX50 devices</li><li>Manages static routes to specific subnets</li><li>Toggles VPN via a custom QC_RUNNER script</li></ol><h3>🔹 5.2 How Netbird Could Enhance Your Setup</h3><pre>CURRENT APPROACH (Traditional VPN):<br>┌─────────────────────────────────────────────────────────────┐<br>│                                                             │<br>│  BX50 Device (Factory)          AAS API Server (Cloud)      │<br>│  10.0.32.100                    54.123.45.67                │<br>│       │                               │                     │<br>│       │    VPN Tunnel                 │                     │<br>│       │    (QC_RUNNER managed)        │                     │<br>│       │                               │                     │<br>│       └──────────► VPN Server ◄───────┘                     │<br>│                    (Central hub)                            │<br>│                                                             │<br>│  Problems:                                                  │<br>│  - All traffic through VPN server                           │<br>│  - Manual route management                                  │<br>│  - Single point of failure                                  │<br>│  - Complex QC_RUNNER scripts                                │<br>│                                                             │<br>└─────────────────────────────────────────────────────────────┘</pre><pre>WITH NETBIRD (Mesh):<br>┌─────────────────────────────────────────────────────────────┐<br>│                                                             │<br>│  BX50 Device (Factory)          AAS API Server (Cloud)      │<br>│  Netbird IP: 100.64.0.10        Netbird IP: 100.64.0.20     │<br>│       │◄──────────────────────────────►│                    │<br>│       │         Direct P2P             │                    │<br>│       │         (auto-established)     │                    │<br>│       │                                │                    │<br>│       │◄──────────► UI Server          │                    │<br>│       │         (another peer)         │                    │<br>│       │                                │                    │<br>│                                                             │<br>│  Benefits:                                                  │<br>│  - Direct connections between peers                         │<br>│  - No central VPN server bottleneck                         │<br>│  - Automatic route management                               │<br>│  - Self-healing (reconnects automatically)                  │<br>│  - Simple: install netbird, done                            │<br>│                                                             │<br>└─────────────────────────────────────────────────────────────┘</pre><h3>🔹 5.3 Practical Migration Example</h3><p><strong>Current ansible task (simplified):</strong></p><pre># Current: Managing VPN manually<br>- name: Enable VPN<br>  shell: |<br>    /opt/qc_runner -v &quot;enable&quot;<br>    ip route add 10.0.0.0/8 via 10.0.32.1<br>    ip route add 172.16.0.0/12 via 10.0.32.1</pre><p><strong>With Netbird (simplified):</strong></p><pre># New: Netbird handles everything<br>- name: Install Netbird<br>  shell: |<br>    curl -fsSL https://pkgs.netbird.io/install.sh | sh<br>  args:<br>    creates: /usr/bin/netbird          # idempotent — skip if installed</pre><pre>- name: Start Netbird with setup key<br>  shell: |<br>    netbird up --setup-key &quot;{{ netbird_setup_key }}&quot; \<br>               --hostname &quot;bx50-{{ inventory_hostname }}&quot;<br>  become: true</pre><pre># That&#39;s it! Netbird auto-discovers peers and routes<br># No manual route management needed</pre><p><strong>The “enable/disable networking” workflow, reimagined:</strong></p><pre># QC validation scripts could replace route surgery with:<br>netbird up      # device joins mesh → cloud link validation can run<br>netbird down    # device leaves mesh → isolated again<br># One command each way, no resolv.conf swapping, no route bookkeeping,<br># and `netbird status --json` gives the QC script a clean pass/fail signal:<br>netbird status --json | jq -e &#39;.management.connected&#39; &amp;&amp; echo &quot;CLOUD LINK OK&quot;</pre><p><strong>Accessing your API from BX50:</strong></p><pre># Before (traditional VPN):<br>curl http://10.0.0.25:8080/api/status<br># (Had to know internal IP, manage routes)</pre><pre># After (Netbird):<br>curl <a href="http://aas-api.netbird.cloud:8080/api/status">http://aas-api.netbird.cloud:8080/api/status</a><br># OR using Netbird IP:<br>curl <a href="http://100.64.0.20:8080/api/status">http://100.64.0.20:8080/api/status</a><br># (Netbird handles DNS and routing automatically)</pre><p><strong>Bonus: fleet operations that become trivial:</strong></p><pre># SSH into ANY factory kiosk from your desk — no jump hosts:<br>ssh scuser@bx50-factory-07.netbird.cloud</pre><pre># Push a config to every kiosk via ansible OVER the mesh<br># (inventory just lists netbird FQDNs — works regardless of which<br>#  factory/NAT each device sits behind):<br>ansible -i &#39;bx50-factory-07.netbird.cloud,bx50-factory-08.netbird.cloud,&#39; \<br>        all -m copy -a &quot;src=app.conf dest=/opt/aas/app.conf&quot;</pre><pre># Tail provisioning logs from a kiosk live, during a support call:<br>ssh scuser@bx50-factory-07.netbird.cloud &#39;tail -f /var/log/aas/provision.log&#39;</pre><pre># Scrape kiosk metrics into Prometheus — every peer is a stable target:<br>#   - targets: [&#39;100.64.0.10:9100&#39;, &#39;100.64.0.11:9100&#39;]</pre><h3>CHEAT SHEET</h3><h3>Quick Commands</h3><pre># Install<br>curl -fsSL https://pkgs.netbird.io/install.sh | sh</pre><pre># Connect / disconnect<br>sudo netbird up<br>sudo netbird up --setup-key &lt;KEY&gt;      # headless / fleet devices<br>sudo netbird down</pre><pre># Status<br>sudo netbird status<br>sudo netbird status -d                 # detailed (ICE candidates etc.)<br>sudo netbird status --json | jq        # for scripts/monitoring</pre><pre># Service management<br>sudo netbird service start<br>sudo netbird service stop<br>sudo netbird service restart</pre><pre># Logs<br>sudo journalctl -u netbird -f</pre><pre># See peers<br>sudo netbird status | grep -A 10 &quot;Peer connection&quot;</pre><pre># Tunnel internals<br>sudo wg show                           # handshakes, transfer counters<br>ip addr show wt0                       # the mesh interface<br>ip route get &lt;netbird-ip&gt;              # confirm traffic uses wt0</pre><pre># Test connectivity (layer by layer)<br>ping &lt;netbird-ip&gt;                      # L3 reachability<br>nc -zv &lt;netbird-ip&gt; &lt;port&gt;             # L4 port open?<br>curl -v http://&lt;netbird-ip&gt;:&lt;port&gt;/    # L7 service responding?</pre><h3>Diagnostic Decoder Ring</h3><p>You see…It means…Do thisConn type: P2PDirect tunnel — best caseNothing 🎉Conn type: RelayedSymmetric NAT somewhereCheck UDP outbound, accept relay, or fix NATcurl: Connection timed outFirewall DROPpingCheck ufw/iptables/ACL policiescurl: Connection refusedReached host, no listenerCheck the service + ss -tulpnwg show handshake very oldTunnel silently deadnetbird down &amp;&amp; netbird upping OK, big transfers stallMTU too largeip link set wt0 mtu 1280Connected peers, ping blockedNetbird ACL policyReview dashboard policies</p><h3>Key Concepts Quick Reference</h3><p>TermOne-LinerNetbird Context<strong>IP</strong>Device’s addressNetbird assigns 100.64.x.x<strong>Subnet</strong>Group of IPs100.64.0.0/16 is your mesh<strong>Gateway</strong>Traffic directorNetbird manages this automatically<strong>WAN</strong>The internetNetbird rides on top of WAN<strong>Firewall</strong>Traffic filterNetbird uses UDP hole punching<strong>NAT</strong>IP sharingNetbird&#39;s STUN discovers public IPs<strong>P2P</strong>Direct connectionNetbird prefers this for speed<strong>VPN</strong>Virtual private networkNetbird is a mesh VPN<strong>WireGuard</strong>Encryption protocolNetbird uses this under the hood<strong>STUN</strong>&quot;What&#39;s my IP?&quot;Netbird uses this for NAT discovery<strong>TURN</strong>Traffic relayNetbird fallback when P2P fails<strong>ICE</strong>Connection negotiatorTries host → srflx → relay candidates<strong>Setup key</strong>Pre-auth tokenHeadless/fleet enrollment (ansible!)<strong>Routing peer</strong>LAN gateway into meshReach PLCs/cameras that can&#39;t run Netbird<strong>Exit node</strong>Full-tunnel gatewayRoute all internet traffic via a peer</p><h3>🧠 REMEMBER THIS</h3><blockquote><strong><em>Netbird = WireGuard (encryption) + ICE/STUN/TURN (NAT traversal) + Management Server (coordination)</em></strong></blockquote><p>The result: <strong>Install on any device, anywhere in the world, and they can talk securely as if on the same LAN.</strong></p><p>No port forwarding. No static routes. No central server bottleneck. It just works.</p><p>And the management server only <em>coordinates</em> — your data flows peer-to-peer,<br>so even a management outage doesn’t break established tunnels.</p><p><em>Generated for understanding Netbird and networking fundamentals with practical examples.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47e8ca84dd38" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My VS Code + Starship Setup That Makes Coding on WSL Actually Feel Good]]></title>
            <link>https://medium.com/@VibekD1996/my-vs-code-starship-setup-that-makes-coding-on-wsl-actually-feel-good-5cba6dd6522e?source=rss-2ed24239d477------2</link>
            <guid isPermaLink="false">https://medium.com/p/5cba6dd6522e</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Vibek Dutta]]></dc:creator>
            <pubDate>Thu, 11 Jun 2026 21:13:13 GMT</pubDate>
            <atom:updated>2026-06-11T21:13:13.084Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A purple-tinted editor, inline errors, sticky scroll, and a terminal prompt that tells me everything I need at a glance — here’s the whole thing, copy-paste ready.</em></p><p>I spend most of my day in VS Code on WSL2, working across a multi-repo TypeScript/React + Node monorepo. Over time I’ve tuned my editor and terminal into something that’s both <strong>pretty</strong> and genuinely <strong>productive</strong> — and enough people have asked “wait, how is your setup like that?” that I figured I’d write it all down.</p><p>This post has two halves:</p><ol><li><strong>The VS Code config</strong> — every setting that earns its place, grouped and explained with real examples.</li><li><strong>The terminal</strong> — how I made my prompt look clean and informative using <a href="https://starship.rs/">Starship</a>, with full install instructions.</li></ol><p>Steal whatever you like.</p><h3>Part 1 — The VS Code setup</h3><h3>A custom-tinted UI</h3><p>The first thing people notice is the color. I’m not using a whole custom theme — I just override a handful of workbench colors on top of my base theme. It gives the UI a signature look without me maintaining an entire theme file.</p><pre>&quot;workbench.colorCustomizations&quot;: {<br>  &quot;sideBar.border&quot;: &quot;#3a3662&quot;,<br>  &quot;editorGroup.border&quot;: &quot;#3a3662&quot;,<br>  &quot;editorGroupHeader.tabsBorder&quot;: &quot;#3a3662&quot;,<br>  &quot;tab.border&quot;: &quot;#3a3662&quot;,<br>  &quot;list.activeSelectionBackground&quot;: &quot;#454e1d&quot;,   // olive-green active selection<br>  &quot;list.activeSelectionForeground&quot;: &quot;#FFFFFF&quot;,<br>  &quot;list.focusBackground&quot;: &quot;#352451&quot;,             // deep purple focus<br>  &quot;list.focusForeground&quot;: &quot;#FFFFFF&quot;,<br>  &quot;list.focusHighlightForeground&quot;: &quot;#C9B8FF&quot;,<br>  &quot;list.inactiveFocusBackground&quot;: &quot;#2A1C42&quot;,<br>  &quot;list.errorForeground&quot;: &quot;#FF8FA3&quot;,<br>  &quot;list.hoverBackground&quot;: &quot;#750253&quot;,             // magenta hover<br>  &quot;list.focusAndSelectionOutline&quot;: &quot;#A0B0FF73&quot;,<br>  &quot;list.inactiveSelectionBackground&quot;: &quot;#454e1d&quot;,<br>  &quot;list.inactiveSelectionForeground&quot;: &quot;#F3F6FF&quot;<br>}</pre><p>The trick here: violet borders (#3a3662) frame the editor groups and sidebar, an <strong>olive-green</strong> highlight marks the selected file, <strong>purple</strong> marks keyboard focus, and a <strong>magenta</strong> hover sweeps across the file tree as I move the mouse. It&#39;s distinctive without being noisy.</p><pre>&quot;window.title&quot;: &quot;${rootName}${separator}${activeEditorMedium}&quot;</pre><p>A more useful title bar — I always know which repo <em>and</em> which file I’m in.</p><h3>Editor quality-of-life</h3><p>These are the settings that quietly remove friction all day long.</p><pre>&quot;editor.stickyScroll.enabled&quot;: true,<br>&quot;editor.linkedEditing&quot;: true,<br>&quot;editor.inlineSuggest.enabled&quot;: true,<br>&quot;editor.cursorSmoothCaretAnimation&quot;: &quot;on&quot;,<br>&quot;editor.renderWhitespace&quot;: &quot;boundary&quot;,<br>&quot;editor.semanticHighlighting.enabled&quot;: true,<br>&quot;workbench.list.smoothScrolling&quot;: true,<br>&quot;workbench.editor.highlightModifiedTabs&quot;: true,<br>&quot;breadcrumbs.enabled&quot;: true</pre><p>A few of these deserve a proper explanation, because they’re the real MVPs:</p><p><strong>editor.stickyScroll.enabled</strong> — Pins the enclosing function/class/JSX block to the top of the editor as you scroll. In a 600-line wizard page, you always know which handler you&#39;re inside even when its opening line scrolled off ages ago. This one alone changed how I navigate big files.</p><p><strong>editor.linkedEditing</strong> — Rename a JSX opening tag and the closing tag updates with it. &lt;Card&gt;…&lt;/Card&gt; → edit one, both change. Tiny, but you stop fixing mismatched tags forever.</p><p><strong>editor.semanticHighlighting.enabled</strong> — VS Code colors code in two layers: a fast regex grammar (TextMate), and <em>semantic</em> highlighting from the TypeScript language server, which actually understands your types. With this on, tokens are colored by <strong>meaning</strong>, not just appearance.</p><blockquote><em>Example: in </em><em>const restructure = (bx50) =&gt; {...}, semantic highlighting can color </em><em>bx50 as a </em><strong><em>parameter</em></strong><em>, </em><em>restructure as a </em><strong><em>function</em></strong><em>, and dim an </em><strong><em>unused variable</em></strong><em>. A </em><em>data.debuggerPW access colors </em><em>debuggerPW specifically as a </em><strong><em>property</em></strong><em>. Without it, those all share one generic &quot;variable&quot; color.</em></blockquote><p><strong>breadcrumbs.enabled</strong> — The clickable trail at the top of the editor showing where you are: path → symbol.</p><blockquote><em>Example: with my cursor inside </em><em>handleFinish, the breadcrumb reads </em><em>src › pages › BatchTestingPage.tsx › BatchTestingPage › handleFinish. Click </em><em>BatchTestingPage and you get a dropdown of </em>every<em> method to jump between. Fast navigation without scrolling.</em></blockquote><p><strong>editor.renderWhitespace&quot;: &quot;boundary&quot;</strong> — Shows whitespace dots only where they matter (trailing space, runs between words), so accidental trailing whitespace stops sneaking into diffs.</p><h3>Minimalist bracket guides (my favorite tweak)</h3><p>I love a bracket guide for the current scope — but the default version is busy. Here’s how I made it minimal:</p><pre>&quot;editor.guides.bracketPairs&quot;: &quot;active&quot;</pre><p>&quot;active&quot; is already the quietest of the vertical-guide modes — it only draws the scope your cursor is <em>currently</em> in, instead of true, which draws a line for every nested bracket pair.</p><p>If you want to go even further (I sometimes do), kill the horizontal “elbow” connectors:</p><pre>&quot;editor.guides.bracketPairs&quot;: &quot;active&quot;,<br>&quot;editor.guides.bracketPairsHorizontal&quot;: false      // ← drops the elbow lines</pre><p>By default, the guide draws a little horizontal segment connecting the vertical line to the bracket character. Turning bracketPairsHorizontal off leaves a single clean vertical line for the active scope — much calmer. You can dim the line itself too:</p><pre>&quot;workbench.colorCustomizations&quot;: {<br>  &quot;editorBracketPairGuide.activeBackground1&quot;: &quot;#ffffff20&quot;   // faint line<br>}</pre><h3>File explorer &amp; navigation</h3><pre>&quot;explorer.fileNesting.enabled&quot;: true,<br>&quot;explorer.fileNesting.patterns&quot;: {<br>  &quot;*.ts&quot;: &quot;${capture}.js, ${capture}.d.ts&quot;,<br>  &quot;*.tsx&quot;: &quot;${capture}.ts, ${capture}.css&quot;,<br>  &quot;package.json&quot;: &quot;package-lock.json, .eslintrc*, tsconfig*.json, .prettierrc*&quot;<br>},<br>&quot;explorer.compactFolders&quot;: false</pre><p><strong>File nesting</strong> tucks generated/related files under their parent — package-lock.json, tsconfig.json, and lint configs collapse neatly under package.json, and Component.css nests under Component.tsx. The explorer stops looking like a junk drawer.</p><p>compactFolders: false keeps single-child folders expanded as separate rows, which I prefer for deeply nested src/pages/... trees — easier to read the real hierarchy.</p><h3>Taming a big, multi-repo workspace</h3><p>This is where the real performance wins live. My workspace has several large repos, a pile of Postman collections, and — no joke — a <strong>33.9 MB</strong> SQL file. I hide what I’m not actively working in and exclude the heavy stuff from search and the file watcher.</p><pre>&quot;files.exclude&quot;: {<br>  &quot;**/.agents&quot;: true,<br>  &quot;**/.claude&quot;: true,<br>  &quot;**/.codex&quot;: true,<br>  &quot;**/aas-ansible&quot;: true,<br>  &quot;**/inventory-api&quot;: true,<br>  &quot;**/inventory-ui&quot;: true,<br>  &quot;**/metrics-ui&quot;: true,<br>  &quot;**/production_metrics&quot;: true<br>  // (repos I want visible are simply set to false)<br>},<br>&quot;search.exclude&quot;: {<br>  &quot;**/node_modules&quot;: true,<br>  &quot;**/dist&quot;: true,<br>  &quot;**/build&quot;: true,<br>  &quot;**/aas-removepassfail.sql&quot;: true,           // the 33 MB monster<br>  &quot;**/*.postman_collection.json&quot;: true         // big, noisy in results<br>},<br>&quot;files.watcherExclude&quot;: {<br>  &quot;**/node_modules/**&quot;: true,<br>  &quot;**/dist/**&quot;: true<br>}</pre><p>files.exclude hides folders from the explorer entirely (great for collapsing repos you&#39;re not touching today). search.exclude keeps node_modules, build output, that giant SQL dump, and Postman collections out of every Ctrl+Shift+F. files.watcherExclude stops VS Code from watching node_modules for changes — a real CPU/battery saver on WSL.</p><blockquote><strong><em>Tip:</em></strong><em> excluding that single 33 MB SQL file from search and watch noticeably sped up my whole workspace. Find your heavy files (</em><em>find . -size +5M) and do the same.</em></blockquote><h3>Terminal settings inside VS Code</h3><pre>&quot;terminal.integrated.fontFamily&quot;: &quot;monospace&quot;,<br>&quot;terminal.integrated.scrollback&quot;: 500</pre><p><strong>scrollback</strong> controls how many lines of past output the terminal keeps before dropping the oldest (default 1000). A npm run build that prints thousands of lines will blow past a small buffer — bump this up if you want to scroll all the way back through a long log. I keep mine modest at 500 since I lean on the prompt and git rather than scrolling.</p><blockquote><em>A couple of cosmetic ones I like in other setups: </em><em>terminal.integrated.cursorBlinking: true (pulsing cursor, easier to spot when you focus the terminal) and a bigger </em><em>scrollback like </em><em>10000 for log-heavy builds.</em></blockquote><h3>The full settings.json</h3><p>Here’s the whole thing, cleaned up and ready to drop into .vscode/settings.json (or your User settings):</p><pre>{<br>  &quot;terminal.integrated.fontFamily&quot;: &quot;monospace&quot;,<br>  &quot;workbench.colorCustomizations&quot;: {<br>    &quot;sideBar.border&quot;: &quot;#3a3662&quot;,<br>    &quot;editorGroup.border&quot;: &quot;#3a3662&quot;,<br>    &quot;editorGroupHeader.tabsBorder&quot;: &quot;#3a3662&quot;,<br>    &quot;tab.border&quot;: &quot;#3a3662&quot;,<br>    &quot;list.activeSelectionBackground&quot;: &quot;#454e1d&quot;,<br>    &quot;list.activeSelectionForeground&quot;: &quot;#FFFFFF&quot;,<br>    &quot;list.activeSelectionIconForeground&quot;: &quot;#FFFFFF&quot;,<br>    &quot;list.focusBackground&quot;: &quot;#352451&quot;,<br>    &quot;list.focusForeground&quot;: &quot;#FFFFFF&quot;,<br>    &quot;list.focusHighlightForeground&quot;: &quot;#C9B8FF&quot;,<br>    &quot;list.inactiveFocusBackground&quot;: &quot;#2A1C42&quot;,<br>    &quot;list.errorForeground&quot;: &quot;#FF8FA3&quot;,<br>    &quot;list.hoverBackground&quot;: &quot;#750253&quot;,<br>    &quot;list.focusAndSelectionOutline&quot;: &quot;#A0B0FF73&quot;,<br>    &quot;list.inactiveSelectionBackground&quot;: &quot;#454e1d&quot;,<br>    &quot;list.inactiveSelectionForeground&quot;: &quot;#F3F6FF&quot;,<br>    &quot;list.inactiveSelectionIconForeground&quot;: &quot;#F3F6FF&quot;<br>  },<br>  &quot;workbench.list.smoothScrolling&quot;: true,<br>  &quot;window.title&quot;: &quot;${rootName}${separator}${activeEditorMedium}&quot;,<br>  &quot;files.exclude&quot;: {<br>    &quot;**/.agents&quot;: true,<br>    &quot;**/.claude&quot;: true,<br>    &quot;**/.codex&quot;: true,<br>    &quot;**/aas-ansible&quot;: true,<br>    &quot;**/inventory-api&quot;: true,<br>    &quot;**/inventory-ui&quot;: true,<br>    &quot;**/metrics-ui&quot;: true,<br>    &quot;**/production_metrics&quot;: true<br>  },<br>  &quot;search.exclude&quot;: {<br>    &quot;**/node_modules&quot;: true,<br>    &quot;**/dist&quot;: true,<br>    &quot;**/build&quot;: true,<br>    &quot;**/aas-removepassfail.sql&quot;: true,<br>    &quot;**/*.postman_collection.json&quot;: true<br>  },<br>  &quot;files.watcherExclude&quot;: {<br>    &quot;**/node_modules/**&quot;: true,<br>    &quot;**/dist/**&quot;: true<br>  },<br>  &quot;explorer.fileNesting.enabled&quot;: true,<br>  &quot;explorer.fileNesting.patterns&quot;: {<br>    &quot;*.ts&quot;: &quot;${capture}.js, ${capture}.d.ts&quot;,<br>    &quot;*.tsx&quot;: &quot;${capture}.ts, ${capture}.css&quot;,<br>    &quot;package.json&quot;: &quot;package-lock.json, .eslintrc*, tsconfig*.json, .prettierrc*&quot;<br>  },<br>  &quot;explorer.compactFolders&quot;: false,<br>  &quot;workbench.editor.highlightModifiedTabs&quot;: true,<br>  &quot;breadcrumbs.enabled&quot;: true,<br>  &quot;editor.guides.bracketPairs&quot;: &quot;active&quot;,<br>  &quot;editor.guides.bracketPairsHorizontal&quot;: false,<br>  &quot;editor.stickyScroll.enabled&quot;: true,<br>  &quot;editor.linkedEditing&quot;: true,<br>  &quot;editor.inlineSuggest.enabled&quot;: true,<br>  &quot;editor.cursorSmoothCaretAnimation&quot;: &quot;on&quot;,<br>  &quot;editor.renderWhitespace&quot;: &quot;boundary&quot;,<br>  &quot;editor.semanticHighlighting.enabled&quot;: true,<br>  &quot;terminal.integrated.scrollback&quot;: 500<br>}</pre><blockquote><em>🔐 </em><strong><em>A word on secrets:</em></strong><em> if you use an extension that stores API keys in </em><em>settings.json, </em><strong><em>strip those keys before sharing your config</em></strong><em> anywhere public. A settings file looks innocent, but keys in it are real credentials — and once they&#39;re on the internet they&#39;re compromised, even if you delete the post later. Keep secrets in environment variables or your OS keychain instead.</em></blockquote><h3>Part 2 — The terminal: a clean prompt with Starship</h3><p>Now the part everyone actually asks about: the prompt.</p><p>I use <a href="https://starship.rs/"><strong>Starship</strong></a> — a single, blazing-fast, cross-shell prompt written in Rust. It works in Bash, Zsh, Fish, PowerShell, you name it, all driven by one little TOML file. My prompt shows me the <strong>directory</strong>, <strong>git branch</strong>, <strong>git status</strong>, how long the <strong>last command took</strong>, and the <strong>time</strong> — without ever feeling cluttered.</p><p>Here’s what a line looks like in spirit:</p><pre>~/KPMinWSL/aas-ui   main  !2 +1 ?3   took 3s        14:32<br>&gt; _</pre><p>That reads as: I’m in aas-ui, on branch main, with <strong>2 modified</strong>, <strong>1 staged</strong>, and <strong>3 untracked</strong> files; the last command took 3 seconds; it&#39;s 14:32 on the right. The &gt; is my prompt character — blue when the last command succeeded, red when it failed.</p><h3>My starship.toml</h3><p>This lives at ~/.config/starship.toml:</p><pre>add_newline = true<br>format = &quot;$directory$git_branch$git_status$cmd_duration$line_break$character&quot;<br>right_format = &quot;$time&quot;</pre><pre>[directory]<br>style = &quot;bold cyan&quot;<br>truncation_length = 3<br>truncate_to_repo = false<br>read_only = &quot; lock &quot;</pre><pre>[git_branch]<br>symbol = &quot; &quot;<br>style = &quot;bold purple&quot;<br>format = &quot;[ $symbol$branch ]($style) &quot;</pre><pre>[git_status]<br>style = &quot;bold yellow&quot;<br>format = &quot;[$all_status$ahead_behind]($style) &quot;<br>conflicted = &quot;=&quot;<br>ahead = &quot; up:${count}&quot;<br>behind = &quot; down:${count}&quot;<br>diverged = &quot; up:${ahead_count} down:${behind_count}&quot;<br>untracked = &quot; ?${count}&quot;<br>stashed = &quot;&quot;<br>modified = &quot; !${count}&quot;<br>staged = &quot; +${count}&quot;<br>renamed = &quot; r${count}&quot;<br>deleted = &quot; x${count}&quot;</pre><pre>[cmd_duration]<br>min_time = 1500<br>format = &quot;[ took $duration]($style)&quot;<br>style = &quot;dimmed yellow&quot;</pre><pre>[time]<br>disabled = false<br>format = &quot;[$time]($style)&quot;<br>time_format = &quot;%H:%M&quot;<br>style = &quot;dimmed white&quot;</pre><pre>[character]<br>success_symbol = &quot;[&gt;](bold blue)&quot;<br>error_symbol = &quot;[&gt;](bold red)&quot;</pre><h3>What each piece is doing</h3><ul><li><strong>format / </strong><strong>right_format</strong> — The main prompt is laid out left-to-right: directory → git branch → git status → command duration → line break → the &gt; character. The clock is pushed to the <strong>right</strong> edge of the terminal via right_format, so it stays out of the way.</li><li><strong>[directory]</strong> — Bold cyan path, truncated to the last 3 folders so deep paths don&#39;t eat the whole line. truncate_to_repo = false means it shows the real path rather than collapsing to the repo root.</li><li><strong>[git_branch]</strong> — A branch glyph + name in <strong>bold purple</strong> (matches my editor&#39;s purple accents — the whole setup is color-coordinated, which is half the fun).</li><li><strong>[git_status]</strong> — The information-dense part, in yellow. I replaced Starship&#39;s default symbols with readable shorthand: !2 = 2 modified, +1 = 1 staged, ?3 = 3 untracked, up:N / down:N for ahead/behind the remote, x deleted, r renamed. At a glance I know my working-tree state without typing git status.</li><li><strong>[cmd_duration]</strong> — Only appears when a command took longer than <strong>1.5s</strong> (min_time = 1500), shown dimmed as took 3s. Free profiling: you instantly notice when something&#39;s slow.</li><li><strong>[time]</strong> — A dimmed HH:MM clock on the right. Genuinely handy for &quot;when did I kick off that build?&quot;</li><li><strong>[character]</strong> — The prompt arrow: <strong>blue </strong><strong>&gt;</strong> on success, <strong>red </strong><strong>&gt;</strong> on failure. The fastest possible signal that the last command errored.</li></ul><h3>Set it up yourself</h3><p><strong>1. Install Starship.</strong> On Linux/WSL/macOS:</p><pre>curl -sS https://starship.rs/install.sh | sh</pre><p>(Or brew install starship, winget install starship, etc. — see <a href="https://starship.rs/guide/">starship.rs/guide</a>.)</p><p><strong>2. Install a Nerd Font.</strong> The branch glyph (and most icon-based prompts) need one. Grab any <a href="https://www.nerdfonts.com/">Nerd Font</a> — <em>FiraCode Nerd Font</em>, <em>JetBrainsMono Nerd Font</em>, and <em>Caskaydia Cove Nerd Font</em> are all great — install it, and set it as the font in your terminal (Windows Terminal, iTerm, GNOME Terminal, or VS Code’s terminal.integrated.fontFamily). Without a Nerd Font, glyphs render as little boxes.</p><p><strong>3. Hook Starship into your shell.</strong> I’m on <strong>Bash</strong>, so the last meaningful line of my ~/.bashrc is:</p><pre># Starship prompt<br>eval &quot;$(starship init bash)&quot;</pre><p>For other shells:</p><p>ShellAdd toLineBash~/.bashrceval &quot;$(starship init bash)&quot;Zsh~/.zshrceval &quot;$(starship init zsh)&quot;Fish~/.config/fish/config.fishstarship init fish | sourcePowerShell$PROFILEInvoke-Expression (&amp;starship init powershell)</p><blockquote><em>Put the init line </em><strong><em>at the end</em></strong><em> of your rc file, after anything else that touches the prompt (in my case, after the </em><em>PATH exports and before </em><em>nvm loads).</em></blockquote><p><strong>4. Drop in the config.</strong> Create ~/.config/starship.toml and paste the TOML above:</p><pre>mkdir -p ~/.config<br># then paste the starship.toml contents into ~/.config/starship.toml</pre><p><strong>5. Reload.</strong></p><pre>source ~/.bashrc</pre><p>That’s it. New shells will greet you with the clean, color-coordinated prompt.</p><blockquote><em>Want to tweak it? Run </em><em>starship explain to see what each module is contributing to your current prompt, and browse </em><a href="https://starship.rs/config/"><em>the config docs</em></a><em> — there are modules for Node version, Python venv, Docker context, AWS profile, battery, and dozens more. Add only what earns its place; the magic of this setup is restraint.</em></blockquote><h3>Wrapping up</h3><p>None of this is exotic — it’s a base theme with a few color overrides, a dozen well-chosen editor settings, smart workspace excludes, and a tidy Starship prompt. But together they turn “VS Code on WSL” into something that feels personal, fast, and a little bit beautiful.</p><p>My top picks if you only copy a few things:</p><ul><li><strong>editor.stickyScroll</strong> — life-changing in long files.</li><li><strong>search.exclude for your heavy files</strong> — instant speed.</li><li><strong>File nesting</strong> — a calmer explorer.</li><li><strong>Starship</strong> — the single biggest “ooh, nice terminal” upgrade for the least effort.</li></ul><p>Copy what resonates, tweak the colors to your taste, and make it yours. Happy hacking. 💜</p><p><em>If you build your own variation, I’d love to see it — drop your </em><em>starship.toml in the comments.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5cba6dd6522e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resolving Real World System Design Issues: Part 1]]></title>
            <link>https://medium.com/@VibekD1996/design-issue-on-aws-and-how-i-fixed-it-c97a47f6932d?source=rss-2ed24239d477------2</link>
            <guid isPermaLink="false">https://medium.com/p/c97a47f6932d</guid>
            <category><![CDATA[aws-sqs]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[system-design-interview]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Vibek Dutta]]></dc:creator>
            <pubDate>Thu, 05 Mar 2026 02:48:12 GMT</pubDate>
            <atom:updated>2026-03-05T20:48:41.297Z</atom:updated>
            <content:encoded><![CDATA[<p>It was a Friday evening. My team and I had just deployed a new feature — a simple batch job to move files using AWS Lambda. We were feeling good. Tests had passed. Everything looked clean. We pushed it to production, closed our laptops, and went into the weekend.</p><p>By Sunday night, I had a huge AWS bill waiting for me.</p><h3>What I Thought Would Happen</h3><p>The job was straightforward — move files from one place to another using a Lambda function. We tested it thoroughly. Files processed cleanly. Response times were acceptable. We configured the function with a 15-minute timeout (the maximum Lambda allows) to be “safe,” added 3 automatic retries for reliability, and called it a day.</p><p>What could go wrong?</p><h3>What Actually Went Wrong — A Perfect Storm</h3><h3>🔴 Problem 1: Test Files vs. Production Files</h3><p>In testing, I used files around 100MB. Clean, manageable, fast.</p><p>In production? The actual data files were 1.2GB each.</p><p>The Lambda function wasn’t built to handle that scale. It would struggle for 14 minutes and 58 seconds trying to process each oversized file — then AWS would forcibly kill it. Timed out. Every. Single. Time.</p><p>And because I was paying for <strong>duration</strong>, not success — I was billed for the full near-15 minutes of each failed run.</p><h3>🔴 Problem 2: Blind Retry Logic</h3><p>I had set up 3 automatic retries per failed job. This is standard best practice for handling transient network errors. Normally, a smart move.</p><p>Except — this wasn’t a network error. This was a permanent payload size failure. The file was always going to be too big. Retrying it three times didn’t fix anything. It just tripled the cost.</p><p>The math was brutal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*i-uqExOBL4kYxHBrcOvPpg.png" /></figure><p>And I had 5,000 files in the queue.</p><p>5,000 files × ~1 hour of failed compute = 💸</p><h3>🔴 Problem 3: CloudWatch Logging Costs</h3><p>Every failure wrote detailed error logs to AWS CloudWatch, which charges by data volume. With 5,000 files constantly failing and retrying, I was generating ~30GB of error logs per hour, all reading some variation of <em>“</em><strong>File too large.</strong><em>”</em></p><p>The logs were screaming at me. I just wasn’t watching.</p><h3>How I Fixed It</h3><p>Once I understood what went wrong, the fixes were clear — and I kicked myself for not thinking of them earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*6qoWux2dfd6bozHypsLPyg.png" /></figure><h3>✅ Fix 1: Context-Aware Retry Logic</h3><p>The root issue was that my retry logic was blind. It didn’t care <em>why</em> something failed — it just retried.</p><p>I refactored the error handling to be smart:</p><ul><li>Network timeout / transient error? → Retry. It might work next time.</li><li>Payload too large / permanent error? → Do NOT retry. Route it immediately to a Dead Letter Queue (DLQ) for manual review.</li></ul><p>This one change alone would have reduced my bill by ~75%. A permanently broken job has no business consuming three more rounds of compute time.</p><h3>✅ Fix 2: Split Large Files (Fan-Out Architecture)</h3><p>I asked myself: <strong>If I tested successfully with 100MB files, why was I throwing 1.2GB at a single Lambda invocation?</strong></p><p>The answer was — I shouldn’t have been.</p><p>I implemented a fan-out pattern:</p><ul><li>Before invoking the processing Lambda, a lightweight “splitter” function checks the file size.</li><li>If the file exceeds the threshold, it splits it into chunks (e.g., a 1.2GB file → 12 × 100MB chunks).</li><li>Each chunk is processed by its own Lambda invocation — fast, parallel, and within limits.</li></ul><p>Instead of 1 giant failed request → I now get 12 fast, successful ones.</p><h3>✅ Fix 3: Pointer Architecture — Stop Loading Files into Memory</h3><p>The other architectural mistake was passing the actual file data <em>through</em> the Lambda function’s memory. That’s like carrying 1.2GB of groceries in your hands when there’s a cart right next to you.</p><p>The correct approach:</p><ul><li>Store the file in S3 (it’s already there — just leave it there).</li><li>Pass only a pointer (the S3 file path) to the Lambda function.</li><li>The function streams the data from S3 in manageable chunks rather than loading everything into memory at once.</li></ul><p>For heavy querying scenarios, I also integrated AWS Athena to query the data directly in S3 — no loading, no memory pressure, no timeout drama.</p><h3>✅ Fix 4: Set a File Size Guard at the Entry Point</h3><p>Before any of this processing begins, I added a simple validation gate:</p><blockquote><em>If file size &gt; threshold → reject immediately and route to DLQ.</em></blockquote><p>Don’t try. Don’t timeout. Don’t retry. Just fail <strong>fast and safely</strong>, log one clean error message, and move on.</p><p>This eliminated the CloudWatch log flooding entirely.</p><h3>The Lesson I’ll Never Forget</h3><blockquote><em>“Fail safely” is not just about retrying — it’s about knowing </em>when not to<em>.</em></blockquote><p>The failures were always going to happen with that architecture. What made it a $4,200 weekend wasn’t the failure itself — it was the system’s blind insistence on failing <strong>slowly, repeatedly, and verbosely</strong>.</p><p>Test data should mirror production data in scale, retry logic should be context-aware, large payloads should be chunked or streamed, and every system should have a fast-fail gate before expensive compute kicks in.</p><p>The cloud is incredibly powerful. But it will absolutely let you foot the bill for your own mistakes — at scale, at speed, and without hesitation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c97a47f6932d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Necessary Git Commands]]></title>
            <link>https://medium.com/@VibekD1996/necessary-git-commands-36791bcee3b6?source=rss-2ed24239d477------2</link>
            <guid isPermaLink="false">https://medium.com/p/36791bcee3b6</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Vibek Dutta]]></dc:creator>
            <pubDate>Tue, 07 Mar 2023 11:17:41 GMT</pubDate>
            <atom:updated>2023-03-07T11:17:41.921Z</atom:updated>
            <content:encoded><![CDATA[<h4>git rebase</h4><p>To perform a git rebase, you first need to switch to the branch that you want to rebase onto. For example, let’s say you have a feature branch called “new-feature” that you want to rebase onto the master branch:</p><pre>git checkout master</pre><p>Next, you can run the git rebase command, specifying the branch you want to rebase:</p><pre>git rebase new-feature</pre><p>This will apply each commit from the new-feature branch onto the master branch, one at a time. If there are any conflicts, Git will pause the rebase process to allow you to resolve them.</p><p>Interactive rebase is a powerful Git command that allows you to selectively modify your commit history. With interactive rebase, you can edit commit messages, squash commits together, split a commit into multiple commits, delete commits, and more.</p><p>To perform an interactive rebase, you first need to switch to the branch that you want to modify:</p><pre>git checkout branch-name</pre><p>Next, you can run the git rebase command with the -i option to start an interactive rebase:</p><pre>git rebase -i HEAD~3</pre><p>In this example, we’re performing an interactive rebase on the last three commits in the branch. Git will open your default text editor with a list of the commits that you’re rebasing, along with a set of instructions for each commit:</p><pre>pick 1a2b3c4d5 Commit message for the first commit<br>pick 6e7f8g9h0 Commit message for the second commit<br>pick abcdef123 Another commit message</pre><pre># Rebase 1a2b3c4..abcdef1 onto 9876543<br>#<br># Commands:<br>#  p, pick = use commit<br>#  r, reword = use commit, but edit the commit message<br>#  e, edit = use commit, but stop for amending<br>#  s, squash = use commit, but meld into previous commit<br>#  f, fixup = like &quot;squash&quot;, but discard this commit&#39;s log message<br>#  x, exec = run command (the rest of the line) using shell<br>#  d, drop = remove commit<br>#<br># These lines can be re-ordered; they are executed from top to bottom.</pre><p>Each line represents a commit that you’re rebasing, with the commit message displayed next to it. The “pick” command specifies that you want to use the commit as is. You can modify the commands for each commit to perform different actions. For example, you can change “pick” to “squash” to merge two commits together:</p><pre>pick 1a2b3c4d5 Commit message for the first commit<br>squash 6e7f8g9h0 Commit message for the second commit<br>pick abcdef123 Another commit message</pre><p>Once you’ve made your changes, save and close the file. Git will then apply your changes and pause the rebase process to allow you to make further changes if necessary. You can continue the rebase process by running:</p><pre>git rebase --continue</pre><p>An interactive rebase can be a powerful tool for modifying your commit history, but it’s important to use it with caution. Modifying your commit history can make it difficult to track changes and collaborate effectively with others. When in doubt, it’s always a good idea to consult with your team before performing an interactive rebase.</p><h4>git stash</h4><p>To use git stash, you can first make changes to your code in your working directory:</p><pre># Make changes to your code<br>git add file.ts</pre><p>Next, you can use git stash to save those changes:</p><pre>git stash</pre><p>This will save your changes to a temporary stash, allowing you to switch to a different branch or perform other actions without committing your changes yet.</p><p>When you’re ready to bring back your changes, you can use git stash pop:</p><pre>git stash pop</pre><p>This will apply the changes from the stash back to your working directory.</p><h4>git reset</h4><p>To use git reset, you first need to specify the commit you want to reset to. For example, let’s say you want to reset your repository to the previous commit:</p><pre>git reset HEAD~1</pre><p>This will perform a mixed reset, which removes the changes from the staging area but keeps them in your working directory.</p><p>If you want to perform a hard reset, which removes the changes from both the staging area and your working directory, you can add the — hard option:</p><pre>git reset HEAD~1 --hard</pre><p>There are a few other scenarios in which you might use git reset. For example, you can use git reset to undo a commit. To undo the last commit, you can use the following command:</p><pre>git reset HEAD^</pre><p>This command removes the last commit from the branch but leaves the changes in the index and the working directory.</p><p>You can also use git reset to move a branch pointer. For example, if you accidentally committed changes to the wrong branch, you can use git reset to move the branch pointer to the correct commit:</p><pre>git reset &lt;commit&gt; --hard</pre><p>This command removes all changes since the specified commit and moves the branch pointer to that commit.</p><h4>Best Practices</h4><p>Here are some best practices for using Git add, commit, and pull request features:</p><ol><li>Use Git’s staging area to carefully curate changes before committing. git add is the command that adds changes to the staging area. Use it carefully, and only add the changes that you want to include in your next commit. This helps ensure that your commits are focused, readable, and represent a logical unit of work.</li><li>Write descriptive commit messages that explain the changes being made. Good commit messages are critical for code review, debugging, and maintaining a clear history of changes. A good commit message should be concise and descriptive and explain what changes were made and why.</li><li>Pull request reviews help ensure code quality and facilitate collaboration. A pull request is a proposed set of changes that are submitted for review by other members of the team. When creating a pull request, be sure to provide context, describe what changes have been made, and explain why they were made. Also, tag relevant team members for review, and respond promptly to feedback and comments.</li><li>Use Git’s branching features to organize your work. Branches allow multiple developers to work on different features or tasks in isolation without interfering with each other’s work. Be sure to follow naming conventions and keep branch names meaningful and descriptive.</li><li>Avoid force pushing to shared branches. Force pushing is a dangerous operation that can overwrite other developers’ changes. Use it with caution and only when absolutely necessary. In general, it’s best to avoid force pushing to shared branches altogether.</li></ol><h4>Conclusion</h4><p>GitHub commands are essential for any developer who wants to collaborate and share code. The above-listed commands are some of the most commonly used commands on GitHub, but there are many more that you can explore. By using these commands, you will be able to navigate through the various features and functionalities of GitHub, making it easier to manage your code and work with others.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=36791bcee3b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS EventBridge]]></title>
            <link>https://medium.com/@VibekD1996/aws-eventbridge-993a38f924dd?source=rss-2ed24239d477------2</link>
            <guid isPermaLink="false">https://medium.com/p/993a38f924dd</guid>
            <category><![CDATA[eventbus]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[event-driven-systems]]></category>
            <category><![CDATA[aws-eventbridge]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <dc:creator><![CDATA[Vibek Dutta]]></dc:creator>
            <pubDate>Mon, 09 May 2022 08:45:45 GMT</pubDate>
            <atom:updated>2022-05-09T08:45:45.307Z</atom:updated>
            <content:encoded><![CDATA[<p>Amazon EventBridge is a serverless event bus that makes it easier to build event-driven applications at scale using events generated from your applications, integrated SaaS applications, and AWS services. We can set up routing rules to determine where to send our data to build application architectures that react in real-time to our data sources with event publishers and consumers completely decoupled.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GL5xsUJ9J1qe35FW" /><figcaption>Event Bridge as a message router</figcaption></figure><p>In simple terms, Amazon EventBridge is a serverless event bus that helps connect services with data. In an event-driven architecture, AWS EventBridge acts as the coordinator to choreograph the interactions between different microservices using events.</p><blockquote><strong>Event Bus</strong></blockquote><p>An event bus receives events from a source and routes them to rules associated with that event bus. We can also filter out what type of events are published onto event bus by creating rules.</p><p>Our account’s default event bus receives events from AWS services. A custom event bus can receive events from your custom applications and services</p><p>Events are represented in the JSON format where we specify fields such as the Source (Source Name), DetailType (Detail of the event), Detail (Payload) and some other metadata like the region, account ID, etc.</p><p>We can pass events from one event bus to another across multiple regions or accounts by setting up a template in the event bus Resource-Based Policy.</p><blockquote><strong>Event Bus Rules</strong></blockquote><p>Rules associated with the event bus evaluate events as they arrive. Each rule checks whether an event matches the rule’s criteria. We associate a rule with a specific event bus, so the rule only applies to events received by that event bus. We can set either Event Patterns or Schedule rules.</p><p>Schedule rules are either Fixed Rate or CRON. These events in the event bus are then handled by any processing service, say Lambda.</p><blockquote><strong>Event Pattern Types</strong></blockquote><p><strong>Predefined pattern</strong> — Provides an automatically generated template which we can further edit based on the service type and the event type of the service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/0*GnLYzliD8QjYE4e9" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/0*hZmfpDcYM76g9tPL" /></figure><p>In the above image, we can see that we have a predefined event of type Bucket Level Operations of S3 and we are only publishing the DeleteBucket and DeleteBucketPolicy.</p><p><strong>Custom patterns </strong>— This allows us to create rules on our own based on the data payload on what we want to filter and check before publishing to the event bus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/0*7rjvkf5ullaGBajL" /></figure><p>In the above image, we can see that we have the schema of the rule and the rule will check if the event data has source=‘my-application’ or detail-type=‘orders’ or if the eventName attribute of the event data includes the data from the eventName in the event rule and only the event data satisfying the rule check will be published to the bus.</p><blockquote><strong>How Rules Work In Event Bus</strong></blockquote><p>EventBridge examines the incoming event and compares it against this rule. The rule specifies a source value of custom.myATMapp and, as this exists in the event, the pattern matches. It then routes the event to the rule’s targets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/0*9hKi7H-U6iI9UIdh" /></figure><p>The example above shows a static, exact match pattern — the attribute is either present, or it’s not. There are now additional operators available for dynamic matching based on specific comparison conditions. This provides functionality that’s similar to what you use in a SQL where clause for filtering records in a database. The image below is a summary of all the comparison operators available in EventBridge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/741/0*JickOkC8G9PBLQ_J" /></figure><p>This link provides in-depth details of advanced filtering by rules <a href="https://aws.amazon.com/blogs/compute/reducing-custom-code-by-using-advanced-rules-in-amazon-eventbridge/#:~:text=EventBridge%20allows%20up%20to%20five,the%20event%20pattern%20is%20required.">Advanced Rules</a>. Based on these EventBridge pattern matching rules we can route events to different targets conditionally based on whichever rule it matches</p><blockquote><strong>Event Bus Targets</strong></blockquote><p>A target can be an AWS service, resource or endpoint. A rule can have up to 5 targets. And based on the target we have to configure them.</p><p>Retry Policy For Targets</p><p>Eventbridge attempts to retry failed invocations.</p><p><strong>Max Age </strong>— The maximum number of periods to keep unprocessed events for, the default is 24 hours.</p><p><strong>Retry Attempts </strong>— The maximum number of attempts to send an event to a target after an error occurred, the default is 185 times.</p><p><strong>DLQ — </strong>We can also send the unprocessed events to a DLQ. We can also specify a DLQ that is in another AWS account. We need to just paste the ARN of the DLQ. The event that is sent to the DLQ consists of additional metadata like errorCode, errorMessage and targetARN which we can check why the delivery failed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/953/0*96rD5q3U7k0pQR2Q" /></figure><blockquote><strong>EventBridge Schema Registry</strong></blockquote><p>A schema defines the structure of events that are sent to EventBridge. EventBridge provides schemas for all events that are generated by AWS services. You can also create or upload custom schemas or infer schemas directly from events on an event bus. We need to turn on the Schema Discovery for an event bus.</p><p>We can select schemas related to AWS services that are already present or can group schemas by creating our own custom schema registry. Once you have a schema for an event, you can download code bindings for popular programming languages and speed up development. You can work with code bindings for schemas and manage schemas from the EventBridge console, by using the API, or directly in your IDE.</p><p>We can use the schema to discover the structure of the data that is being published into the event bus. There is no enforcement though on what we want to publish to the event bus, it is just for client-side validation. We could use this schema to validate the data with respect to the schema before publishing it into the event bus.</p><ul><li>Store schemas in a central location</li><li>Download code bindings to use in code quickly</li><li>Predefined schemas available</li><li>Can automatically discover schemas from the incoming input events and put them in the schema registry</li><li>Using the schema we can also do message transformation before sending it to the target</li></ul><blockquote><strong>How To Pass Events Between EventBus</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/733/0*wV_lhNmUr2QMy8gX" /></figure><p>We can pass events from one event bus to another across multiple regions or accounts by setting up a template in the event bus Resource-Based Policy. The steps are</p><ul><li>We need to create an event bus in account 1 which will act as the publisher of events to the event bus on account 2.</li><li>Go to account 2 and create an event bus with a name</li><li>Provide Resource-Based Policy (allows us to define specific resources and entities to publish to this event bus) by Load Template by putting in the details of the resource that can publish events into this event bus</li><li>Copy the ARN of this event bus and go back to account 1</li><li>In the target section of the event bus in account 1, select the “EventBus in different region or account” option for the target and paste the ARN of the event bus of account 2</li></ul><blockquote><strong>SNS vs SQS vs EventBridge</strong></blockquote><p>In SNS we publish a message to a topic and then the multiple subscribers to that topic get that message. It is a push-based model.</p><p>In SQS we publish the message to a queue and the consumer polls that message from the queue. Only one subscriber for a queue. It is a polling-based mode</p><p>In EventBridge we publish the message to the event bus and from there the subscribers get the message. It is also a push-based model.</p><p>SNS scales automatically, using Lambda per function concurrency setting to control downstream consumption.<br>SQS also scales automatically, using Lambda trigger batch size and per function concurrency setting to control downstream consumption.<br>EventBridge scales automatically up with a default quota of 400 PutEvents and 750 target invocation requests per second. Use Lambda per function concurrency setting to control downstream consumption.</p><p>Conditional message processing in SNS is that it can invoke different subscribers based on values on message metadata using SNS message filtering. Input Transformation like EventBridge is not available and the conditional message filtering is also not very flexible as we cannot transform parts of the message and define the metadata clearly.</p><p>Conditional message processing in SQS is that it can’t decide the consumer based on the message. Use SNS filtering with SQS to achieve this.<br>Conditional message processing in EventBridge is that it has event filtering which can route messages to targets based on the message. It can also transform events by Input Transform action before sending to the target. It also has a schema registry. It can auto-discover the event schema, so we don’t have to do it manually.</p><p>In SNS messages are gone once delivered to subscribers. No replay functionality</p><p>In SQS messages are gone once delivered to the consumer. No replay functionality</p><p>In EventBridge messages can be archived based on rules and can be replayed later. The benefit is we can archive the event message rather than running the producer again to produce the same event. So it’s convenient</p><p>In SNS message filtering can be done only on the message attributes<br>In SQS message filtering can be done only on the message attributes</p><p>In EventBridge message, filtering can be done on the entire message body</p><p>SNS FIFO maintains message order<br>SQS FIFO maintains message order<br>EventBridge message order not maintained</p><p>In SNS messages at rest can be encrypted using KMS</p><p>In SQS messages at rest can be encrypted using KMS</p><p>In EventBridge messages at rest cannot be encrypted using KMS</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=993a38f924dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Athena]]></title>
            <link>https://medium.com/@VibekD1996/aws-athena-f06dce2e1891?source=rss-2ed24239d477------2</link>
            <guid isPermaLink="false">https://medium.com/p/f06dce2e1891</guid>
            <category><![CDATA[aws-athena]]></category>
            <category><![CDATA[etl-pipeline]]></category>
            <category><![CDATA[data-crawling]]></category>
            <category><![CDATA[data-science-aws]]></category>
            <dc:creator><![CDATA[Vibek Dutta]]></dc:creator>
            <pubDate>Mon, 09 May 2022 08:29:19 GMT</pubDate>
            <atom:updated>2022-05-09T08:29:19.763Z</atom:updated>
            <content:encoded><![CDATA[<p>Amazon Athena is an interactive data analysis tool used to process complex queries in relatively less time, breaking the complex queries into simpler ones and running them parallelly, then combining the results to give the desired output.</p><p>It is server-less hence, there is no hassle of setting up and doesn’t require managing the infrastructure, configuration, scaling or failure of the service.</p><p>It is not a Database service hence, you just pay for the queries you run. You just point your data in S3, define the schema required and with standard SQL queries.</p><p>Athena helps you analyze unstructured, semi-structured and structured data that is stored in Amazon S3. Athena works with AWS Glue to give you a better way to store the metadata of the data schema in S3 with the help of crawlers.</p><blockquote><strong>Role Of AWS Glue In AWS Athena</strong></blockquote><p>AWS Glue can catalogue your Amazon S3 data, making it available for querying with Amazon Athena. Firstly, you define a crawler to populate your AWS Glue Data Catalog with metadata table definitions from the S3 data source file. You point your crawler at a data store, and the crawler creates table definitions in the Data Catalog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/776/0*h8zK-hHjWfefyf0v" /><figcaption>Athena Workflow</figcaption></figure><p>Say you upload a CSV or a JSON file in your S3 bucket. A crawler that connects to the data store i.e. the S3 bucket file path, progresses through a prioritized list of classifiers to determine the schema for your data and then creates metadata tables in the Data Catalog which is a persistent metadata store in AWS Glue that contains table definitions</p><p>While attaching a crawler to a data source you have to name a database to which the crawler is going to create the table for the scanned schema from the S3 data source file.</p><p><strong>Crawler </strong>— A program that connects to a data store (source or target), progresses through a prioritized list of classifiers to determine the schema for your data and then creates metadata tables in the Data Catalog.</p><p><strong>Data Catalog</strong> — A persistent metadata store in AWS Glue. It contains table definitions, job definitions, and other control information to manage your AWS Glue environment.</p><p><strong>Work Group</strong> — Each workgroup that you create shows saved queries and query history only for queries that ran in it, and not for all queries in the account. This separates your queries from other queries within an account and makes it more efficient for you to locate your own saved queries and queries in history.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/0*X5jM4e8QhPl8kXvE" /></figure><blockquote><strong>Athena Queries</strong></blockquote><ul><li>Query results and metadata are stored in S3 so that you don’t have to run the same query again to scan the data and retrieve the same dataset</li><li>For storing the query results you need to specify the output folder in S3</li><li>Stored procedures and certain DDL queries are not supported</li><li>Federated queries help to join query results from multiple sources like DynamoDB, JDBC connectors and other AWS services</li></ul><blockquote><strong>Athena Cost Model</strong></blockquote><ul><li>$5 per TB data scanned</li><li>Charged for the number of bytes scanned with a minimum of 10MB per query</li><li>No charge for DDL(Create, Alter, Drop) and failed queries</li><li>Charged for cancelled queries for the data scanned</li><li>Using partitions can help reduce cost</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f06dce2e1891" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>