<?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: Vulcan Shen</title>
    <description>The latest articles on DEV Community by Vulcan Shen (@vulcan_shen_acdbffa0285d2).</description>
    <link>https://dev.to/vulcan_shen_acdbffa0285d2</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%2F3874809%2F48989896-dd70-436a-bb13-2b5bd2739722.png</url>
      <title>DEV Community: Vulcan Shen</title>
      <link>https://dev.to/vulcan_shen_acdbffa0285d2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vulcan_shen_acdbffa0285d2"/>
    <language>en</language>
    <item>
      <title>I built a CLI to stop explaining what /etc/hosts is</title>
      <dc:creator>Vulcan Shen</dc:creator>
      <pubDate>Sun, 12 Apr 2026 11:49:16 +0000</pubDate>
      <link>https://dev.to/vulcan_shen_acdbffa0285d2/i-built-a-cli-to-stop-explaining-what-etchosts-is-4f0o</link>
      <guid>https://dev.to/vulcan_shen_acdbffa0285d2/i-built-a-cli-to-stop-explaining-what-etchosts-is-4f0o</guid>
      <description>&lt;p&gt;Last month, a PM asked me to point &lt;code&gt;api.staging.local&lt;/code&gt; to a new IP. I spent 15 minutes explaining what &lt;code&gt;/etc/hosts&lt;/code&gt; is. Then I did it for them anyway.&lt;/p&gt;

&lt;p&gt;This happens a lot. So I built &lt;a href="https://github.com/vulcanshen/hostfile" rel="noopener noreferrer"&gt;hostfile&lt;/a&gt; — a CLI that turns hosts file management into copy-pasteable one-liners.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fvulcanshen%2Fhostfile%2Fmain%2Fdocs%2Fdemo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fraw.githubusercontent.com%2Fvulcanshen%2Fhostfile%2Fmain%2Fdocs%2Fdemo.gif" alt="demo" width="720" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What's wrong with existing tools
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Manual editing&lt;/strong&gt; is risky. One wrong move and DNS resolution breaks. Non-technical users shouldn't be anywhere near &lt;code&gt;vim /etc/hosts&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GUI tools&lt;/strong&gt; like SwitchHosts exist, but they're overkill when you just need someone to run one command. You can't paste a GUI into Slack.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Other CLIs&lt;/strong&gt; exist and work fine for developers who know what they're doing. But when you need a non-technical person to run one command without supervision, most fall apart.&lt;/p&gt;

&lt;h2&gt;
  
  
  What hostfile does differently
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Managed block isolation.&lt;/strong&gt; hostfile only touches entries between its own markers. Your hand-written entries are never modified:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="c"&gt;# Your stuff — safe
&lt;/span&gt;&lt;span class="m"&gt;127&lt;/span&gt;.&lt;span class="m"&gt;0&lt;/span&gt;.&lt;span class="m"&gt;0&lt;/span&gt;.&lt;span class="m"&gt;1&lt;/span&gt;  &lt;span class="n"&gt;localhost&lt;/span&gt;

&lt;span class="c"&gt;#### hostfile &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
&lt;/span&gt;&lt;span class="m"&gt;192&lt;/span&gt;.&lt;span class="m"&gt;168&lt;/span&gt;.&lt;span class="m"&gt;1&lt;/span&gt;.&lt;span class="m"&gt;100&lt;/span&gt;  &lt;span class="n"&gt;web&lt;/span&gt;.&lt;span class="n"&gt;local&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;.&lt;span class="n"&gt;local&lt;/span&gt;
&lt;span class="c"&gt;#### hostfile &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Enable/disable without deleting.&lt;/strong&gt; Need to temporarily turn off an entry? &lt;code&gt;hostfile disable api.local&lt;/code&gt;. Turn it back on with &lt;code&gt;hostfile enable api.local&lt;/code&gt;. No re-typing IPs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JSON I/O and pipelines.&lt;/strong&gt; Export your config as JSON, pipe it to another machine, or feed it into scripts:&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;# Export&lt;/span&gt;
hostfile show &lt;span class="nt"&gt;--json&lt;/span&gt;
&lt;span class="c"&gt;# {"192.168.1.100": ["web.local", "api.local"]}&lt;/span&gt;

&lt;span class="c"&gt;# Import via pipeline&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'{"10.0.0.1":["db.local"]}'&lt;/span&gt; | hostfile merge -

&lt;span class="c"&gt;# Sync between machines&lt;/span&gt;
hostfile show &lt;span class="nt"&gt;--json&lt;/span&gt; | ssh prod hostfile apply -
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Automatic privilege escalation.&lt;/strong&gt; hostfile handles &lt;code&gt;sudo&lt;/code&gt;, &lt;code&gt;doas&lt;/code&gt;, or &lt;code&gt;gsudo&lt;/code&gt; on Windows automatically. Users never need to remember.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Input validation.&lt;/strong&gt; Bad JSON, invalid IPs, or garbage text gets rejected before touching your hosts file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick start
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install (macOS/Linux)&lt;/span&gt;
curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://raw.githubusercontent.com/vulcanshen/hostfile/main/install.sh | sh

&lt;span class="c"&gt;# Add entries&lt;/span&gt;
hostfile add 192.168.1.100 web.local api.local

&lt;span class="c"&gt;# Save a snapshot before making changes&lt;/span&gt;
hostfile save before-migration

&lt;span class="c"&gt;# Roll back if needed&lt;/span&gt;
hostfile load before-migration

&lt;span class="c"&gt;# Done with this setup&lt;/span&gt;
hostfile clean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# macOS / Linux&lt;/span&gt;
brew &lt;span class="nb"&gt;install &lt;/span&gt;vulcanshen/tap/hostfile

&lt;span class="c"&gt;# Windows&lt;/span&gt;
irm https://raw.githubusercontent.com/vulcanshen/hostfile/main/install.ps1 | iex
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also available as &lt;code&gt;.deb&lt;/code&gt;, &lt;code&gt;.rpm&lt;/code&gt;, and Scoop. See the &lt;a href="https://github.com/vulcanshen/hostfile" rel="noopener noreferrer"&gt;README&lt;/a&gt; for all options.&lt;/p&gt;




&lt;p&gt;This isn't a revolutionary tool. It solves one specific problem: making hosts file changes safe and accessible to anyone who can copy-paste a command. If that's a problem you have, give it a try.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/vulcanshen/hostfile" rel="noopener noreferrer"&gt;GitHub: vulcanshen/hostfile&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>cli</category>
      <category>devops</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
