<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Matthew Scharley</title>
    <description>The latest articles on DEV Community by Matthew Scharley (@mscharley).</description>
    <link>https://dev.to/mscharley</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2129102%2Fce7a25c1-9a26-41cf-b95e-b2f1cd2dc4f5.png</url>
      <title>DEV Community: Matthew Scharley</title>
      <link>https://dev.to/mscharley</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mscharley"/>
    <language>en</language>
    <item>
      <title>Installing Tailscale on immutable Linux distros</title>
      <dc:creator>Matthew Scharley</dc:creator>
      <pubDate>Mon, 18 Nov 2024 00:08:47 +0000</pubDate>
      <link>https://dev.to/mscharley/tailscale-on-immutable-linux-3j92</link>
      <guid>https://dev.to/mscharley/tailscale-on-immutable-linux-3j92</guid>
      <description>&lt;p&gt;Recently I've been testing OpenSUSE Kalpa, one of the recent batch of immutable operating systems. One of the first things I wanted to setup was Tailscale so that the laptop could connect back into my home network. For anyone unfamiliar, Tailscale is a really cool product for doing mesh VPNs.&lt;/p&gt;

&lt;p&gt;The following instructions should work on any system with &lt;code&gt;distrobox&lt;/code&gt; available, but it's especially useful for Kalpa and other immutable operating systems.&lt;/p&gt;

&lt;p&gt;There's no official instructions for getting things going with distrobox, but thankfully it takes basically no extra effort.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Tailscale
&lt;/h2&gt;

&lt;p&gt;First, you need to create a new root distrobox with &lt;a href="https://github.com/89luca89/distrobox/blob/main/docs/useful_tips.md#using-init-system-inside-a-distrobox" rel="noopener noreferrer"&gt;init system support&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo mkdir&lt;/span&gt; /var/run/tailscale
distrobox create &lt;span class="nt"&gt;--root&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; tailscale &lt;span class="nt"&gt;--image&lt;/span&gt; registry.opensuse.org/opensuse/tumbleweed:latest &lt;span class="nt"&gt;--volume&lt;/span&gt; /var/run/tailscale:/var/run/tailscale:rw &lt;span class="nt"&gt;--image&lt;/span&gt; registry.opensuse.org/opensuse/tumbleweed:latest &lt;span class="nt"&gt;--init&lt;/span&gt; &lt;span class="nt"&gt;--additional-packages&lt;/span&gt; &lt;span class="s2"&gt;"systemd"&lt;/span&gt;
distrobox enter &lt;span class="nt"&gt;--root&lt;/span&gt; tailscale
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Since this is a root distrobox, you'll be asked for a password for access to the distrobox. Once you're fully inside the distrobox, follow &lt;a href="https://tailscale.com/kb/1047/install-opensuse-tumbleweed" rel="noopener noreferrer"&gt;the normal installation instructions&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;rpm &lt;span class="nt"&gt;--import&lt;/span&gt; https://pkgs.tailscale.com/stable/opensuse/tumbleweed/repo.gpg
&lt;span class="nb"&gt;sudo &lt;/span&gt;zypper ar &lt;span class="nt"&gt;-g&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; https://pkgs.tailscale.com/stable/opensuse/tumbleweed/tailscale.repo
&lt;span class="nb"&gt;sudo &lt;/span&gt;zypper ref
&lt;span class="nb"&gt;sudo &lt;/span&gt;zypper &lt;span class="k"&gt;in &lt;/span&gt;tailscale
&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl &lt;span class="nb"&gt;enable&lt;/span&gt; &lt;span class="nt"&gt;--now&lt;/span&gt; tailscaled
&lt;span class="c"&gt;# Allow using tailscale without two passwords&lt;/span&gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;tailscale &lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;--operator&lt;/span&gt; &lt;span class="nv"&gt;$USER&lt;/span&gt;
&lt;span class="c"&gt;# Expose the binaries to the host system&lt;/span&gt;
distrobox-export &lt;span class="nt"&gt;--bin&lt;/span&gt; /bin/tailscale
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can drop back out of the distrobox container and use &lt;code&gt;tailscale&lt;/code&gt; as normal, eg. &lt;code&gt;tailscale up&lt;/code&gt; to login and get setup.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start on boot
&lt;/h3&gt;

&lt;p&gt;This setup will not start on boot, but will start when the distrobox starts. If you want it to start automatically on boot then you can start distrobox at login using a systemd service.&lt;/p&gt;

&lt;p&gt;First, create a small shell script which will start the container. I use &lt;code&gt;/root/bin/start-tailscale.sh&lt;/code&gt; for this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class="c"&gt;# Precreate the volume that distrobox expects&lt;/span&gt;
&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /run/tailscale
&lt;span class="c"&gt;# Start the container manually&lt;/span&gt;
podman start tailscale
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure to set this as executable with &lt;code&gt;chmod a+x /root/bin/start-tailscale.sh&lt;/code&gt;. After this, create a new systemd service file in &lt;code&gt;/etc/systemd/system/tailscale.service&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ini"&gt;&lt;code&gt;&lt;span class="nn"&gt;[Unit]&lt;/span&gt;
&lt;span class="py"&gt;Description&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;Tailscale VPN&lt;/span&gt;
&lt;span class="py"&gt;After&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;network.target&lt;/span&gt;
&lt;span class="py"&gt;After&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;network-online.target&lt;/span&gt;

&lt;span class="nn"&gt;[Service]&lt;/span&gt;
&lt;span class="py"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;oneshot&lt;/span&gt;
&lt;span class="py"&gt;ExecStart&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;/root/bin/start-tailscale.sh&lt;/span&gt;

&lt;span class="nn"&gt;[Install]&lt;/span&gt;
&lt;span class="py"&gt;WantedBy&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;multi-user.target&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once this file is created, you can use the following commands to test the new service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Tell systemd to load the new service file
systemd daemon-reload
# Do a test start
systemd start tailscale
# Enable on next boot
systemd enable tailscale
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Caveats
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;sudo tailscale&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Anywhere you see &lt;code&gt;sudo tailscale&lt;/code&gt; in the documentation, you can just use &lt;code&gt;tailscale&lt;/code&gt; instead. Distrobox will install the binary stub into your local user account and deal with sudo for you. If you try to use sudo yourself, then it's likely that it won't be able to find the &lt;code&gt;tailscale&lt;/code&gt; stub since it's installed into your home folder and won't be on the sudo &lt;code&gt;$PATH&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The client socket
&lt;/h3&gt;

&lt;p&gt;The setup above will map the client socket to the host machine correctly, but in my testing unless you also setup the on-boot startup then flatpaks will not be able to access the socket correctly. I haven't managed to fully identify why this happens, but it's working for me properly now. Without the systemd service, Trayscale would simply time out while trying to connect to the unix socket.&lt;/p&gt;

&lt;h3&gt;
  
  
  MagicDNS
&lt;/h3&gt;

&lt;p&gt;I haven't fully tested MagicDNS yet, but I suspect it doesn't work properly with this setup as &lt;code&gt;tailscale status&lt;/code&gt; will complain about not being able to manage &lt;code&gt;resolve.conf&lt;/code&gt;.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>tailscale</category>
      <category>opensuse</category>
      <category>distrobox</category>
    </item>
  </channel>
</rss>
