<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>pcarleton&apos;s blog</title>
    <description>Thoughts on software by Paul Carleton
</description>
    <link>http://pcarleton.github.io/</link>
    <atom:link href="http://pcarleton.github.io/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Mon, 27 Jul 2026 19:14:04 +0000</pubDate>
    <lastBuildDate>Mon, 27 Jul 2026 19:14:04 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>TIL: The difference between netstat and ss</title>
        <description>&lt;h3 id=&quot;motivation&quot;&gt;Motivation&lt;/h3&gt;

&lt;p&gt;In this post, I’m going to go over two tools for inspecting the socket states (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstat&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ss&lt;/code&gt;), and why to choose one over the other (spoiler: you can really choose either).   This is not going to be a 12 ways to inspect socket states article, there are lots of those.&lt;/p&gt;

&lt;h3 id=&quot;what-is-a-socket&quot;&gt;What is a socket?&lt;/h3&gt;

&lt;p&gt;A socket is a Linux file descriptor for communicating with the network. In Linux, they say everything is a file.  In this case, you can treat a socket like a file that writes to the network instead of writing to a disk.  Sockets come in different flavors for TCP vs. UDP.  For more on sockets, checkout these links:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://man7.org/tlpi/&quot;&gt;The Linux Programming Interface&lt;/a&gt; (this is really great)&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://beej.us/guide/bgnet/html/multi/theory.html&quot;&gt;Beej’s Network Programming Guide&lt;/a&gt; (not quite TLPI, but available for free)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;why-would-i-care-about-sockets&quot;&gt;Why would I care about sockets?&lt;/h3&gt;

