<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/atom.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Posts tagged: networking</title>
  <id>https://waylonwalker.com/tags/networking/atom.xml</id>
  <updated>2024-12-03T15:36:37Z</updated>
  <subtitle>All posts with the tag &#34;networking&#34;</subtitle>
  <link href="https://waylonwalker.com/tags/networking/" rel="alternate" type="text/html"></link>
  <link href="https://waylonwalker.com/tags/networking/atom.xml" rel="self" type="application/atom+xml"></link>
  <author>
    <name>Waylon Walker</name>
  </author>
  <generator uri="https://github.com/WaylonWalker/markata-go">markata-go</generator>
  <entry>
    <title>debug cloudflared tunnel</title>
    <id>https://waylonwalker.com/debug-cloudflared-tunnel/</id>
    <updated>2024-12-03T15:36:37Z</updated>
    <published>2024-12-03T15:36:37Z</published>
    <link href="https://waylonwalker.com/debug-cloudflared-tunnel/" rel="alternate" type="text/html"></link>
    <summary type="text">I&#39;ve been debugging a cloudflared tunnel issue in my homelab all day today, and getting really frustrated. My issue ended up being that it was running twice,...</summary>
    <content type="html">&lt;p&gt;I’ve been debugging a cloudflared tunnel issue in my &lt;a href=&#34;/homelab/&#34; class=&#34;glossary-term&#34; title=&#34;A place to self host applications. For me this is primarily self built web applications, and applications for sharing files with my family. Techno Tim has a...&#34;&gt;homelab&lt;/a&gt; all day today, and&#xA;getting really frustrated.  My issue ended up being that it was running twice,&#xA;once without the correct config file and another with it.  I believe that&#xA;cacheing may have compounded the issue.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;In yesterday’s post I setup a cloudflared tunnel on my ubuntu server to&#xA;expose applications running on the server to the internet.  I’m setting up a&#xA;new server and running cloudflared in its own vm.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;&lt;a href=&#34;/setup-cloudflared-tunnel-on-ubuntu/&#34; class=&#34;wikilink&#34; data-title=&#34;setup cloudflared tunnel on ubuntu&#34; data-description=&#34;I run a cloudflared tunnel on my ubuntu server to expose applications running on the server to the internet. I&amp;#39;m setting up a new server and running...&#34; data-date=&#34;2024-12-02&#34; data-preview=&#34;I run a cloudflared tunnel on my ubuntu server to expose applications running on the server to the internet. I&amp;#39;m setting up a new server and running...&#34;&gt;setup cloudflared tunnel on ubuntu&lt;/a&gt;&lt;/p&gt;&#xA;&lt;h2 id=&#34;check-that-dns-is-pointing-to-the-correct-tunnel&#34;&gt;Check that dns is pointing to the correct tunnel &lt;a href=&#34;#check-that-dns-is-pointing-to-the-correct-tunnel&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;dig subdomain.example.com&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;traceroute subdomain.example.com&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;check-that-the-tunnel-is-running&#34;&gt;Check that the tunnel is running &lt;a href=&#34;#check-that-the-tunnel-is-running&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;export&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;CLOUDFLARED_TUNNEL_ID&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;my-tunnel-id&amp;#34;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cloudflared tunnel list&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cloudflared tunnel info &lt;span class=&#34;nv&#34;&gt;$CLOUDFLARED_TUNNEL_ID&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
    <author>
      <name>Waylon Walker</name>
      <email>hello@waylonwalker.com</email>
      <uri>https://waylonwalker.com</uri>
    </author>
  </entry>
  <entry>
    <title>setup cloudflared tunnel on ubuntu</title>
    <id>https://waylonwalker.com/setup-cloudflared-tunnel-on-ubuntu/</id>
    <updated>2024-12-02T15:43:45Z</updated>
    <published>2024-12-02T15:43:45Z</published>
    <link href="https://waylonwalker.com/setup-cloudflared-tunnel-on-ubuntu/" rel="alternate" type="text/html"></link>
    <summary type="text">I run a cloudflared tunnel on my ubuntu server to expose applications running on the server to the internet. I&#39;m setting up a new server and running...</summary>
    <content type="html">&lt;p&gt;I run a cloudflared tunnel on my ubuntu server to expose applications running&#xA;on the server to the internet.  I’m setting up a new server and running&#xA;cloudflared in its own vm.&lt;/p&gt;&#xA;&lt;h2 id=&#34;get-the-cloudflared-binary&#34;&gt;Get the cloudflared binary &lt;a href=&#34;#get-the-cloudflared-binary&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -O /usr/local/bin/cloudflared&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo chmod +x /usr/local/bin/cloudflared&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;heading&#34;&gt; &lt;a href=&#34;#heading&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Now setup the config directory.  For the systemd service to work, the config&#xA;file needs to be in /etc/cloudflared.  I like to give my user rights to edit&#xA;the config file without being sudo, we will do that here by creating a group&#xA;&lt;code&gt;cloudflared&lt;/code&gt;, add ourselves to the group, give ownership of &lt;code&gt;/etc/cloudflared&lt;/code&gt;&#xA;to the group, give group write access to the directory, and refresh groups.&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo mkdir -p /etc/cloudflared&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo groupadd cloudflared&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo usermod -aG cloudflared &lt;span class=&#34;nv&#34;&gt;$USER&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo chown -R root:cloudflared /etc/cloudflared&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo chmod g+w /etc/cloudflared&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;newgrp cloudflared&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;login&#34;&gt;login &lt;a href=&#34;#login&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Now we can log into the domain zone with cloudflared.&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cloudflared tunnel login&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will give a url, follow it in a browser to log in.&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cloudflared tunnel create &amp;lt;NAME&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;mv ~/.cloudflared/cert.pem /etc/cloudflared/cert.pem&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;mv ~/.cloudflared/&amp;lt;tunnel-id&amp;gt;.json /etc/cloudflared/&amp;lt;tunnel-id&amp;gt;.json&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;config&#34;&gt;config &lt;a href=&#34;#config&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Now setup config.  For the systemd service to work, the config file needs to be&#xA;in /etc/cloudflared.  The config that I have provided below will expose&#xA;localhost:8000 to tester.example.com&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;export&lt;/span&gt; &lt;span class=&#34;nv&#34;&gt;CLOUDFLARED_TUNNEL_ID&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;=&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;$(&lt;/span&gt;ls /etc/cloudflared/*.json &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; xargs -n &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; basename &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; sed &lt;span class=&#34;s1&#34;&gt;&amp;#39;s/\.json$//&amp;#39;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;mv ~/.cloudflared/&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;CLOUDFLARED_TUNNEL_ID&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;.json /etc/cloudflared/&lt;span class=&#34;si&#34;&gt;${&lt;/span&gt;&lt;span class=&#34;nv&#34;&gt;CLOUDFLARED_TUNNEL_ID&lt;/span&gt;&lt;span class=&#34;si&#34;&gt;}&lt;/span&gt;.json&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;mv ~/.cloudflared/cert.pem /etc/cloudflared/cert.pem&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;echo&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s2&#34;&gt;tunnel: &lt;/span&gt;&lt;span class=&#34;k&#34;&gt;$(&lt;/span&gt;CLOUDFLARED_TUNNEL_ID&lt;span class=&#34;k&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s2&#34;&gt;credentials-file: /etc/cloudflared/&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;$(&lt;/span&gt;CLOUDFLARED_TUNNEL_ID&lt;span class=&#34;k&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;.json&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s2&#34;&gt;ingress:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s2&#34;&gt;  - hostname: tester.example.com&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s2&#34;&gt;    service: http://localhost:8000&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s2&#34;&gt;  - service: &amp;#39;http_status:404&amp;#39;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;&lt;/span&gt; &amp;gt;&amp;gt; /etc/cloudflared/config.yaml&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;dns&#34;&gt;dns &lt;a href=&#34;#dns&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Now to get a dns record for tester.example.com to point to the cloudflared&#xA;tunnel.&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cloudflared tunnel route dns &lt;span class=&#34;k&#34;&gt;$(&lt;/span&gt;CLOUDFLARED_TUNNEL_ID&lt;span class=&#34;k&#34;&gt;)&lt;/span&gt; tester.example.com&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;systemd&#34;&gt;systemd &lt;a href=&#34;#systemd&#34; class=&#34;heading-anchor&#34;&gt;#&lt;/a&gt;&lt;/h2&gt;&#xA;&lt;p&gt;Now install the systemd service.&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo cloudflared service install&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo systemctl status cloudflared.service&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# if its not running&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;sudo systemctl start cloudflared.service&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
    <author>
      <name>Waylon Walker</name>
      <email>hello@waylonwalker.com</email>
      <uri>https://waylonwalker.com</uri>
    </author>
  </entry>
</feed>