<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Networking | The End of the Tunnel</title><link>https://development--vigilant-hodgkin-644b1e.netlify.com/tags/networking/</link><atom:link href="https://development--vigilant-hodgkin-644b1e.netlify.com/tags/networking/index.xml" rel="self" type="application/rss+xml"/><description>Networking</description><generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><copyright>© 2019 Derek Murawsky</copyright><lastBuildDate>Wed, 29 Aug 2018 12:05:52 -0400</lastBuildDate><image><url>https://development--vigilant-hodgkin-644b1e.netlify.com/img/icon-32.png</url><title>Networking</title><link>https://development--vigilant-hodgkin-644b1e.netlify.com/tags/networking/</link></image><item><title>Rebuilding the Homestead’s DNS with Consul, DNSMasq, and Ansible</title><link>https://development--vigilant-hodgkin-644b1e.netlify.com/post/rebuilding-homestead-dns/</link><pubDate>Wed, 29 Aug 2018 12:05:52 -0400</pubDate><guid>https://development--vigilant-hodgkin-644b1e.netlify.com/post/rebuilding-homestead-dns/</guid><description>
&lt;p&gt;My friend Jason recently posted an update on his blog over at &lt;a href=&#34;https://peaksandprotocols.com/home-network-dns-infrastructure/&#34; target=&#34;_blank&#34;&gt;Peaks and Protocols&lt;/a&gt; about redoing his home network’s DNS setup. This reminded me that I really needed to do an update on my own recent DNS rebuild, which was based around &lt;a href=&#34;https://www.hashicorp.com/&#34; target=&#34;_blank&#34;&gt;Hashicorp&lt;/a&gt;‘s &lt;a href=&#34;https://www.consul.io/&#34; target=&#34;_blank&#34;&gt;Consul&lt;/a&gt;, &lt;a href=&#34;http://www.thekelleys.org.uk/dnsmasq/doc.html&#34; target=&#34;_blank&#34;&gt;DNSMasq&lt;/a&gt; and &lt;a href=&#34;https://www.ansible.com/&#34; target=&#34;_blank&#34;&gt;Ansible&lt;/a&gt; running on some &lt;a href=&#34;https://www.raspberrypi.org/&#34; target=&#34;_blank&#34;&gt;Raspberry Pi 3&lt;/a&gt;s. Overkill? Probably. But if you can’t have fun with your home network, what’s the point? On to the setup…&lt;/p&gt;
&lt;figure&gt;
&lt;a data-fancybox=&#34;&#34; href=&#34;images/homenet.png&#34; &gt;
&lt;img src=&#34;images/homenet.png&#34; alt=&#34;&#34; &gt;&lt;/a&gt;
&lt;/figure&gt;
&lt;h2 id=&#34;consul&#34;&gt;Consul&lt;/h2&gt;
&lt;p&gt;
&lt;figure&gt;
&lt;a data-fancybox=&#34;&#34; href=&#34;images/consul-logo.png&#34; &gt;
&lt;img src=&#34;images/consul-logo.png&#34; alt=&#34;&#34; width=&#34;100&#34; &gt;&lt;/a&gt;
&lt;/figure&gt;
Consul started life as a distributed service locator and key-value store. It has grown significantly over the years and is now becoming a full-fledged service mesh. It allows for any server to register and provide one or multiple services, with simple config files or api calls. Further, Consul supports the idea of multiple locations natively and even has health checks. This means it will give you your local, healthy service endpoint.&lt;/p&gt;
&lt;p&gt;One of the main reasons I chose Consul is because it makes itself available via DNS as the .consul domain. Want to know where your git server is? dig git.service.consul. Your documentation hosted on a webserver somewhere? dig docs.service.consul. This makes finding a service you have running somewhere trivial, and means never having to update a DNS zone file again.&lt;/p&gt;
&lt;p&gt;Another reason, which I’m not using yet, is that it has a solid key-value store. This is great for storing configuration settings for distributed applications. There are a ton of tools that take advantage of this, and even provide dynamic reloading capabilities to the app when a key is changed in Consul.&lt;/p&gt;
&lt;h2 id=&#34;dnsmasq&#34;&gt;DNSMasq&lt;/h2&gt;
&lt;p&gt;In order to take advantage of Consul’s DNS features you need a DNS server that can point to Consul for just that domain, while passing through all other traffic to a normal DNS resolver. I chose DNSMasq for this because it is simple and well understood. There were some security issues with it last year, but they have since been addressed. I may migrate to &lt;a href=&#34;https://nlnetlabs.nl/projects/unbound/about/&#34; target=&#34;_blank&#34;&gt;unbound&lt;/a&gt; in the long run, but DNSMasq is fine for my use cases.&lt;/p&gt;
&lt;h2 id=&#34;ansible-putting-it-all-together&#34;&gt;Ansible &amp;amp; Putting it All Together&lt;/h2&gt;
&lt;figure&gt;
&lt;a data-fancybox=&#34;&#34; href=&#34;images/ansible-logo.png&#34; &gt;
&lt;img src=&#34;images/ansible-logo.png&#34; alt=&#34;&#34; width=&#34;100&#34; &gt;&lt;/a&gt;
&lt;/figure&gt;
&lt;p&gt;Ansible is the glue that makes sure I can redo this config easily should something happen to the PIs. It is a configuration management system that just works, with minimal extra craziness. I could go on for days about Ansible, and probably should write a dozen posts on it alone, but there’s so much out there already that I don’t feel the need. Bottom line is, this is the tool that sets up Consul and DNSMasq for me, and ensures that I can reset everything to a known working state in the event of configuration drift.&lt;/p&gt;
&lt;p&gt;I used several modules to help get this project running quickly.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/idealista/consul-role&#34; target=&#34;_blank&#34;&gt;idealista-consul-role&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/Oefenweb/ansible-dnsmasq&#34; target=&#34;_blank&#34;&gt;oefenweb.dnsmasq&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/geerlingguy/ansible-role-ntp&#34; target=&#34;_blank&#34;&gt;geerlingguy.ntp&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I ended up having to change some of the roles around to suit the raspberry pi environment, but otherwise it was fairly easy. I created my own baseline role which updates and upgrades and installs some packages, including python and its tools. This base role also creates a user account for me and Ansible itself. The first time I ran it, I had to pass parameters to login as the default Raspbian user, but after that it can run using the Ansible user instead.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-yaml&#34;&gt;- name: Update Apt and Upgrade Packages
apt:
update_cache: yes
cache_valid_time: 3600
name: &amp;quot;*&amp;quot;
state: latest
tags:
- packages
- name: Install Baseline Apps
apt:
name: &amp;quot;{{ packages }}&amp;quot;
state: present
vars:
packages:
- python
- python-pip
- python3
- python3-pip
- virtualenv
- python3-virtualenv
- python-pip
- dnsutils
tags:
- packages
- name: Install pi base python packages
pip:
name: &amp;quot;{{ packages }}&amp;quot;
state: present
vars:
packages:
- python-consul
- hvac
- name: Create Ansible management user
user:
name: ansible
comment: Ansible system user
group: admin
state: present
- name: Create dmurawsky user
user:
name: dmurawsky
comment: Derek Murawsky
group: admin
state: present
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For my group_vars, I created a DNS.yml file with the needed variables for consul and DNSMasq.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-yaml&#34;&gt;# Consul Configuration
consul_version: 1.2.2
#consul_package: consul_1.2.2_linux_arm.zip
consul_server: true
consul_agent: true
consul_ui: true
consul_server_nodes:
- 192.168.1.2
- 192.168.1.3
# Services #
consul_agent_services: true
consul_services_register:
# Register NTP in consul
- name: ntp
port: 123
tags:
- udp
- name: dns
port: 53
tags:
- udp
# Hashicorp Vault
vault_version: 0.10.4
vault_pkg: vault_{{ vault_version }}_linux_arm.zip
vault_pkg_sum: 384e47720cdc72317d3b8c98d58e6c8c719ff3aaeeb71b147a6f5f7a529ca21b
# DNSMasq
dnsmasq_dnsmasq_conf:
- |
port=53
bind-interfaces
server=8.8.8.8
server=8.8.4.4
dnsmasq_dnsmasq_d_files_present:
cache:
- |
domain-needed
bogus-priv
no-hosts
dns-forward-max=150
cache-size=1000
neg-ttl=3600
no-poll
no-resolv
consul:
- |
server=/consul/127.0.0.1#8600
homestead-murawsky-net:
- address=/usg.homestead.murawsky.net/192.168.1.1
- address=/ns1.homestead.murawsky.net/192.168.1.2
- address=/ns2.homestead.murawsky.net/192.168.1.3
# NTP
ntp_enabled: true
ntp_manage_config: true
ntp_area: &#39;us&#39;
ntp_servers:
- &amp;quot;0{{ ntp_area }}.pool.ntp.org iburst&amp;quot;
- &amp;quot;1{{ ntp_area }}.pool.ntp.org iburst&amp;quot;
- &amp;quot;2{{ ntp_area }}.pool.ntp.org iburst&amp;quot;
- &amp;quot;3{{ ntp_area }}.pool.ntp.org iburst&amp;quot;
ntp_timezone: America/New_York
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And finally, the simple site.yml file.&lt;/p&gt;
&lt;pre&gt;&lt;code class=&#34;language-yaml&#34;&gt;- name: Configure System Baselines
hosts: all
roles:
- { role: baseline, tags: [&#39;baseline&#39;]}
- name: Configure DNS hosts
hosts: dns
roles:
- { role: ntp, tags: [&#39;ntp&#39;] }
- { role: dnsmasq, tags: [&#39;dnsmasq&#39;] }
- { role: consul, tags: [&#39;consul&#39;] }
- { role: hashivault, tags: [&#39;hashivault&#39;] }
&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&#34;results&#34;&gt;Results&lt;/h2&gt;
&lt;p&gt;DNS resolution worked perfectly out of the gate as expected, but what about Consul?&lt;/p&gt;
&lt;p&gt;
&lt;figure&gt;
&lt;a data-fancybox=&#34;&#34; href=&#34;images/consul-screenshot.png&#34; &gt;
&lt;img src=&#34;images/consul-screenshot.png&#34; alt=&#34;&#34; width=&#34;600&#34; &gt;&lt;/a&gt;
&lt;/figure&gt;
Brilliant! Sure, the services that I have loaded are pretty simple and don’t really benefit from a service locator, but they’re examples of what is possible. Now I can register any new service by loading the consul agent onto the server and simply adding a definition file in the appropriate folder! This should make future expansion of services much easier.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; I currently have two consul servers. This is bad and not highly available. I have to get one more consul server online. Debating between another pi or putting on the home server.&lt;/p&gt;
&lt;h2 id=&#34;future-plans&#34;&gt;Future Plans&lt;/h2&gt;
&lt;p&gt;You’ll notice there’s no real security around the deployment above either. That needs to be fixed in terms of Consul ACLs, Vault, and password/key management for user accounts. There’s also a cool tool called &lt;a href=&#34;https://pi-hole.net/&#34; target=&#34;_blank&#34;&gt;pi-hole&lt;/a&gt; which is a dns level ad blocker that I want to integrate into my environment. I also plan on setting up Docker on my home server in the not too distant future to make it easier to host some fun services like &lt;a href=&#34;https://prometheus.io/&#34; target=&#34;_blank&#34;&gt;Prometheus&lt;/a&gt;, &lt;a href=&#34;https://grafana.com/&#34; target=&#34;_blank&#34;&gt;Grafana&lt;/a&gt;, &lt;a href=&#34;https://www.home-assistant.io/&#34; target=&#34;_blank&#34;&gt;HomeAssistant&lt;/a&gt;, and some other cool tools. I’ll also have to extend the network to my barn as the office is moving out there. Lastly, I want to build a portable lab that I can take with me when doing demos or presentation at local user groups.&lt;/p&gt;</description></item><item><title>Homestead Network Upgrades</title><link>https://development--vigilant-hodgkin-644b1e.netlify.com/post/homestead-network-upgrades/</link><pubDate>Sun, 22 Oct 2017 12:05:33 -0400</pubDate><guid>https://development--vigilant-hodgkin-644b1e.netlify.com/post/homestead-network-upgrades/</guid><description>&lt;p&gt;Despite coming from the networking side of IT, I tend to use regular consumer grade equipment at home. It typically just works, and I’m not looking for extreme reliability or features. I’ve been using hardware from Linksys, Netgear, and the other consumer network vendors for at least the last 10 years. Sometimes, though, things happen that make you reevaluate your previous life choices…&lt;/p&gt;
&lt;p&gt;For me, that thing was an email that I received from Verizon saying my router was infected with malware. Since I always take basic precautions like changing the default password and locking down external ports, I was a bit surprised. Turns out, there was a vulnerability in the firmware that had gone unpatched for months… In hindsight, I should not have been that surprised. At all. I thought I had purchased a flagship router that would be supported for at least a few years, but it didn’t look like any more patches were coming. Ever. I looked into trusty old &lt;a href=&#34;http://www.dd-wrt.com/&#34; target=&#34;_blank&#34;&gt;DD-WRT&lt;/a&gt; figuring that I could flash the router and at least get another year out of it, but apparently the R7000 has some performance issues with DD-WRT.&lt;/p&gt;
&lt;p&gt;After having issues like this a few times with generic consumer grade stuff over the years, no matter the vendor, I decided enough was enough. I researched available options in the enterprise hardware space (way too expensive and time consuming to set up), looked at open source alternatives (cheap, but time consuming, and not well integrated), and even looked at the more pro-level offerings from consumer manufacturers (underwhelming). After a few days, I decided on and purchased some &lt;a href=&#34;https://www.ubnt.com/&#34; target=&#34;_blank&#34;&gt;Ubiquiti&lt;/a&gt; hardware based on the many good reviews and a few personal recommendations from networking folks I respect.&lt;/p&gt;
&lt;figure&gt;
&lt;a data-fancybox=&#34;&#34; href=&#34;images/ubiquiti-logo.png&#34; &gt;
&lt;img src=&#34;images/ubiquiti-logo.png&#34; alt=&#34;&#34; width=&#34;150&#34; &gt;&lt;/a&gt;
&lt;/figure&gt;
&lt;p&gt;Ubiquiti’s hardware is solid stuff, performance wise, and they have a very good reputation. The hardware is what I would call “Enterprise Lite”, meaning it’s not Cisco, but its perfect for small to medium businesses who just want things to work. Additionally, the &lt;a href=&#34;https://unifi-sdn.ubnt.com/&#34; target=&#34;_blank&#34;&gt;Unifi configuration system&lt;/a&gt; and dashboard is excellent, taking a significant configuration and support burden off of me.&lt;/p&gt;
&lt;p&gt;The initial hardware purchase was:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://www.ubnt.com/unifi-routing/unifi-security-gateway-pro-4/&#34; target=&#34;_blank&#34;&gt;Unifi Security Gateway Pro&lt;/a&gt; (&lt;a href=&#34;https://www.amazon.com/gp/product/B019PBEI5W&#34; target=&#34;_blank&#34;&gt;Amazon&lt;/a&gt;)- I definitely went overkill here. The &lt;a href=&#34;https://www.amazon.com/Ubiquiti-Unifi-Security-Gateway-USG/dp/B00LV8YZLK/&#34; target=&#34;_blank&#34;&gt;entry model USG&lt;/a&gt; is capable of routing gigabit at near wirespeed. However, I decided that I likes the extra ports for a few future projects, like the barn office.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.ubnt.com/unifi-switching/unifi-switch-8/&#34; target=&#34;_blank&#34;&gt;Unifi Switch 8, 60 Watt&lt;/a&gt; (&lt;a href=&#34;https://www.amazon.com/gp/product/B01MU3WUX1&#34; target=&#34;_blank&#34;&gt;Amazon&lt;/a&gt;)- Since the new network was not an all-in-one setup, I needed something to power the other devices around the house. This managed switch provided a lot more than just that, though. The VLANs will come in handy when we set up the home office.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.ubnt.com/unifi/unifi-ap-ac-pro/&#34; target=&#34;_blank&#34;&gt;Unifi AP AC Pro&lt;/a&gt; (&lt;a href=&#34;https://www.amazon.com/gp/product/B015PRO512&#34; target=&#34;_blank&#34;&gt;Amazon&lt;/a&gt;)- Another bit of overkill for home use, but this one was easier to justify than the firewall. Simply put, it has more power, and I need that given the 2′ thick stone walls in the farmhouse.&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://www.ubnt.com/unifi/unifi-cloud-key/&#34; target=&#34;_blank&#34;&gt;Unifi Cloud Key&lt;/a&gt; (&lt;a href=&#34;https://www.amazon.com/gp/product/B017T2QB22&#34; target=&#34;_blank&#34;&gt;Amazon&lt;/a&gt;)- Though not strictly necessary, the Cloud Key allows you to run your network controller app on dedicated hardware. It can also be linked to the Unifi cloud portal allowing for a very convenient and secure hybrid cloud management platform.&lt;/li&gt;
&lt;/ul&gt;
&lt;figure&gt;
&lt;a data-fancybox=&#34;&#34; href=&#34;images/murawsky-homestead-physical.png&#34; &gt;
&lt;img src=&#34;images/murawsky-homestead-physical.png&#34; alt=&#34;&#34; width=&#34;300&#34; &gt;&lt;/a&gt;
&lt;/figure&gt;
&lt;p&gt;The hardware wasn’t cheap, but surprisingly, it wasn’t much more than I paid for the R7000 two years ago. If I had chosen the regular USG, the price difference would have been negligible.&lt;/p&gt;
&lt;p&gt;As for the setup, it was easier than I thought. I racked the USG Pro, plugged in the switch, then the cloud key. Thankfully I had already run the line to the wireless AP so that was easy. I also threw in a Raspberry Pi server for fun. It took about 10 minutes to patch everything together. But what about the configuration?&lt;/p&gt;
&lt;p&gt;Well, thanks to the Unifi software on the Cloud Key, I was able to “adopt” the other devices and have them configured in no time at all. My basic single vlan setup was ready to go out of the box. All totaled, I had the network up and running in 20 minutes. Time vs the R7000? Maybe an extra 10 minutes.&lt;/p&gt;
&lt;figure&gt;
&lt;a data-fancybox=&#34;&#34; href=&#34;images/unifi-dash.png&#34; &gt;
&lt;img src=&#34;images/unifi-dash.png&#34; alt=&#34;&#34; width=&#34;600&#34; &gt;&lt;/a&gt;
&lt;/figure&gt;
&lt;p&gt;What has it been like living with “Enterprise Lite” hardware at home? Fantastic. Having a useful dashboard that I can glance at to see the status of the home network is a perk I didn’t think I would care about, but I’ve used it several times already. The speed is true gigabit on wired, the wireless coverage is solid, and we don’t have random drops in connectivity anymore. And as for patches… I’ve already had two patches come through for stack. It’s a simple matter of hitting the upgrade button for the device, or setting up auto-upgrade. As far as I’m concerned, I’m never going back to consumer gear again.&lt;/p&gt;</description></item></channel></rss>