&lt;p&gt;Sockets can be in a bunch of different states (listed in &lt;a href=&quot;https://github.com/sivasankariit/iproute2/blob/master/misc/ss.c#L80-L92&quot;&gt;this snippet of ss&lt;/a&gt;) which can be useful to answer questions like:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Is my server process actually listening on the port I think it is?&lt;/li&gt;
  &lt;li&gt;Is it listening on the loopback interface (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;127.0.0.1&lt;/code&gt;), or could someone on my network connect to it (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;*&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0.0.0.0&lt;/code&gt;)?  (This can be bad if you’re developing something and running a database that anyone in the coffee shop can make requests to)&lt;/li&gt;
  &lt;li&gt;What processes are listening on what ports in general?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These questions pertain to sockets that are listening on a host, but there are also various connected states a socket can be in.  &lt;a href=&quot;https://hpbn.co/building-blocks-of-tcp/#three-way-handshake&quot;&gt;High Performance Browser Networking&lt;/a&gt;’s TCP overview if great for some explanation of the other states (or again &lt;a href=&quot;http://man7.org/tlpi/&quot;&gt;TLPI&lt;/a&gt; is excellent)&lt;/p&gt;

&lt;h3 id=&quot;how-do-i-inspect-the-state-of-sockets-on-my-machine&quot;&gt;How do I inspect the state of sockets on my machine?&lt;/h3&gt;

&lt;p&gt;The two tools I’ll cover are the command line tools &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstat&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ss&lt;/code&gt;.  I’ll start with where they get their information.&lt;/p&gt;

&lt;h4 id=&quot;procfs&quot;&gt;Procfs&lt;/h4&gt;

&lt;p&gt;The &lt;a href=&quot;https://en.wikipedia.org/wiki/Procfs&quot;&gt;Procfs&lt;/a&gt; is a file system that Linux exposes that is like a peek into kernel memory.  It lives in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/proc&lt;/code&gt; and it exposes information about TCP and UDP sockets at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/proc/net/tcp&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/proc/net/udp&lt;/code&gt;.  If I &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;cat&lt;/code&gt; either of those I’ll get some inscrutable output.&lt;/p&gt;

&lt;h4 id=&quot;netlink&quot;&gt;Netlink&lt;/h4&gt;

&lt;p&gt;The other source of information is called the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netlink&lt;/code&gt; protocol.  In this case you open a socket (a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;SOCK_RAW&lt;/code&gt; with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;AF_NETLINK&lt;/code&gt; as seen &lt;a href=&quot;https://github.com/sivasankariit/iproute2/blob/1179ab033c31d2c67f406be5bcd5e4c0685855fe/misc/ss.c#L1650&quot;&gt;here&lt;/a&gt;).  I can then send requests on that socket for information about other sockets (pretty meta).  I have a lot to learn still about &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netlink&lt;/code&gt;, but here are some things I found:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.infradead.org/~tgr/libnl/doc/core.html&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;libnl&lt;/code&gt;documentation&lt;/a&gt; which is a library for interacting with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netlink&lt;/code&gt; sockets.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc3549&quot;&gt;RFC 3594&lt;/a&gt; – Linux Netlink as an IP Services Protocol&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;netstat-vs-ss&quot;&gt;Netstat vs. ss&lt;/h3&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstat&lt;/code&gt; gets its information from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/proc/net&lt;/code&gt; directly.  It parses the file and prints out information based on it.&lt;/p&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ss&lt;/code&gt; was written more recently to use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netlink&lt;/code&gt; API (it will fall back to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;proc/net&lt;/code&gt; if netlink is unavailable).  The information in both systems is essentially the same (from what I’ve seen), but here are some arguments for why to use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ss&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;It’s faster (I just read that a lot, I don’t find &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstat&lt;/code&gt; to be noticeably slower)&lt;/li&gt;
  &lt;li&gt;Netlink exposes more TCP states (again I mostly look for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;LISTEN&lt;/code&gt; so that’s not a huge selling point)&lt;/li&gt;
  &lt;li&gt;It has better default argument&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of these are a huge homerun, which is why I expect a lot of people still use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstat&lt;/code&gt;.  It’s also likely that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstat&lt;/code&gt; is installed more places. For instance my Macbook has &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstat&lt;/code&gt; but not &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ss&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The default arguments is a little more compelling.  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstat&lt;/code&gt; by default will try to resolve IP addresses through DNS which really slows it down. It also opens a bunch of new UDP sockets, which might clutter the picture if you’re investigating something.  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstat -n&lt;/code&gt; stops this behavior, but &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ss&lt;/code&gt; has that on by default (you can use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ss -r&lt;/code&gt; if you do want the resolution).&lt;/p&gt;

&lt;p&gt;One other nice thing about &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ss&lt;/code&gt; is that its source code is much nicer to read!&lt;/p&gt;

&lt;h3 id=&quot;open-questions&quot;&gt;Open Questions&lt;/h3&gt;

&lt;p&gt;Here are some things I am still wondering&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;What are the states that netlink supports that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;netstat&lt;/code&gt; won’t show? Are they states I actually care about?&lt;/li&gt;
  &lt;li&gt;Where does &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;lsof -i&lt;/code&gt; fit in with all of this? Why would I choose that over &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ss&lt;/code&gt;?&lt;/li&gt;
  &lt;li&gt;What other users are there for netlink?&lt;/li&gt;
  &lt;li&gt;Can I use netlink to poll for any new UDP connection? (I’ve been wanting to do this to figure out what process is sending UDP packets to a particular IP address, which is easy with TCP but hard with UDP)&lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Thu, 31 May 2018 00:00:00 +0000</pubDate>
        <link>http://pcarleton.github.io/2018/05/31/netstat-v-ss.html</link>
        <guid isPermaLink="true">http://pcarleton.github.io/2018/05/31/netstat-v-ss.html</guid>
        
        
      </item>
    
      <item>
        <title>New Format: Today I Learned</title>
        <description>&lt;p&gt;I am going to try a new format where I write about something I learned.  My goals with this format are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Increase the amount of writing I do&lt;/li&gt;
  &lt;li&gt;Increase the frequency of writing&lt;/li&gt;
  &lt;li&gt;Lower the barrier for making a new post&lt;/li&gt;
  &lt;li&gt;Document things I’ve learned&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My rough goal is to spend:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;20 minutes researching / outlining&lt;/li&gt;
  &lt;li&gt;20 minutes writing&lt;/li&gt;
  &lt;li&gt;20 minutes editting&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We’ll see how this time commitment works out, it may be a little extreme for daily writing. I’m going to try it for the next 3 days and then re-evaluate.&lt;/p&gt;

</description>
        <pubDate>Wed, 30 May 2018 00:00:00 +0000</pubDate>
        <link>http://pcarleton.github.io/2018/05/30/til.html</link>
        <guid isPermaLink="true">http://pcarleton.github.io/2018/05/30/til.html</guid>
        
        
      </item>
    
      <item>
        <title>TIL: There are 16 T1 Internet Service Providers</title>
        <description>&lt;p&gt;I’ve been collecting information for a “Practical Guide to Linux Networking” by reading material I can find.  Two things I’ve been reading recently are:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.nanog.org/meetings/nanog47/presentations/Sunday/RAS_Traceroute_N47_Sun.pdf&quot;&gt;A Practical Guide to (Correctly) Troubleshooting with Traceroute&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;a presentation by Richard A Steenbergen&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.amazon.com/Computer-Networking-Top-Down-Approach-6th/dp/0132856204&quot;&gt;Compute Networking: A Top Down Approach&lt;/a&gt;
    &lt;ul&gt;
      &lt;li&gt;a textbook by Kurose and Ross&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the traceroute guide, Richard mentions that it’s useful to find the boundaries of your network and that it’s also useful to be able to translate DNS names to ISP’s. It seemed highly unlikely that I would ever be able to do this translation given the examples shown, like:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;p16-1-0-0.r21.asbnva01.us.bb.verio.net
ldn-bb2-link.telia.net
tbr2.wswdc.ip.att.net
xe-3-0-0.cr1.nyc3.us.nlayer.net
te2-4.ar5.PAO2.gblx.net
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Sure, I can see that there are some words just before the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.net&lt;/code&gt;, but I don’t have any mapping of what that means. I was imagining a list of international Comcasts that I would never be able to remember.  However, “Computer Networking”, they mention that the list of T1 ISP’s is actually pretty small!&lt;/p&gt;

&lt;p&gt;Here they are:&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;Provider&lt;/th&gt;
      &lt;th&gt;Country&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;AT&amp;amp;T  &lt;/td&gt;
      &lt;td&gt;USA&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;CenturyLink (formerly Level3, Global Crossing (gblx) and some others)&lt;/td&gt;
      &lt;td&gt;USA&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Deutsche Telekom AG (ICSS)&lt;/td&gt;
      &lt;td&gt;Germany&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;GTT (formerly Tinet &amp;amp; nLayer)&lt;/td&gt;
      &lt;td&gt;USA&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;KPN International&lt;/td&gt;
      &lt;td&gt;Netherlands&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Liberty Global&lt;/td&gt;
      &lt;td&gt;UK&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;NTT Communications (formerly Verio)&lt;/td&gt;
      &lt;td&gt;Japan&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Orange (OpenTransit)&lt;/td&gt;
      &lt;td&gt;France&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;PCCW Global&lt;/td&gt;
      &lt;td&gt;Hong Kong&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Sprint&lt;/td&gt;
      &lt;td&gt;Japan&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Tata Commmunications&lt;/td&gt;
      &lt;td&gt;India&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Telecom Italia Sparkle&lt;/td&gt;
      &lt;td&gt;Italy&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Telxius (subsidiary Telefonica)&lt;/td&gt;
      &lt;td&gt;Spain&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Telia Carrier&lt;/td&gt;
      &lt;td&gt;Sweden&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Verizon Enterprise Solutions (UUNET &amp;amp; XO Communications)&lt;/td&gt;
      &lt;td&gt;USA&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;Zayo Group (formerly AboveNet)&lt;/td&gt;
      &lt;td&gt;USA&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Granted, that’s still a lot, but at least it’s tractable.  And knowing there’s a small list makes it more tractable to look up when I don’t see one I recognize (rather than google “All names of internet providers, ever…”)&lt;/p&gt;

&lt;p&gt;I wanted to find what some of their hostnames looked like. So I tried some random tracerouting starting with the company name &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.net&lt;/code&gt; also trying some variations of former names.  This worked pretty well! I also tried in TCP mode with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo traceroute -T&lt;/code&gt; which uncovered a few that eluded the first attempts.  Here are the non-exhaustive results.&lt;/p&gt;

&lt;h3 id=&quot;att&quot;&gt;AT&amp;amp;T&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ traceroute att.net
...
 8  cr2.sffca.ip.att.net (12.122.149.134)  75.585 ms  76.402 ms  75.958 ms
...
10  cr2.dlstx.ip.att.net (12.122.2.81)  78.300 ms  77.370 ms  78.694 ms
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We can see we jumped from SF over to Dallas Texas!&lt;/p&gt;

&lt;h3 id=&quot;centurylink&quot;&gt;CenturyLink&lt;/h3&gt;

&lt;p&gt;I tried &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;centurylink.com&lt;/code&gt; but that didn’t give me anything, so I tried:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ traceroute level3.net
...
 6  lag-14.ear2.SanJose1.Level3.net (4.68.72.101)  18.185 ms  16.268 ms  17.309 ms
 7  * * *
 8  4.68.88.74 (4.68.88.74)  39.986 ms  41.772 ms  41.428 ms
 9  * * *
10  Level3IsNowCenturylink.com (4.68.80.110)  41.310 ms  41.700 ms  36.501 ms

# Similarly for globalcrossing.com
10  thenewcenturylink.com (4.68.80.110)  43.422 ms  37.603 ms  37.615 ms
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;deutsche-telekom-ag-icss&quot;&gt;Deutsche Telekom AG (ICSS)&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo traceroute -T telekom.com
...
9  m-eb7-i.M.DE.NET.DTAG.DE (217.5.69.14)  180.473 ms  175.974 ms  176.948 ms

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

&lt;h3 id=&quot;gtt-communications&quot;&gt;GTT Communications&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ traceroute tinet.net
...
 8  xe-7-3-0.cr0-trn3.ip4.gtt.net (89.149.184.162)  180.859 ms  179.917 ms  181.247 ms
 9  it-farm-gw2.ip4.gtt.net (77.67.94.202)  203.231 ms  198.183 ms  203.110 ms

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

&lt;h3 id=&quot;kpn-international&quot;&gt;KPN International&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ traceroute kpn.com 
 6  lag-14.ear2.SanJose1.Level3.net (4.68.72.101)  25.916 ms  17.694 ms  18.140 ms
 7  ae-237-3613.edge6.Amsterdam1.Level3.net (4.69.162.242)  158.544 ms  151.896 ms  153.006 ms
 8  IPTRIPLEPLA.edge6.Amsterdam1.Level3.net (212.72.47.250)  157.888 ms  159.041 ms  158.746 ms
 9  * * *
10  cca-iaas-cr01.net.kpnvdc.nl (145.128.23.193)  159.382 ms  159.334 ms  159.067 ms
11  145.128.23.242 (145.128.23.242)  159.278 ms  159.481 ms  159.424 ms
12  apd-iaas-cr01.net.kpnvdc.nl (145.128.13.146)  171.001 ms  165.615 ms  165.130 ms
13  * * *
14  static.kpnvdc.nl (145.128.64.11)  160.604 ms  161.201 ms  161.399 ms

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

&lt;h3 id=&quot;sprint&quot;&gt;Sprint&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ sudo traceroute -T sprint.net
...
18  sl-sprin881-320471-0.sprintlink.net (144.223.33.34)  85.353 ms  84.287 ms  97.713 ms
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;open-questions&quot;&gt;Open Questions&lt;/h3&gt;

&lt;p&gt;After digging in to this stuff, I still had some questions.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;What is an AS number? And how does it translate to IP CIDR ranges?&lt;/li&gt;
  &lt;li&gt;Is there a map of T1 endpoints somewhere?&lt;/li&gt;
  &lt;li&gt;How much does someone pay to send traffic over a T1?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;other-resources&quot;&gt;Other resources:&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Tier_1_network&quot;&gt;Wikipedia: Tier 1 Network&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mtr&lt;/code&gt;is like traceroute but continuous (I wanted easy copy-pasteable output, so I stuck with traceroute.)&lt;/li&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;traceroute bad.horse&lt;/code&gt; (Just try it)
    &lt;ul&gt;
      &lt;li&gt;Also &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;openssl s_client -connect signed.bad.horse:443 -servername signed.bad.horse &amp;lt; /dev/null&lt;/code&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Wed, 30 May 2018 00:00:00 +0000</pubDate>
        <link>http://pcarleton.github.io/2018/05/30/t1-isp.html</link>
        <guid isPermaLink="true">http://pcarleton.github.io/2018/05/30/t1-isp.html</guid>
        
        
      </item>
    
      <item>
        <title>Dumb dig clone in Rust</title>
        <description>&lt;h1 id=&quot;why-write-a-dns-client&quot;&gt;Why write a DNS client&lt;/h1&gt;

&lt;p&gt;When I started digging in to DNS, I thought it would be interesting to try implementing a very simple DNS client similar to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dig&lt;/code&gt;, but using Rust. My goal was to better understand DNS at the protocol level.  I wanted to know what bytes were being sent and received to drive the system.&lt;/p&gt;

&lt;p&gt;The final result is in &lt;a href=&quot;https://github.com/pcarleton/dumb-dig&quot;&gt;this repo&lt;/a&gt;).  In the rest of the post, I’ll detail what I found out along the way.&lt;/p&gt;

&lt;h1 id=&quot;the-protocol&quot;&gt;The Protocol&lt;/h1&gt;

&lt;p&gt;The DNS protocol is detailed in &lt;a href=&quot;https://www.ietf.org/rfc/rfc1035.txt&quot;&gt;Domain Names - Implementation and Specification RFC1035&lt;/a&gt;. Section “4.1 MESSAGES - Format” details the bytes of the protocol.  Here are the ascii diagrams I found useful:&lt;/p&gt;

&lt;h3 id=&quot;message&quot;&gt;Message&lt;/h3&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
    +---------------------+
    |        Header       |
    +---------------------+
    |       Question      | the question for the name server
    +---------------------+
    |        Answer       | RRs answering the question
    +---------------------+
    |      Authority      | RRs pointing toward an authority
    +---------------------+
    |      Additional     | RRs holding additional information
    +---------------------+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;header&quot;&gt;Header&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                      ID                       |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |QR|   Opcode  |AA|TC|RD|RA|   Z    |   RCODE   |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    QDCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    ANCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    NSCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    ARCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;question-section&quot;&gt;Question Section&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                                               |
    /                     QNAME                     /
    /                                               /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                     QTYPE                     |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                     QCLASS                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;resource-record-answer&quot;&gt;Resource Record (answer)&lt;/h3&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                                               |
    /                                               /
    /                      NAME                     /
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                      TYPE                     |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                     CLASS                     |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                      TTL                      |
    |                                               |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                   RDLENGTH                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--|
    /                     RDATA                     /
    /                                               /
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h1 id=&quot;implementation&quot;&gt;Implementation&lt;/h1&gt;

&lt;p&gt;I started out by “hand” building a DNS query for google.com with hard-coded values to ensure my tool was working.  Once I had this working, I started taking input from the command line.&lt;/p&gt;

&lt;p&gt;I am relatively new to Rust, so I was initially trying to put everying on the stack and have nothign on the heap.  While a nice idea in theory, accepting input from the command line, or parsing dynamically sized elements from a server response make this pretty impractical.  I considered having a really large array and saying anything above that size wasn’t supported, but ergonomically this didn’t make the code any easier to work with.&lt;/p&gt;

&lt;p&gt;Around this time, I came across &lt;a href=&quot;https://github.com/bluejekyll/trust-dns&quot;&gt;TRust DNS&lt;/a&gt;, “A Rust based DNS client and server, built to be safe and secure from the ground up.”  I took some inspiration from the message parsing code there, specically the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bindecoder&lt;/code&gt; idea.&lt;/p&gt;

&lt;p&gt;The end result was a client that could make a very simple DNS query and spit back the response.&lt;/p&gt;

&lt;h1 id=&quot;weird-and-interesting-things-i-came-across&quot;&gt;Weird and Interesting Things I came across&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Compression.  The protocol uses a bespoke method of compression where it will refer to resource names that have previously been seen.  It starts with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;11&lt;/code&gt; in the leading bits which distinguishes it from an ordinary label because an ordinary label starts with a length byte, and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;11&lt;/code&gt; as the leading bytes would make the label too long (they’re limited to 63 bytes).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Bash has a special builtin tool for opening UDP and TCP sockets – I used this to sanity check my tool very early on (see &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hello_udp.sh&lt;/code&gt; in &lt;a href=&quot;https://github.com/pcarleton/dumb-dig&quot;&gt;the repo&lt;/a&gt;).  See &lt;a href=&quot;http://xmodulo.com/tcp-udp-socket-bash-shell.html&quot;&gt;this post&lt;/a&gt; for more details on how it works.  (Notably, these builtins are not present in Zsh which threw me off).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.icann.org/resources/pages/help/dndr/udrp-en&quot;&gt;Unified Domain-name Dispute Resolution Policy&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://songbird.com/pab/mail/0472.html&quot;&gt;Postel DNS Root incident&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://osaka.law.miami.edu/~froomkin/articles/icann-body.htm#H1N5&quot;&gt;Is ICANN legal?&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.iana.org/domains/root/tld-change-template.txt&quot;&gt;TLD Change email template&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;unanswered-questions-and-future-work&quot;&gt;Unanswered Questions and future work&lt;/h1&gt;

&lt;ul&gt;
  &lt;li&gt;Who assigns new public IP addresses? And who maintains the existing mappings?&lt;/li&gt;
  &lt;li&gt;Is there a super nice CLI library like Cobra Commander for Go in Rust?&lt;/li&gt;
  &lt;li&gt;Recently, I wanted to know which process was issuing a DNS query against a DNS host I needed to shut-down, but I couldn’t seem to do it.  It would be nice if there were a tool to trace particular traffic to an individual process.&lt;/li&gt;
  &lt;li&gt;Writing this super simple version of a common command line tool taught me a lot about how the system works on a lower level, so I’d like to try it with some other ones.&lt;/li&gt;
&lt;/ul&gt;

</description>
        <pubDate>Mon, 19 Feb 2018 00:00:00 +0000</pubDate>
        <link>http://pcarleton.github.io/2018/02/19/drt-dns-dig.html</link>
        <guid isPermaLink="true">http://pcarleton.github.io/2018/02/19/drt-dns-dig.html</guid>
        
        
      </item>
    
      <item>
        <title>Starting to figure out SSL</title>
        <description>&lt;h1 id=&quot;introduction&quot;&gt;Introduction&lt;/h1&gt;

&lt;p&gt;I’ve been slowly working towards a personal finance app, but before I can actually put it on the open web, I want to be reasonably confident that I am not opening myself up to being hacked.&lt;/p&gt;

&lt;p&gt;One of the pieces to that puzzle is having secure connections in the browser for accessing my site.  That involves HTTPS.&lt;/p&gt;

&lt;h2 id=&quot;progress&quot;&gt;Progress&lt;/h2&gt;

&lt;p&gt;Here’s what I’ve got so far.  There’s symmetric and asymmetric encryption.  Symmetric is when both parties share the same secret. They use the same secret to encode and decode messages.  In Caesar’s cipher, you shift all the letters in your message by some number N, so the secret would be N.  When somebody knows N, they can encode your message, and they can eaisly re-encode another message.&lt;/p&gt;

&lt;p&gt;Asymmetric encryption involves 2 keys: public, and private.  The public key is for encryption and the private key is for decryption.  The public key is not sensitive and can be shared.   The private key is kept secret because it is the only thing that can decrypt something that has been encrypted with the public key.  This means posting your public key somewhere is like saying here is a secure way to send me information at any point in time.  It also provides a way for you to prove your identity.  For instance, if you get a public key from a source you trust, you can verify that someone holds the private key by encrypting something, sending it to them, and having them send your message back to you..&lt;/p&gt;

&lt;h2 id=&quot;remaining-questions&quot;&gt;Remaining questions&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;How does signing of a certificate work? Like you create your public key, and then a CA signs it, but only your private key can still decrypt it?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;( Maybe there’s a portion of it that indicates that it’s signed, and then there’s your public key in there.)&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;How does the math work in symmetric and asymmetric encryption?&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;What is X.509?&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;How do I use a public key to verify something without consulting the private key? I want to verify the CA signed this thing, but that doesn’t fit in my pub-encrypt, priv-decrypt model.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To be continued!&lt;/p&gt;
</description>
        <pubDate>Wed, 14 Feb 2018 00:00:00 +0000</pubDate>
        <link>http://pcarleton.github.io/2018/02/14/ssl.html</link>
        <guid isPermaLink="true">http://pcarleton.github.io/2018/02/14/ssl.html</guid>
        
        
      </item>
    
      <item>
        <title>Meandering History of DNS Authority</title>
        <description>&lt;p&gt;As a follow up to my DNS post, I started trying to answer “Who’s in charge of all this?”.&lt;/p&gt;

&lt;p&gt;Basically, I wanted to know what keeps me from claiming a different domain name or for that matter for claiming a different IP address.&lt;/p&gt;

&lt;p&gt;I went down a rabbit hole of RFC’s and never quite pulled out the answer to my question, but I wanted to post what I did find out since it’s been languishing in my drafts for too long.&lt;/p&gt;

&lt;h2 id=&quot;summary&quot;&gt;Summary&lt;/h2&gt;

&lt;p&gt;Systems were each keeping track of the list of “names” of hosts and their “addresses” (which seem to just be decimal numbers, it’s unclear what protocol these addresses were for as this was before the IP protocol was developed.).&lt;/p&gt;

&lt;p&gt;In 1973, the NIC put out an official list of host names and addresses, afterwhich somebody suggested that the NIC maintain a file that other hosts can pull down.  The NIC agreed, and started serving a “HOSTS.TXT” file in ASCII format with the host name and addresses available via FTP.&lt;/p&gt;

&lt;p&gt;In 1981, Internet Protocol (IP) was introduced, and J. Postel put out a list of IP ranges assigned to existing networks.  These networks were free to assign IP addresses in that range as they saw fit.&lt;/p&gt;

&lt;p&gt;In 1982, Feinler updates the HOSTS.TXT format to use IP addresses and to specify networks, gateways and hosts separately.&lt;/p&gt;

&lt;h3 id=&quot;1969&quot;&gt;1969&lt;/h3&gt;

&lt;p&gt;First computers linked&lt;/p&gt;

&lt;p&gt;Engelbart volunteers Stanford Research Institute (SRI) to be the Network Information Center (NIC) since he has NLS (oN-Line System) which could help manage it.&lt;/p&gt;

&lt;h3 id=&quot;1972&quot;&gt;1972&lt;/h3&gt;

&lt;p&gt;Jake Feinler transfers into ARC (Augmentation Research Center) to work on NIC.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc322&quot;&gt;Socket catalog request - RFC 322&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc349&quot;&gt;RFC 349 - Proposed Socket Numbers&lt;/a&gt;
  Postel suggests there be a czar for socket numbers for standard protocols
  and that it be him&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc433&quot;&gt;Socket Number List - RFC 433&lt;/a&gt;
  Postel specifies the socket number assignent&lt;/p&gt;

&lt;h3 id=&quot;1973&quot;&gt;1973&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc597&quot;&gt;RFC 597 - List of hosts on ARPANET&lt;/a&gt;
	interestingly the address numbers are between 0 and 255&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;OFFICE-1 the NIC host is on a PDP-10 along with NLS
Also offers &quot;TENEX&quot;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc606&quot;&gt;RFC 606 - Host Names On-Line&lt;/a&gt;
	L. Peter Deutsch recommends a centralized list of host names&lt;/p&gt;

&lt;h3 id=&quot;1974&quot;&gt;1974&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc608&quot;&gt;RFC 608 - Host Names On-Line&lt;/a&gt;
	Jake commits to updating a text file
	File lives at &lt;NETINFO&gt;HOSTS.TXT
	Host &quot;OFFICE-1&quot; Host Address = 43 decimal&lt;/NETINFO&gt;&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;^^ so Host Addresses were just numbers
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;1977&quot;&gt;1977&lt;/h3&gt;
&lt;p&gt;NLS sold to Tymshare, with it the machine NIC ran on, so NIC switches to DEC-10&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc739&quot;&gt;RFC 739 - Assigned Numbers&lt;/a&gt;
  Postel lists the assigned “link” numbers and socket numbers for protocols.
  Not clear to me exactly what a “link” is.  I’m not sure how packets were
  routed, this was pre-IP though, so maybe it was in a really weird way&lt;/p&gt;

&lt;p&gt;Refers to the “internetwork protocols”&lt;/p&gt;

&lt;p&gt;1980&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc760&quot;&gt;RFC 760 - Internet Protocol&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;1981&quot;&gt;1981&lt;/h3&gt;
&lt;p&gt;Convert from NCP to TCP/IP (NCP was original Arpanet protocol)
TCP/IP created?&lt;/p&gt;

&lt;p&gt;DDN created&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc790&quot;&gt;RFC 790 - Assigned Numbers&lt;/a&gt;
  Class A,B,C networks described.
  IP ranges assigned to different networks&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc796&quot;&gt;RFC 796 - Address Mappings&lt;/a&gt;
  Class A,B,C networks, describes how network specific addresses correspond
  to IP addresses.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc791&quot;&gt;RFC 791 - Internet Protocol (IP)&lt;/a&gt;
  This is an update&lt;/p&gt;

&lt;h3 id=&quot;1982&quot;&gt;1982&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc810&quot;&gt;RFC 810 - Host Table Specification&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;It can be obtained by connecting to host SRI-NIC (10.0.0.73) from your local FTP server, logging in as user=ANONYMOUS, password=GUEST, and doing a ‘get’ on &lt;NETINFO&gt;HOSTS.TXT.&lt;/NETINFO&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc811&quot;&gt;RFC 811 - Hostname Server&lt;/a&gt;
  SRI-NIC is mentioned to be running on a Foonly
  Describes command interface for looking up the host addresses for machines by name&lt;/p&gt;

&lt;h3 id=&quot;1983&quot;&gt;1983&lt;/h3&gt;
&lt;p&gt;Deadline for military to adopt TCP/IP&lt;/p&gt;

&lt;h3 id=&quot;1984&quot;&gt;1984&lt;/h3&gt;

&lt;p&gt;Domain Name requirements 
&lt;a href=&quot;http://www.rfc-editor.org/rfc/rfc920.txt&quot;&gt;RFC 920&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;The administrator of a level N domain must register with the
registrar (or responsible person) of the level N-1 domain.  This
upper level authority must be satisfied that the requirements are
met before authorization for the domain is granted.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Lays out the information necessary to register a domain.  Essentially:
email hostmaster@sri-nic.arpa with your information including the IP addresses of the name servers that will host the DNS information.&lt;/p&gt;

&lt;p&gt;The IP address listed is of the typical x.x.x.x format.&lt;/p&gt;

&lt;h3 id=&quot;1985&quot;&gt;1985&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc953&quot;&gt;RFC 995: Hostname server&lt;/a&gt;
(Feinler update to RFC 811)&lt;/p&gt;

&lt;h3 id=&quot;1987&quot;&gt;1987&lt;/h3&gt;
&lt;p&gt;NIC took over maintaining assigned numbers and become Arpanet/DDN’s naming auhtority&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc1035&quot;&gt;RFC 1035 - DNS protocol specification&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;1991&quot;&gt;1991&lt;/h3&gt;
&lt;p&gt;NIC contract awarded to Network Solutions Inc (NSI).&lt;/p&gt;

&lt;h3 id=&quot;1993&quot;&gt;1993&lt;/h3&gt;
&lt;p&gt;NSI adds root server&lt;/p&gt;

&lt;h3 id=&quot;1994&quot;&gt;1994&lt;/h3&gt;

&lt;p&gt;RFC 1591 (Postel):
internic.net - registers second level domains under the TLD’s (com, edu, org, gov, net)&lt;/p&gt;

&lt;p&gt;now is US Department of Commerce&lt;/p&gt;

&lt;p&gt;.mil - DDN 
.int - PVM at ISI.edu (USC)&lt;/p&gt;

&lt;h3 id=&quot;1998&quot;&gt;1998&lt;/h3&gt;

&lt;p&gt;ICANN established&lt;/p&gt;

&lt;h2 id=&quot;unanswered-questions&quot;&gt;Unanswered Questions&lt;/h2&gt;
&lt;ul&gt;
  &lt;li&gt;If NIC did the host names, what did IANA do?&lt;/li&gt;
  &lt;li&gt;What is TIP? and what is a TIP phone number?&lt;/li&gt;
  &lt;li&gt;What was Namedroppers?&lt;/li&gt;
  &lt;li&gt;What format were addresses before IP? How did things get routed?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;further-reading&quot;&gt;Further Reading:&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;http://ieeexplore.ieee.org/document/5551028/?reload=true&quot;&gt;History by Jake Feinler&lt;/a&gt;
(a)
&lt;a href=&quot;http://a.root-servers.org/&quot;&gt;Verisign a root server&lt;/a&gt;
pre-1991 Network Information Center (NIC) at Stanford Research Institute (SRI)
SRI operated one of 3 root name servers.&lt;/p&gt;

&lt;p&gt;(b) USC started in 1987
&lt;a href=&quot;http://b.root-servers.org/&quot;&gt;USC b root server&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(c) also started in 1987
&lt;a href=&quot;http://c.root-servers.org/&quot;&gt;Cogent c root server&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;(d) 1988
&lt;a href=&quot;http://d.root-servers.org/&quot;&gt;University of Mayland d root server&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Internet_Assigned_Numbers_Authority&quot;&gt;IANA Wikipedia&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc1591&quot;&gt;IANA’s role - RFC 1591&lt;/a&gt;
“It is extremely unlikely that any other TLDs will be created.” (lol)&lt;/p&gt;

</description>
        <pubDate>Wed, 14 Feb 2018 00:00:00 +0000</pubDate>
        <link>http://pcarleton.github.io/2018/02/14/dns-authority.html</link>
        <guid isPermaLink="true">http://pcarleton.github.io/2018/02/14/dns-authority.html</guid>
        
        
      </item>
    
      <item>
        <title>Wifi Woes resolved with Ubiquiti</title>
        <description>&lt;h2 id=&quot;fast-wifi-is-possible&quot;&gt;Fast Wifi is possible!&lt;/h2&gt;

&lt;p&gt;I have declared my Ubiquiti experiment a success! I am consistently measuring internet speeds over 100 MB/s with the lowest I’ve seen around 40 MB/s.  This is a huge upgrade from seeing 5-8 MB/s regularly with the highest being around 15 MB/s (see &lt;a href=&quot;/2018/01/04/wifi-debug.html&quot;&gt;my previous post&lt;/a&gt; for more details on the diagnosis of my old system).&lt;/p&gt;

&lt;p&gt;In this post, I want to document my installatin process because it was a bit of a doozy.  I also want to offer some recommendations in case anyone else is considering investing in a Ubiquiti wifi set up.&lt;/p&gt;

&lt;h2 id=&quot;the-installation-process-a-network-bootstrapping-wrestling-match&quot;&gt;The Installation Process (A Network Bootstrapping Wrestling Match)&lt;/h2&gt;

&lt;p&gt;First, here is the hardware I ordered &lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.amazon.com/Ubiquiti-Unifi-Security-Gateway-USG/dp/B00LV8YZLK/ref=sr_1_1?ie=UTF8&amp;amp;qid=1515081742&amp;amp;sr=8-1&amp;amp;keywords=ubiquiti+usg+unifi+security+gateway&quot;&gt;Unifi Security Gateway (USG)&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;https://www.amazon.com/dp/B016K4GQVG/ref=sr_ob_1?ie=UTF8&amp;amp;qid=1515081752&amp;amp;sr=8-1&quot;&gt;Unifi AP AC Lite&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first step after plugging everything in and powering it on was “adopting” the devices to a controller.  I started out putting the controller software on my laptop for expediency with the eventual goal of running it on a RaspberryPi.&lt;/p&gt;

&lt;h3 id=&quot;laptop-controller&quot;&gt;Laptop Controller&lt;/h3&gt;

&lt;p&gt;My laptop does not have an ethernet port, so I connected to the AP using the QR code on bottom side of the AP.  I had to use the iOS App to do this scanning because the Android app wasn’t working for me.  This gave me the SSID for a hidden network (the MAC address of the AP w/o the colons) and a password.  I was able to then see the USG in the controller interface, but I could not see the AP.  I assumed this was because I was connected through the AP and that in order for the controller to adopt the AP it had to be running independently of it&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;h3 id=&quot;raspberry-pi-controller-over-ethernet&quot;&gt;Raspberry Pi Controller over Ethernet&lt;/h3&gt;

&lt;p&gt;This was when I decided to plug the Raspberry Pi directly in to the USG andstart using it as the controller. I followed &lt;a href=&quot;http://www.technologist.site/2016/06/02/how-to-install-ubiquiti-unifi-controller-5-on-the-raspberry-pi/&quot;&gt;a guide&lt;/a&gt; to get the software installed and after a couple of speedbumps&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;, got the controller up and running. I was SSH’ing to the machine via my laptop which was still connected to the AP’s MAC address network, and I assumed I needed to not be connected that way in order for the AP to be adoptable (an assumption that may have been flawed).  In order to work around that, I set up the RaspberryPi as &lt;a href=&quot;https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md&quot;&gt;a wireless access point&lt;/a&gt; and then connected and SSH’d that way.&lt;/p&gt;

&lt;h3 id=&quot;raspberry-pi-controller-over-wifi&quot;&gt;Raspberry Pi Controller over WiFi&lt;/h3&gt;

&lt;p&gt;I then was able to adopt the AP and the USG, and things were looking good.  However, I needed to free up an ethernet port in order to plug in the brigde for my Hue lights, so I wanted to get my Raspberry Pi acting as the controller over Wifi.  I figured this would be a simple exercise of connecting the Raspberry Pi to Wifi and updating some configuration settings.  Once I did this, and unplugged the ethernet cable, it started reporting the USG as not connected.  Apparently, the USG wants the controller to be on the same subnet as it, and in this case the AP (and therefore the controller) was on the LAN2 subnet&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;.  I tried naively swapping the AP to the LAN1 port, but this really messed evertyhing up, so I factory reset everything and started from the beginning.&lt;/p&gt;

&lt;p&gt;On my next attempt, after I got the Raspberry Pi up and running as the controller. I unplugged it, and plugged the AP into the same port.  This way the AP was running on the LAN1 subnet.  After reconnecting the Raspberry pi, everything worked, and I recorded much faster speeds than I had previously read.&lt;/p&gt;

&lt;p&gt;In the future, I want to look into running a Controller from an EC2 or GCE instance so I don’t have to keep my RaspberryPi plugged in to power all the time.&lt;/p&gt;

&lt;h2 id=&quot;reccomendations&quot;&gt;Reccomendations&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Be generous with your ethernet ports - investing in an ethernet switch will save you heartache even if you only use it for the initial set up.&lt;/li&gt;
  &lt;li&gt;Buying a “Cloud Key” will also make your setup life a lot easier, some of the “Discovery” and “Set Up” tools have special features that only work with a Cloud Key.&lt;/li&gt;
  &lt;li&gt;Be sure your Controller is on the same subnet as the USG.&lt;/li&gt;
  &lt;li&gt;If your modem doesn’t immediately work with the USG, unplug everything, wait a few minutes and try again.  (This may seem like the technology equivalent of a ceremonial sacrifice, but it worked for me, and I’m willing to chalk it up to something in the modem needing to be cleared out from the previous router)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;take-away&quot;&gt;Take-away&lt;/h2&gt;

&lt;p&gt;Hopefully this saves someone from the mostly self-inflicted torment I experienced.  Overall, I am very happy with the Unifi set up and would recommend it to anyone who’s willing to invest a little bit extra in the set up.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;If you’ve read up on the Unifi line of products, you may notice this is missing a “Controller”.  I have RaspberryPi laying around which I decided I was going to use at the Controller, but more on that later. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Looking back, there was probably a way to manually adopt the AP by SSH’ing to it as described in this &lt;a href=&quot;https://community.ubnt.com/t5/UniFi-Wireless/Changing-controller-IP/td-p/255168&quot;&gt;forum post&lt;/a&gt;, but I did not know enough at the time to try that. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;First, I had some weird version of Raspian installed which made it impossible to install the right packages.  I had to &lt;a href=&quot;https://www.raspberrypi.org/documentation/installation/installing-images/&quot;&gt;flash a new image&lt;/a&gt; and remember to &lt;a href=&quot;https://www.raspberrypi.org/documentation/remote-access/ssh/&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;touch ssh&lt;/code&gt;&lt;/a&gt; in the boot directory in order to enable SSH access on a fresh install because I didn’t have a monitor or keyboard with me. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I gathered this from &lt;a href=&quot;https://help.ubnt.com/hc/en-us/articles/236281367-UniFi-How-to-Adopt-a-USG-into-an-Existing-Network&quot;&gt;an article&lt;/a&gt; about how to adopt a USG into an existing network.  It says “If the controller is on a subnet other than the USG’s default 192.168.1.0/24, it is necessary to change the USG’s LAN IP so the controller and USG can communicate”. &lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Tue, 16 Jan 2018 00:00:00 +0000</pubDate>
        <link>http://pcarleton.github.io/2018/01/16/ubiquiti-wifi.html</link>
        <guid isPermaLink="true">http://pcarleton.github.io/2018/01/16/ubiquiti-wifi.html</guid>
        
        
      </item>
    
      <item>
        <title>Debugging Slow Wifi</title>
        <description>&lt;h1 id=&quot;introduction&quot;&gt;Introduction&lt;/h1&gt;

&lt;p&gt;I ran into the ever common problem of slow WiFi recently.  In this post I want to detail the experiments I ran and what I gleaned from the results.&lt;/p&gt;

&lt;h1 id=&quot;setting-the-stage&quot;&gt;Setting the Stage&lt;/h1&gt;

&lt;p&gt;First I’ll describe the setup I have for my home wifi network and the problems I was experiencing.&lt;/p&gt;

&lt;p&gt;Symptoms:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;No problem streaming Netflix&lt;/li&gt;
  &lt;li&gt;Trouble loading web pages occasionally&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I had a weird set of problems in that I typically could stream episodes of shows on Netflix without any huge problems, but sometimes loading sites would be unbearably slow.  It was common enough to be a huge pain, but the times when it worked well confused me.  Why was it only sometimes slow?&lt;/p&gt;

&lt;p&gt;Hardware:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Modem: &lt;a href=&quot;https://www.amazon.com/gp/product/B00AJHDZSI/ref=oh_aui_search_detailpage?ie=UTF8&amp;amp;psc=1&quot;&gt;Arris Surfboard SB6141&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Router/AP: &lt;a href=&quot;https://on.google.com/hub/features/&quot;&gt;Google OnHub&lt;/a&gt; by &lt;a href=&quot;http://www.tp-link.com/us/products/details/cat-9_TGR1900.html&quot;&gt;TP-Link&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;investigation&quot;&gt;Investigation&lt;/h1&gt;

&lt;p&gt;I wanted to check if my internet was actually slow or whether I was just impatient.  I ran speedtests from several different providers, and it was in fact slow. (billed speed was 100 Mb/s, observed was between 3-8 Mb/s).&lt;/p&gt;

&lt;p&gt;At first, I was convinced that Comcast was to blame for my slow wifi speed.
However, I ruled this out by checking the internet speed over ethernet.  Comcast was delivering speeds to my router that were much higher than I was observing at my laptop. (observed ethernet speeds between 56-75 Mb/s)&lt;/p&gt;

&lt;p&gt;Next, I wanted to establish a baseline for what the point to point speed on my network was.  This came out around 5 Mb/s which was really slow!&lt;/p&gt;

&lt;p&gt;Next, I thought maybe there was a lot of WiFi congestion in my area.  Maybe my router was picking a congested channel, or there was some kind of crazy interference in my apartment.  To test this, I ran my raspberry pi right next to my router in AP mode.  I was very surprised when the Raspberry Pi was able to get 33 Mb/s running on the same channel as my router.&lt;/p&gt;

&lt;h1 id=&quot;experiments&quot;&gt;Experiments&lt;/h1&gt;

&lt;h2 id=&quot;speed-tests&quot;&gt;Speed Tests&lt;/h2&gt;
&lt;p&gt;Ran speed tests on 3 different sites: &lt;a href=&quot;http://fast.com&quot;&gt;fast.com&lt;/a&gt; (Netflix’s Speed test site), &lt;a href=&quot;http://speedof.me&quot;&gt;speedof.me&lt;/a&gt; (Javascript based graphs and reports), and &lt;a href=&quot;http://speedtest.net&quot;&gt;speedtest.net&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Results:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Fast.com: 8 Mbps&lt;/li&gt;
  &lt;li&gt;speedtest.net: 4.6 Mbps&lt;/li&gt;
  &lt;li&gt;speedof.me: 3.15 Mbps&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;raspberry-pi-on-ethernet&quot;&gt;Raspberry Pi on Ethernet&lt;/h2&gt;

&lt;p&gt;Setup:&lt;/p&gt;

&lt;p&gt;I plugged my Raspberry Pi into the ethernet port of my router.  I then downloaded &lt;a href=&quot;https://github.com/sivel/speedtest-cli&quot;&gt;speedtest-cli&lt;/a&gt; (a CLI for running speed tests against speedtest.net).  I also ran a test with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget&lt;/code&gt;&lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Results:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;speedtest-cli: 75 Mb/s&lt;/li&gt;
  &lt;li&gt;wget: 6.9 MB/s =&amp;gt; 56 Mb/s&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;laptop-to-laptop-communication&quot;&gt;Laptop to Laptop communication&lt;/h2&gt;

&lt;p&gt;Setup:
I installed &lt;a href=&quot;https://iperf.fr/iperf-download.php&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iperf&lt;/code&gt;&lt;/a&gt; on 2 laptops. Laptop 1 is running Linux on a 2011 Macbook Air and was running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iperf -s&lt;/code&gt; (the server).  Laptop 2 is a 2017 Macbook Pro running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iperf -c&lt;/code&gt;.  I started out running with the default parameters which runs a test for 10 seconds, then switched to longer times using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iperf -c -t 60&lt;/code&gt; to run the test for 60 seconds.&lt;/p&gt;

&lt;p&gt;Results:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Average for 10s (6 trials): 17.7 Mb/s&lt;/li&gt;
  &lt;li&gt;Average for 60s (3 trials): 5 Mb/s&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;raspberry-pi-as-ap&quot;&gt;Raspberry Pi as AP&lt;/h2&gt;

&lt;p&gt;Setup:
I put my raspberry pi in AP mode&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt; and had my laptop connect to it directly.&lt;/p&gt;

&lt;p&gt;Results:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;iperf -c -t 60&lt;/code&gt; : 33.4 Mb/s&lt;/li&gt;
&lt;/ul&gt;

&lt;h1 id=&quot;conclusions&quot;&gt;Conclusions&lt;/h1&gt;

&lt;p&gt;My conclusion is that my router is not performing.  I tried power cycling it to see if that would help, but the measurements were the same after.  I am not certain why this is the case, especially since it is supposed to have 13 antennae which I would expect to lead to high LAN bandwidth.  My next experiment is to order some &lt;a href=&quot;https://unifi-sdn.ubnt.com/&quot;&gt;UniFi&lt;/a&gt; hardware and see if was that improves the situation&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;I never got a good answer as to why I was able to stream Netflix but regular websites would have trouble loading.&lt;/p&gt;

&lt;p&gt;Hopefully my new hardware does the trick. I plan on writing a follow up post when I have it all set up to see if it makes a difference.&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;The exact command I ran: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip&lt;/code&gt; NB: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;wget&lt;/code&gt; reports speeds in megaBYTES not megaBITS (like most wifi tools).  Multiply by 8 to get a comparable number. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;To setup a Raspberry Pi as an AP, I used &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hostapd&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;udhcpd&lt;/code&gt; which you can find instructions for on &lt;a href=&quot;https://www.raspberrypi.org/documentation/configuration/wireless/access-point.md&quot;&gt;raspberrypi.org&lt;/a&gt; &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I am going with a &lt;a href=&quot;https://www.amazon.com/Ubiquiti-Unifi-Security-Gateway-USG/dp/B00LV8YZLK/ref=sr_1_1?ie=UTF8&amp;amp;qid=1515081742&amp;amp;sr=8-1&amp;amp;keywords=ubiquiti+usg+unifi+security+gateway&quot;&gt;USG&lt;/a&gt; and a &lt;a href=&quot;https://www.amazon.com/dp/B016K4GQVG/ref=sr_ob_1?ie=UTF8&amp;amp;qid=1515081752&amp;amp;sr=8-1&quot;&gt;UniFi AP AC Lite&lt;/a&gt;.  I went with Ubiquiti based on recommendations from some coworkers and a blog post by &lt;a href=&quot;https://www.troyhunt.com/ubiquiti-all-the-things-how-i-finally-fixed-my-dodgy-wifi/&quot;&gt;Troy Hunt&lt;/a&gt; that describes similar frustrations as mine.  I debated whether to get an EdgeMax router over the USG after seeing some discussion in Troy’s &lt;a href=&quot;https://gist.github.com/troyhunt/86ce1de40e58b1eed0961ce6a7a906d5&quot;&gt;gist&lt;/a&gt;.  I ended up going with the USG since I don’t believe I’ll benefit from the more advanced configuration opions of the EdgeMax, and I like the idea of all of it working with the UniFi portal. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Thu, 04 Jan 2018 00:00:00 +0000</pubDate>
        <link>http://pcarleton.github.io/2018/01/04/wifi-debug.html</link>
        <guid isPermaLink="true">http://pcarleton.github.io/2018/01/04/wifi-debug.html</guid>
        
        
      </item>
    
      <item>
        <title>DNS End to End</title>
        <description>&lt;h1 id=&quot;domain-name-system-end-to-end&quot;&gt;Domain Name System: End to End&lt;/h1&gt;

&lt;p&gt;We all interact with the Domain Name System (DNS) every day.  Every time we load a web page, or click a link, our software relies on DNS to figure out what address to send requests to. In this post, I will dig into how DNS works by tracing through the machinery that happens behind the scenes.&lt;/p&gt;

&lt;h1 id=&quot;what-is-the-purpose-of-dns&quot;&gt;What is the purpose of DNS?&lt;/h1&gt;

&lt;p&gt;It is first worth calling out what DNS is and why anybody should care about it.  A good place to start is &lt;a href=&quot;https://www.ietf.org/rfc/rfc1035.txt&quot;&gt;Domain Names - Implementation and Specification RFC1035&lt;/a&gt;.  In the introduction, it says:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The goal of domain names is to provide a mechanism for naming resources
in such a way that the names are usable in different hosts, networks,
protocol families, internets, and administrative organizations.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Domain names are supposed to be a convenient, general purpose way to refer to resources.  Convenient in this case most likely means relative to referring things to an actual host address. Practically, this means DNS turns “google.com” into an IP address like “216.58.192.14” &lt;sup id=&quot;fnref:1&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;. This provides a number of benefits.  “google.com” is much easier to remember than a series of 4 numbers.  Also, a web service can change which host address it wants to use without end users even noticing&lt;sup id=&quot;fnref:2&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;h1 id=&quot;dns-resolution-by-hand&quot;&gt;DNS Resolution “by hand”&lt;/h1&gt;

&lt;p&gt;Now that we know the goal of DNS, I want to demonstrate how DNS works by crafting DNS queries using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dig&lt;/code&gt;.  I will ignore a lot of pieces of the system for this illustration (like caching and recursive resolution). I will try to resolve “pcarleton.com”&lt;/p&gt;

&lt;h2 id=&quot;root-domain&quot;&gt;Root Domain&lt;/h2&gt;

&lt;p&gt;In order to figure out what IP address is serving “pcarleton.com.”, I can work my way down the hierachy.  There are servers at each level of the hierarchy that can tell me where to find information for the level below. The domain name “pcarleton.com” becomes &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;[&quot;&quot;, &quot;com&quot;, &quot;pcarleton&quot;]&lt;/code&gt; in the hierarchy where the empty string is the implied “root” domain&lt;sup id=&quot;fnref:3&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;A name server at the root level can tell me about what nameservers are responsible for each Top Level Domain (TLD) like “.com”, “.net” etc.  In order to query a root server, I need to know one of its IP addresses.  I can pick one from the &lt;a href=&quot;https://www.iana.org/domains/root/servers&quot;&gt;IANA website&lt;/a&gt;, so I’ll pick &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a.root-servers.net&lt;/code&gt; with IP address &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;198.41.0.4&lt;/code&gt;&lt;sup id=&quot;fnref:4&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;I can then query this root server for what name servers are responsible for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pcarleton.com&lt;/code&gt; via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dig -t ns pcarleton.com @198.41.0.4&lt;/code&gt;.  This gives me a list of servers which are responsible for the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.com&lt;/code&gt; TLD.&lt;/p&gt;

&lt;h2 id=&quot;com-domain&quot;&gt;.Com Domain&lt;/h2&gt;

&lt;p&gt;The root server gave a list of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.com&lt;/code&gt; nameservers (and IP addresses) that look like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a.gtld-servers.net&lt;/code&gt; with the letters A through M.  For instance, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;a.gtld-servers.net&lt;/code&gt; has address: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;192.5.6.30&lt;/code&gt;.  I can then query this address to see which &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.com&lt;/code&gt; name server is responsible for the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pcarleton&lt;/code&gt; domain name with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dig -t ns pcarleton.com @192.5.6.30&lt;/code&gt;.&lt;/p&gt;

&lt;h2 id=&quot;namecheap-dns-servers&quot;&gt;Namecheap DNS servers&lt;/h2&gt;

&lt;p&gt;This query reveals that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dns1.registrar-servers.com&lt;/code&gt; has information for &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pcarleton.com&lt;/code&gt; (and has IP &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;216.87.155.33&lt;/code&gt;).  This name server is the one run by Namecheap which is where I registered &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pcarleton.com&lt;/code&gt;&lt;sup id=&quot;fnref:5&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;.  If we query this one with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dig pcarleton.com @216.87.155.33&lt;/code&gt;, we get the IP address of this site which we can then use.&lt;/p&gt;

&lt;h2 id=&quot;making-changes&quot;&gt;Making Changes&lt;/h2&gt;

&lt;p&gt;This example demonstrated how to interact with the DNS system, but it did not show how changes to that information would propagate.  To understand that, let’s look back at what data was required:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://pcarleton.github.io/assets/dns/data.png&quot; width=&quot;600px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Changes to the list of root IP’s should never happen.  If it did, it would require pushing a file listing the new IP’s to all running DNS servers by system admins all over the world.&lt;/p&gt;

&lt;p&gt;Changes of the mapping of TLD’s to authoritative name servers does not happen frequently, but is administered by ICANN. It will be communicated to all the root servers which will update their records and serve them to requests.&lt;/p&gt;

&lt;p&gt;Changes to the TLD server’s mapping (the Registry) changes more frequently.  Every time a new domain name is registered, the TLD’d servers need to know which domain name servers have the required IP addresses. A Registrar makes a request to the “Registry” to update these records.&lt;/p&gt;

&lt;p&gt;Changes to the final DNS servers mapping of domain name to IP address can happen much more frequently since it only needs to be updated in the two DNS servers listed. I can change this by making a request to Namecheap.&lt;/p&gt;

&lt;h1 id=&quot;reality-check&quot;&gt;Reality Check&lt;/h1&gt;

&lt;p&gt;This example showed how some of the pieces of the DNS system work, but it is not typically how a DNS request goes.  In reality, the client usually makes a request to a DNS server&lt;sup id=&quot;fnref:6&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;6&lt;/a&gt;&lt;/sup&gt; which has a lot of information cached (like the .com TLD servers) and will make requests to the appropriate servers rather than telling the client which nameservers to look at&lt;sup id=&quot;fnref:7&quot; role=&quot;doc-noteref&quot;&gt;&lt;a href=&quot;#fn:7&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;h1 id=&quot;further-information&quot;&gt;Further Information&lt;/h1&gt;

&lt;p&gt;Here’s a list of resources to look for further information about DNS:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc7020&quot;&gt;Internet Numbers Registry System - RFC 7010&lt;/a&gt;
&lt;a href=&quot;https://www.ripe.net/membership/indices/US.html&quot;&gt;List of Local Internet Registries&lt;/a&gt; (This who Namecheap could contract with to update the nameserver mapping)&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc1591&quot;&gt;IANA’s role - RFC 1591&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://tools.ietf.org/html/rfc2468&quot;&gt;Jon Postel (the original IANA)’s RFC Eulogy&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://songbird.com/pab/mail/0472.html&quot;&gt;Jon Postel root swapping incident&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://osaka.law.miami.edu/~froomkin/articles/icann-body.htm#H1N5&quot;&gt;Argument that ICANN’s authority is illegal&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.icann.org/resources/pages/help/dndr/udrp-en&quot;&gt;Unified Domain-name Dispute Resolution Policy&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.iana.org/domains/root/tld-change-template.txt&quot;&gt;Email Template to update IP for a TLD name server&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.arin.net/about_us/overview.html&quot;&gt;ARIN&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://en.wikipedia.org/wiki/Regional_Internet_registry&quot;&gt;RIR&lt;/a&gt;&lt;/p&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;You can test this out locally by running &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dig google.com&lt;/code&gt; from the command line. If you put this IP address into your browser, it will load google.com. &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;It is not difficult to imagine how a bad actor could cause trouble with this too. If they were to compromise DNS information, they could cause clients to send information to a location where they can intercept it.  For this post, I won’t get into that, and I will pretend like everybody on the internet are behaving nicely. &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;pcarleton.com is implicitly re-written as “pcarleton.com.” (note the trailing period) where the root domain is the empty string at the end. &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;Ordinary websites do not load “iana.org” in order to figure out root servers.  These 13 name servers are like internet constants in that their IP addresses never change.  Domain name servers usually have these IP addreses in a file somewhere. &lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;I verified this was Namecheap’s by going to &lt;a href=&quot;https://www.whois.com/whois/registrar-servers.com&quot;&gt;whois.com&lt;/a&gt;.  This info can also be obtaind with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;whois&lt;/code&gt; CLI with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;whois dns1.registrar-servers.com --host whois.enom.com&lt;/code&gt; (I got the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;whois.enom.com&lt;/code&gt; part from first issuing the command without the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--host&lt;/code&gt; argument).  Enom must be the registrar that Namecheap used to register its domain with. That leads me to wonder if there are any circular registrar dependencies, but is looks like Enom used itself to register “enom.com”. &lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:6&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;One such server is &lt;a href=&quot;https://en.wikipedia.org/wiki/Google_Public_DNS&quot;&gt;Google Public DNS&lt;/a&gt; which resides at IP address &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;8.8.8.8&lt;/code&gt;. &lt;a href=&quot;#fnref:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:7&quot; role=&quot;doc-endnote&quot;&gt;
      &lt;p&gt;This is assuming that the request is “recursive”.  A recursive request asks that the server make requests to other DNS servers if it doesn’t have the answer.  An “iterative” request by contrast asks that the server tell the client what server will have the answer if it does not have the answer.  A DNS server gets to decide whether it supports “recursive” requests. &lt;a href=&quot;#fnref:7&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;
</description>
        <pubDate>Sat, 25 Nov 2017 00:00:00 +0000</pubDate>
        <link>http://pcarleton.github.io/2017/11/25/dns-end-to-end.html</link>
        <guid isPermaLink="true">http://pcarleton.github.io/2017/11/25/dns-end-to-end.html</guid>
        
        
      </item>
    
      <item>
        <title>What does mount do?</title>
        <description>&lt;h1 id=&quot;background&quot;&gt;Background&lt;/h1&gt;

&lt;p&gt;As I mentioned in my &lt;a href=&quot;/2017/04/19/containers.html&quot;&gt;post about containers&lt;/a&gt;, I want to write a container tool in rust to learn more about rust and containers.  I started doing that with my friend Kevin, and our (humble) progress so far is on Github in a project we called &lt;a href=&quot;https://github.com/kevindrosendahl/bucket&quot;&gt;bucket&lt;/a&gt; (like a container, that’s sometimes rusty… or something).&lt;/p&gt;

&lt;p&gt;We’re following a long a talk given by Eric Chiang at CoreOS Fest called &lt;a href=&quot;https://www.youtube.com/watch?v=wyqoi52k5jM&quot;&gt;Containers From Scratch&lt;/a&gt; (&lt;a href=&quot;https://speakerd.s3.amazonaws.com/presentations/eb9b416908c743f99c20d05d060209ae/coreos-fest-2017.pdf&quot;&gt;slides&lt;/a&gt;).  In the talk, Eric walks through the linux command line utilities that you can string together yourself to make a “container”.  We got as far as creating a “root filesystem”, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chroot&lt;/code&gt;ing into it, and then making a separate PID namespace by calling &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt;.  It was during this &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt; step that I ran into an error message that led me to learn more about &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount&lt;/code&gt; that I want to document here.&lt;/p&gt;

&lt;h1 id=&quot;what-does-mount-do&quot;&gt;What does &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount&lt;/code&gt; do?&lt;/h1&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount&lt;/code&gt; is a command line utility which wraps the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount&lt;/code&gt; system call. (Another fun fact I learned: the #’s after a name in a man page indicates what section that man page is in.  So &lt;a href=&quot;https://linux.die.net/man/2/mount&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount(2)&lt;/code&gt;&lt;/a&gt; is the system call because it is in the “System calls” section of the manual and &lt;a href=&quot;https://linux.die.net/man/8/mount&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount(8)&lt;/code&gt;&lt;/a&gt; is the command line utility because it is in the “System Administation Commands and Daemons” section. More info in this &lt;a href=&quot;https://stackoverflow.com/questions/62936/what-does-the-number-in-parentheses-shown-after-unix-command-names-mean&quot;&gt;SO Answer&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;If you’re like me, you have had to call mount some times when you’ve plugged in a USB drive and it hasn’t worked correctly.  Usually, the OS handles the mounting for you. For instance, when I plug in a USB stick to my computer, it pops up a Files window with the contents.&lt;/p&gt;

&lt;p&gt;First, it’s worth knowing how to get information about current mounts. The place for that is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mtab&lt;/code&gt;.  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mtab&lt;/code&gt; is a read-only file that lives at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/etc/mtab&lt;/code&gt; (and in my case is a symlink to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/proc/self/mounts&lt;/code&gt;) which lists the current active mounts.  When I plugged in my USB drive, I saw the following line at the bottom of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mtab&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;/dev/sdc2 /media/paul/P16G hfsplus ro,nosuid,nodev,relatime,umask=22,uid=0,gid=0,nls=utf8 0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If we break that down, we have a device on the far left called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/dev/sdc2&lt;/code&gt;. (Quick side note: to break down &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sdc2&lt;/code&gt;, first ignore the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sd&lt;/code&gt;, then you have &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;c&lt;/code&gt; which indicates it’s the third drive that the OS has seen.  &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sda&lt;/code&gt; is my computer’s hard drive, I’m not sure what &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sdb&lt;/code&gt; is.  Then the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2&lt;/code&gt; means what partition on that drive, so this is the 2nd partition. (more info in this &lt;a href=&quot;https://superuser.com/questions/558156/what-does-dev-sda-for-linux-mean\&quot;&gt;Superuser answer&lt;/a&gt;))&lt;/p&gt;

&lt;p&gt;After that, we have the mount point.  This is directory where the files on the device are accessible.  In this case, I can go to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/media/paul/P16G&lt;/code&gt; to access the files on the USB stick.&lt;/p&gt;

&lt;p&gt;Next is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hfsplus&lt;/code&gt; indicating the filesystem type.  Then there are several options and then 2 0’s indicating the dump/pass options.  0’s mean we don’t back up this mount (dump) and we don’t run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fsck&lt;/code&gt; on it to detect errors (pass).  The &lt;a href=&quot;https://en.wikipedia.org/wiki/Fstab&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fstab&lt;/code&gt; wikipedia page&lt;/a&gt; has more info on this file’s format.&lt;/p&gt;

&lt;p&gt;If I want to unmount this, I can run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;umount /media/paul/P16G&lt;/code&gt;.  I can then remount it with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sudo mount -t hfsplus /dev/sdc2 /media/paul/P16G&lt;/code&gt;. (Interestingly, I had to create the P16G directory since when I unmounted it, the directory went away.  I’m not sure why that is.)&lt;/p&gt;

&lt;p&gt;Another interesting place related to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount&lt;/code&gt; is &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fstab&lt;/code&gt;.  It’s the same format as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mtab&lt;/code&gt;, but instead of reflecting the current mounts, it represents what mounts should be created at boot time.  If you change that file, you will have new mounts when you reboot.&lt;/p&gt;

&lt;p&gt;That gives us enough information to move on to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt;.&lt;/p&gt;

&lt;h1 id=&quot;what-does-unshare-do&quot;&gt;What does &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt; do?&lt;/h1&gt;

&lt;p&gt;The particular &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt; command we were looking at was:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;sudo unshare -p -f --mount-proc=$PWD/rootfs/proc chroot rootfs /bin/bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This creates a new PID namespace, mounts a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;proc&lt;/code&gt; filesystem under the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;rootfs/proc&lt;/code&gt; directory and then executes &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;chroot&lt;/code&gt; and finally &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;bash&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The tricky part I was running in to was that I was getting a “Invalid argument” error message when I tried to run this command.&lt;/p&gt;

&lt;p&gt;First, I’ll look at mounting a proc filesystem.  It turns out I can do this anywhere and I don’t need a device like I did for mounting a USB drive.  Instead, whatever I pass in as the device becomes a kind of dummy label.  For instance, I can say &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount -t proc dummy ~/fs1&lt;/code&gt; and I’ll get a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;proc&lt;/code&gt; filesystem in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fs1&lt;/code&gt; directory.  If I do &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls ~/fs1&lt;/code&gt;, it will look identical to doing &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ls /proc&lt;/code&gt;.  Additionally, I get the following line in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mtab&lt;/code&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;dummy /home/paul/fs1 proc rw,relatime 0 0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, I want to look at what the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt; command does when it has the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--mount-proc&lt;/code&gt; command because it starts to demonstrate why I ran in to my error.  Here are some lines from the &lt;a href=&quot;https://github.com/karelzak/util-linux/blob/master/sys-utils/unshare.c#L454-L455&quot;&gt;unshare source code&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;if (procmnt &amp;amp;&amp;amp;
    (mount(&quot;none&quot;, procmnt, NULL, MS_PRIVATE|MS_REC, NULL) != 0 ||
     mount(&quot;proc&quot;, procmnt, &quot;proc&quot;, MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL) != 0))
          err(EXIT_FAILURE, _(&quot;mount %s failed&quot;), procmnt);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I can see there are 2 calls to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount(2)&lt;/code&gt; (the system call).  The first isn’t creating a mount, but it’s taking the mount point and making it private recursively.  This is the same as saying &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount --make-private $procmnt&lt;/code&gt;.  Interestingly, if I unmount &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fs1&lt;/code&gt;, and then try to make it private with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount --make-private fs1&lt;/code&gt;, it fails, saying that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;fs1&lt;/code&gt; is not a mountpoint.  This is not the exact error I was getting from &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt;, but I assume it has the same source.  If I run &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount --bind fs1 fs1&lt;/code&gt;, and then run the make private command it works (and similarly with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt; command).  The problem was that the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt; command expects the target for mounting the new proc filesystem to already be a mount point.&lt;/p&gt;

&lt;h1 id=&quot;what-does---make-private-do&quot;&gt;What does &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--make-private&lt;/code&gt; do?&lt;/h1&gt;

&lt;p&gt;It’s nice to know why the command was failing and how to fix it, but what might be more important to understand is why &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt; would be trying to make the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;proc&lt;/code&gt; filesystem private to begin with.&lt;/p&gt;

&lt;p&gt;The &lt;a href=&quot;https://linux.die.net/man/8/mount&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount(8)&lt;/code&gt; manpage&lt;/a&gt; explains the different options for the sharing status of a file system so I won’t repeat them here.  However, it’s useful to know how to tell what the sharing bits are for a particular filesystem.  To get that, I can look at &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/proc/self/mountinfo&lt;/code&gt; and I can see for my procfs a line like this with the word shared in it:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;170 24 0:4 / /home/paul/fs1 rw,relatime shared:146 - proc dummy rw
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If I call &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount --make-private fs1&lt;/code&gt;, the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;shared:146&lt;/code&gt; portion of the line goes away.&lt;/p&gt;

&lt;p&gt;How does a shared mount differ from a private one?  A shared mount means that subsequent calls to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;umount&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount&lt;/code&gt; will propagate to other &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--bind&lt;/code&gt; mounted file systems.  In a private mount, those calls will not propagate.  To illustrate this, here is an example:&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;$ mkdir fs1 fs2 subd1
$ sudo mount --bind fs1 fs1
$ sudo mount --bind fs1 fs2
$ sudo mount --make-private fs1
$ mkdir fs1/sub_mount
$ ls fs2
sub_mount
# ^ Files are propagated between the mounts

$ sudo mount --bind subd1 fs1/sub_mount
$ touch subd1/hello
$ ls fs1/sub_mount
hello
$ ls fs2/sub_mount
$ # nothing
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It turns out that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt; mounts all its new mounts as private by default (see &lt;a href=&quot;http://man7.org/linux/man-pages/man1/unshare.1.html&quot;&gt;unshare(1)&lt;/a&gt;).  Since the purpose of unshare is to isolate it from other things, this makes sense conceptually, but practically, I am having a hard time thinking of when a proc file system being shared would be a thing that mattered, but then again I do not know if there is more mounting that happens during the creation of a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;proc&lt;/code&gt; fs.&lt;/p&gt;

&lt;h1 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h1&gt;

&lt;p&gt;This post was a bit of a random walk around &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;mount&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;unshare&lt;/code&gt;, but I learned something during it, so I wanted to record it in case I find myself wondering about it later.&lt;/p&gt;

</description>
        <pubDate>Mon, 10 Jul 2017 00:00:00 +0000</pubDate>
        <link>http://pcarleton.github.io/2017/07/10/mount.html</link>
        <guid isPermaLink="true">http://pcarleton.github.io/2017/07/10/mount.html</guid>
        
        
      </item>
    
  </channel>
</rss>
