<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mikrotik on Major Hayden</title><link>https://major.io/tags/mikrotik/</link><description>Recent content in Mikrotik on Major Hayden</description><generator>Hugo</generator><language>en</language><managingEditor>major@mhtx.net (Major Hayden)</managingEditor><webMaster>major@mhtx.net (Major Hayden)</webMaster><copyright>All content licensed [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/)</copyright><lastBuildDate>Sun, 07 Jun 2026 23:39:03 +0000</lastBuildDate><atom:link href="https://major.io/tags/mikrotik/index.xml" rel="self" type="application/rss+xml"/><item><title>Add a VLAN on a Mikrotik router</title><link>https://major.io/p/mikrotik-vlan/</link><pubDate>Thu, 20 Apr 2023 00:00:00 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/mikrotik-vlan/</guid><description>&lt;p&gt;If your house is like mine, you have devices that you really trust and then there are
those &lt;em&gt;other devices&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;My trusted device group includes my work computers, a Synology NAS, and a few other
computers. The bucket of untrusted devices includes Chromecasts, TVs, tablets, phones,
and whatever random devices that my kids&amp;rsquo; friends bring over.&lt;/p&gt;
&lt;p&gt;A &lt;a href="https://en.wikipedia.org/wiki/VLAN"&gt;VLAN&lt;/a&gt; helps with traffic segmentation by
isolating certain traffic over the same network cable. A router can manage tons of
different networks via the same downlink cable(s) to a switch or other equipment. You
can tell a switch to only allow certain VLANs through a port or you can have the port
only offer one network that happens to be one of your VLANs.&lt;/p&gt;
&lt;p&gt;The best analogy for a VLAN is a &lt;em&gt;cable within a cable&lt;/em&gt;. It&amp;rsquo;s almost like being able to
add thousands of individual segmented networks in the same ethernet cable.&lt;/p&gt;
&lt;p&gt;VLANs are possible via a networking standard called
&lt;a href="https://en.wikipedia.org/wiki/IEEE_802.1Q"&gt;802.1Q&lt;/a&gt;. Network devices add a small 802.1Q
header, often called a &lt;em&gt;VLAN tag&lt;/em&gt;, to each ethernet packet. These tags offer a way for
network devices to filter traffic on a network.&lt;/p&gt;
&lt;p&gt;It works well for devices that don&amp;rsquo;t understand VLANs, too. For example, if you have a
device that isn&amp;rsquo;t VLAN-aware, you can plug it into a switch port that is configured to
offer a VLAN network as the native VLAN. That device happily uses the network it is
offered via the switch port without knowing that the switch is adding VLAN tags to all
traffic that the device creates.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s get a VLAN working on a Mikrotik router.&lt;/p&gt;
&lt;h1 id="adding-a-vlan"&gt;Adding a VLAN&lt;/h1&gt;
&lt;p&gt;Mikrotik devices have a great command line interface and I&amp;rsquo;ll use that for this post.&lt;/p&gt;
&lt;p&gt;In this example, my networks are set up like this:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I have a default LAN network: &lt;code&gt;192.168.10.0/24&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;My VLAN network is tagged with tag 15: &lt;code&gt;192.168.15.0/24&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The basic building block of any network on a Mikrotik device is an &lt;em&gt;interface&lt;/em&gt;. We start
by creating a VLAN interface:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/interface vlan \
add interface=bridge name=vlan15 vlan-id=15
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;My router uses a bridge called &lt;code&gt;bridge&lt;/code&gt; &lt;em&gt;(gotta keep things simple)&lt;/em&gt;, but you may need
to use something like &lt;code&gt;ether2&lt;/code&gt; or &lt;code&gt;ether3&lt;/code&gt; if you&amp;rsquo;re using a physical network interface
instead of a bridge.&lt;/p&gt;
&lt;p&gt;Now I can add an IP address to my new network interface:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip address \
add address=192.168.15.1/24 interface=vlan15 network=192.168.15.0
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;DHCP sure does make IP address configuration easier, so let&amp;rsquo;s create an address pool and
a DHCP server instance for our VLAN network. Choose whatever range makes sense for you
but my default is usually &lt;code&gt;10-254&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip pool \
add name=vlan15 ranges=192.168.15.10-192.168.15.254
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Add a DHCP server and a DHCP network configuration:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip dhcp-server \
add address-pool=vlan15 interface=vlan15 name=vlan15
/ip dhcp-server network
add address=192.168.15.0/24 dns-server=192.168.15.1 gateway=192.168.15.1
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The DHCP server uses our &lt;code&gt;vlan15&lt;/code&gt; address pool for handing out addresses to devices on
the VLAN.&lt;/p&gt;
&lt;h1 id="testing-the-vlan"&gt;Testing the VLAN&lt;/h1&gt;
&lt;p&gt;I like to give the VLAN a quick test with my desktop PC before I start messing around
with the switch configuration. We just need to add a VLAN device via &lt;code&gt;nmcli&lt;/code&gt; and verify
that DHCP and routing are working.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s add a new interface called &lt;code&gt;VLAN15&lt;/code&gt; to handle traffic tagged with VLAN 15:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# Replace enp7s0 with your ethernet interface name!
$ nmcli con add type vlan ifname VLAN15 con-name VLAN15 dev enp7s0 id 15
Connection &amp;#39;VLAN15&amp;#39; (f7cd4cdf-d2ce-4dc7-9ed8-f40102ff3e42) successfully added.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Did we get an IP address and a route?&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ ip addr show dev VLAN15
7: VLAN15@enp7s0: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu 1500 qdisc noqueue state UP group default qlen 1000
 link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
 inet 192.168.15.52/24 brd 192.168.15.255 scope global dynamic noprefixroute VLAN15
 valid_lft 409sec preferred_lft 409sec
 inet6 fe80::7f62:9d9a:dc8c:3fd7/64 scope link noprefixroute 
 valid_lft forever preferred_lft forever
$ ip route show dev VLAN15
192.168.15.0/24 proto kernel scope link src 192.168.15.52 metric 400 
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Awesome!&lt;/p&gt;
&lt;h1 id="using-it-with-a-switch"&gt;Using it with a switch&lt;/h1&gt;
&lt;p&gt;I have a Mikrotik CRS that I use for my main home switch and it handles VLAN tagging. My
goal here is to &lt;em&gt;trunk&lt;/em&gt; VLAN 15 from the router down to the switch so that a particular
port &lt;em&gt;ONLY&lt;/em&gt; exposes the VLAN 15 network to a device. I don&amp;rsquo;t want that device to have
any idea that VLAN 15 even exists. It should think that there&amp;rsquo;s a regular old LAN
network coming through the switch port.&lt;/p&gt;
&lt;p&gt;This is called an &lt;em&gt;access port&lt;/em&gt;. Devices on the port have no idea that VLAN tagging is
happening on the switch, but the switch tags all traffic coming from the port.&lt;/p&gt;
&lt;p&gt;In this example, I set up switch port &lt;code&gt;ether18&lt;/code&gt; to take VLAN 15 and make it available as
the native VLAN to anything connected to that switch port:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# Translate VLAN 15 to the native VLAN on ether18
# This is creating the access port
/interface ethernet switch ingress-vlan-translation \
add ports=ether18 customer-vid=0 new-customer-vid=15

# Ensure that traffic tagged with VLAN 15 can exit the switch
# through the uplink to the router
/interface ethernet switch egress-vlan-tag \
add tagged-ports=ether1 vlan-id=15

# Add VLAN table entries to show which ports are members of the VLAN
/interface ethernet switch vlan \
add ports=ether1,ether18 vlan-id=15

# Don&amp;#39;t allow anyone on port ether18 to tag their traffic with a
# different VLAN ID and circumvent our access port settings
/interface ethernet switch \
set drop-if-invalid-or-src-port-not-member-of-vlan-on-ports=ether1,ether18
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;At this point, I can connect a device to port &lt;code&gt;ether18&lt;/code&gt; and it gets an IP address via
DHCP on the &lt;code&gt;192.168.15.1&lt;/code&gt; network automatically!&lt;/p&gt;
&lt;p&gt;For further reading on these settings, check out Mikrotik&amp;rsquo;s wiki page of
&lt;a href="https://wiki.mikrotik.com/wiki/Manual:CRS1xx/2xx_series_switches_examples"&gt;switch configuration examples&lt;/a&gt;.&lt;/p&gt;
&lt;h1 id="extra-credit"&gt;Extra credit&lt;/h1&gt;
&lt;p&gt;Once you begin segmenting your network, review your router configuration to see how
these networks are allowed to communicate with one another. The default on Mikrotik
devices is to allow internal networks to freely communicate with each other since that
makes everything easier to get started. However, I don&amp;rsquo;t want my Chromecast to talk to
my NAS.&lt;/p&gt;
&lt;p&gt;Mikrotik&amp;rsquo;s IP firewalling capabilities give you lots of methods for limiting access
between networks. Be sure to read up on the
&lt;a href="https://wiki.mikrotik.com/wiki/Manual:IP/Firewall/Filter"&gt;IP/Firewall/Filter&lt;/a&gt;
documentation. If you use IPv6 on your network, be sure to review the
&lt;a href="https://wiki.mikrotik.com/wiki/Manual:IPv6/Firewall/Filter"&gt;IPv6/Firewall/Filter&lt;/a&gt; docs,
too.&lt;/p&gt;
&lt;p&gt;Even if you think that you aren&amp;rsquo;t using IPv6 internally, &lt;a href="https://en.wikipedia.org/wiki/Link-local_address"&gt;you might actually be using
it&lt;/a&gt;. 😉&lt;/p&gt;</description></item><item><title>Monitor a UPS with a Mikrotik router via SNMP</title><link>https://major.io/p/monitor-ups-with-mikrotik-snmp/</link><pubDate>Fri, 28 Oct 2022 00:00:00 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/monitor-ups-with-mikrotik-snmp/</guid><description>&lt;p&gt;Cyberpower UPS units saved me from plenty of issues in the past with power outages.
However, although I love the units themselves, I found that the quality of replacement batteries varies widely.
This leads me to keep a close watch on my UPS units and test them regularly.&lt;/p&gt;
&lt;p&gt;Energy conservation ranks high on my list of priorities, too.
I monitor the power draw on my UPS units to know about usage spikes or to review electricity consumption after I make changes.&lt;/p&gt;
&lt;p&gt;My Raspberry Pi did a great job of monitoring my UPS for my network devices but it failed after a recent reboot.
My &lt;a href="https://major.io/2022/09/02/pxe-boot-netboot.xyz-on-a-mikrotik-router/"&gt;network woes&lt;/a&gt; from September left me with a &lt;a href="https://mikrotik.com/product/hex_s"&gt;Mikrotik hEXs&lt;/a&gt; running my home network and I noticed it had a USB port.&lt;/p&gt;
&lt;p&gt;Can you monitor a UPS with a Mikrotik device and query its status remotely?
&lt;strong&gt;You can!&lt;/strong&gt;&lt;/p&gt;
&lt;h1 id="initial-setup"&gt;Initial setup&lt;/h1&gt;
&lt;p&gt;My Cyberpower &lt;a href="https://www.cyberpowersystems.com/product/ups/intelligent-lcd/cp1500avrlcd/"&gt;CP1500AVRLCD&lt;/a&gt; has a USB port on the back for monitoring and control.
The hEXs router has a USB-A port on the side that can be used for mass storage, LTE modems, and yes &amp;ndash; UPS units.&lt;/p&gt;
&lt;p&gt;However, UPS monitoring does not come standard with RouterOS 7.x and it must be installed via a separate package.
Follow these steps to get started:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Identify the CPU architecture of your Mikrotik.
It should be shown on the product page.
The &lt;a href="https://mikrotik.com/product/hex_s"&gt;Mikrotik hEXs&lt;/a&gt; is a MMIPS (&lt;a href="https://en.wikipedia.org/wiki/MIPS_architecture#microMIPS"&gt;microMIPS&lt;/a&gt;) device.&lt;/li&gt;
&lt;li&gt;Go to the RouterOS &lt;a href="https://mikrotik.com/download"&gt;download page&lt;/a&gt; and download the &lt;strong&gt;Extra packages&lt;/strong&gt; file for your architecture.&lt;/li&gt;
&lt;li&gt;Unpack the zip file you downloaded and locate the &lt;code&gt;ups-7.x-mmips.npk&lt;/code&gt; package.&lt;/li&gt;
&lt;li&gt;Upload the &lt;code&gt;ups-7.x-mmips.npk&lt;/code&gt; file via your preferred method.
FTP, ssh, and the web interface work well for this.&lt;/li&gt;
&lt;li&gt;Reboot your Mikrotik device.&lt;/li&gt;
&lt;/ol&gt;
&lt;h1 id="enable-monitoring"&gt;Enable monitoring&lt;/h1&gt;
&lt;p&gt;After the reboot, your Mikrotik should now have a &lt;code&gt;/system/ups&lt;/code&gt; entry on the command line.
Let&amp;rsquo;s add monitoring for our UPS:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[major@hexs] &amp;gt; /system/ups
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[major@hexs] /system/ups&amp;gt; add name=ups min-runtime=never port=usbhid1
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you don&amp;rsquo;t know what your port is called, type in &lt;code&gt;add port=&lt;/code&gt; and press &lt;code&gt;TAB&lt;/code&gt; to see the available ports.
Refer to the &lt;a href="https://wiki.mikrotik.com/wiki/Manual:System/UPS"&gt;Mikrotik System/UPS manual&lt;/a&gt; for more help here.&lt;/p&gt;
&lt;p&gt;I set the &lt;code&gt;min-runtime&lt;/code&gt; to &lt;code&gt;never&lt;/code&gt; which means that the Mikrotik will never hibernate even if the UPS power runs low.
It uses so little power and it&amp;rsquo;s so critical for my home network that it should be the last system to go offline during an outage.&lt;/p&gt;
&lt;p&gt;All that&amp;rsquo;s left is to enable read-only SNMP so that we can monitor the UPS remotely.
Back to the Mikrotik command line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[major@hexs] &amp;gt; /snmp/set enabled=yes
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This enables unrestricted read-only SNMP access for your entire network without authentication under the community name &lt;em&gt;public&lt;/em&gt;.
I restrict SNMP access with firewall rules but you may want to consider further restrictions on your SNMP community.&lt;/p&gt;
&lt;h1 id="getting-data"&gt;Getting data&lt;/h1&gt;
&lt;p&gt;From another machine on the network, I dumped all of the SNMP data from the Mikrotik into a file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; snmpwalk -v2c -c public 192.168.10.1 &lt;span class="p"&gt;|&lt;/span&gt; tee -a /tmp/snmpwalk.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then I looked for my UPS&amp;rsquo; model name:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; grep LCD /tmp/snmpwalk.txt 
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.1.2.0 = STRING: &amp;#34;CP1500AVRLCDa&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.47.1.1.1.1.2.262146 = STRING: &amp;#34;CPS CP1500AVRLCDa&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let&amp;rsquo;s see if the first entry gives us the data we need:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;&amp;gt;&lt;/span&gt; $ grep &lt;span class="s2"&gt;&amp;#34;^SNMPv2-SMI::mib-2.33&amp;#34;&lt;/span&gt; /tmp/snmpwalk.txt 
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.1.2.0 = STRING: &amp;#34;CP1500AVRLCDa&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.1.3.0 = &amp;#34;&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.2.1.0 = INTEGER: 2
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.2.3.0 = INTEGER: 103
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.2.4.0 = INTEGER: 100
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.2.5.0 = INTEGER: 0
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.2.7.0 = INTEGER: 0
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.3.2.0 = INTEGER: 1
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.3.3.1.2.3 = INTEGER: 0
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.3.3.1.3.3 = INTEGER: 122
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.4.3.0 = INTEGER: 1
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.4.4.1.2.3 = INTEGER: 122
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.4.4.1.5.3 = INTEGER: 8
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SNMPv2-SMI::mib-2.33.1.6.1.0 = Gauge32: 0
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;What the heck do all these numbers mean?
A quick trip to a &lt;a href="https://www.oidview.com/mibs/0/UPS-MIB.html"&gt;MIB browser&lt;/a&gt; shows us that there are a few important items here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;upsOutputPercentLoad&lt;/code&gt; is &lt;code&gt;1.4.4.1.5&lt;/code&gt; (8%)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;upsOutputVoltage&lt;/code&gt; is &lt;code&gt;1.4.4.1.2&lt;/code&gt; (122V)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;upsEstimatedChargeRemaining&lt;/code&gt; is &lt;code&gt;1.2.4.0&lt;/code&gt; (100%)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;These are the three numbers I care most about.
However, the percent load of 8% isn&amp;rsquo;t terribly useful.
I&amp;rsquo;d rather have watts.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s write a script to get the value, and convert the percentage to watts:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;set -euo pipefail
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# From the CP1500AVRLCDa spec sheet
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;MAX_LOAD_WATTS=815
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# SNMP MIB for load percentage
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;SNMP_MIB=&amp;#34;SNMPv2-SMI::mib-2.33.1.4.4.1.5.3&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Get the load integer only.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CURRENT_LOAD=$(snmpget -Oqv -v2c -c public 192.168.10.1 $SNMP_MIB)
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# Convert the percentage into wattage consumed right now.
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;CURRENT_WATTS=$(($MAX_LOAD_WATTS * $CURRENT_LOAD / 100))
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;echo &amp;#34;${CURRENT_WATTS}&amp;#34;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let&amp;rsquo;s test the script!&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;$&lt;/span&gt; ./get_wattage.sh
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;65
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Awesome! 🎉&lt;/p&gt;</description></item><item><title>PXE boot netboot.xyz on a Mikrotik router</title><link>https://major.io/p/pxeboot-netboot.xyz-on-mikrotik-router/</link><pubDate>Fri, 02 Sep 2022 00:00:00 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/pxeboot-netboot.xyz-on-mikrotik-router/</guid><description>&lt;p&gt;The first RFCs for &lt;a href="https://en.wikipedia.org/wiki/Preboot_Execution_Environment"&gt;PXE&lt;/a&gt;, or preboot execution environment, showed up in June 1981 and it&amp;rsquo;s still a popular tool today.
It enables computers to boot up and download some software that runs early in the boot process.&lt;/p&gt;
&lt;p&gt;Although PXE has been with us for ages, it&amp;rsquo;s still extremely relevant today:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Provisioning:&lt;/strong&gt; Deploying new operating systems to machines is easily automated with PXE.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Rescue:&lt;/strong&gt; Fix a broken system by booting into a live OS and then make repairs.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Validation:&lt;/strong&gt; PXE boot a machine into a validation suite that checks hardware or puts it through a burn-in process.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ephemeral OS:&lt;/strong&gt; Boot into a live operating system that runs completely in RAM and disappears on reboot.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A good friend of mine started a project to take PXE booting to the next level.&lt;/p&gt;
&lt;h1 id="enter-netbootxyz"&gt;Enter netboot.xyz&lt;/h1&gt;
&lt;p&gt;Most of the PXE deployments I&amp;rsquo;ve used in the past were restricted to a company&amp;rsquo;s internal network for specfic uses.
These deployments often served as a provisioning method.&lt;/p&gt;
&lt;p&gt;Although the actual mechanisms for booting machines via PXE are not difficult, writing the backend scripts and creating keyboard-friendly menus is challenging.
One of my favorite people on the planet, &lt;a href="https://github.com/antonym"&gt;Ant Messerli&lt;/a&gt;, started the &lt;a href="https://netboot.xyz"&gt;netboot.xyz&lt;/a&gt; project several years ago.&lt;/p&gt;
&lt;p&gt;What does netboot.xyz do for you?
For one, you don&amp;rsquo;t need to write your own menu scripts.
All you do is PXE boot and use the menus already available on the site.
You can even add your own in &lt;a href="https://github.com/netbootxyz/netboot.xyz"&gt;netboot.xyz&amp;rsquo;s GitHub repository&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The site relies on &lt;a href="https://ipxe.org/"&gt;ipxe&lt;/a&gt;, an open source boot firmware.
There&amp;rsquo;s no need to compile your own ipxe binary.
netboot.xyz offers &lt;a href="https://netboot.xyz/downloads/"&gt;pre-built ipxe binaries&lt;/a&gt; that already connect you to netboot.xyz on the first boot!&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s what you&amp;rsquo;ll see from netboot.xyz on your first boot:&lt;/p&gt;
&lt;p&gt;&lt;img alt="Animation of selecting menu items from netboot.xyz" loading="lazy" src="https://major.io/p/pxeboot-netboot.xyz-on-mikrotik-router/netboot.xyz.gif"&gt;&lt;/p&gt;
&lt;h1 id="pxe-ingredients"&gt;PXE ingredients&lt;/h1&gt;
&lt;p&gt;Now that netboot.xyz did the hard part, what&amp;rsquo;s left?
A PXE environment requires a few items:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DHCP server&lt;/li&gt;
&lt;li&gt;TFTP server&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The DHCP server normally tells the machine about its IP address, gateway, DNS servers and more.
However, we need it to provide two extra pieces of information:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The server running a TFTP daemon&lt;/li&gt;
&lt;li&gt;The filename to request&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The boot process for a machine on your network will go something like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Machine makes a DHCP request&lt;/li&gt;
&lt;li&gt;Your DHCP server replies with the usual IP information plus a server IP and filename for the PXE software&lt;/li&gt;
&lt;li&gt;Machine sets its IP, gateway, netmask, and DNS&lt;/li&gt;
&lt;li&gt;Machine downloads the PXE software from the server provided by the DHCP server&lt;/li&gt;
&lt;li&gt;PXE software runs on the machine&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id="mikrotik-pxe-configuration"&gt;Mikrotik PXE configuration&lt;/h1&gt;
&lt;p&gt;Let&amp;rsquo;s update the DHCP server configuration first.
Log into your Mikrotik router via ssh and add configuration to your DHCP server&amp;rsquo;s network configuration&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[major@hexs] &amp;gt; /ip/dhcp-server/
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[major@hexs] /ip/dhcp-server&amp;gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[major@hexs] /ip/dhcp-server/network&amp;gt; print
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;Columns: ADDRESS, GATEWAY, DNS-SERVER
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;# ADDRESS GATEWAY DNS-SERVER 
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;0 192.168.10.0/24 192.168.10.1 192.168.10.1
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[major@hexs] /ip/dhcp-server/network&amp;gt; set next-server=192.168.10.1 boot-file-name=pxeboot numbers=0
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Great.
Now our DHCP server will tell new machines where to find their PXE image.
Now we need to get our PXE boot image.
Most of my machines support UEFI, so I use the &lt;a href="https://boot.netboot.xyz/ipxe/netboot.xyz.efi"&gt;UEFI DHCP image&lt;/a&gt;.
Upload the image to the mikrotik however you prefer.
I normally use FTP or the web interface.&lt;/p&gt;
&lt;p&gt;My PXE image is stored on the Mikrotik as &lt;code&gt;/netboot.xyz/netboot.xyz.efi&lt;/code&gt;.
Now we can set configure the Mikrotik&amp;rsquo;s built-in FTP server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-text" data-lang="text"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[major@hexs] &amp;gt; /ip tftp
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;add ip-addresses=192.168.10.0/24 real-filename=\
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; /netboot.xyz/netboot.xyz.efi req-filename=.*
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;[major@hexs] &amp;gt; /ip tftp settings
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;set max-block-size=8192
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;These settings enable TFTP access for anything on my LAN.
Also, my PXE image from netboot.xyz is returned no matter what is in the request.&lt;/p&gt;
&lt;p&gt;Now it&amp;rsquo;s time for a quick test! On Fedora, you can install a &lt;code&gt;tftp&lt;/code&gt; client by running &lt;code&gt;dnf install tftp&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;❯ tftp 192.168.10.1 -v -m binary -c get pxeboot
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;mode set to octet
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Connected to 192.168.10.1 (192.168.10.1), port 69
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;getting from 192.168.10.1:pxeboot to pxeboot [octet]
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;Received 1074688 bytes in 0.6 seconds [14810621 bit/s]
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Awesome! Let&amp;rsquo;s make sure we downloaded everything correctly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-console" data-lang="console"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;#&lt;/span&gt; Check the software downloaded from TFTP
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;❯ sha256sum pxeboot 
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;ef4b7d62d360bd8b58a3e83dfa87f8c645d459340554ce4ad66c0ef341fc3653 pxeboot
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="err"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="gp"&gt;#&lt;/span&gt; Check our original file
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;❯ sha256sum ~/Downloads/netboot.xyz.efi
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;ef4b7d62d360bd8b58a3e83dfa87f8c645d459340554ce4ad66c0ef341fc3653 /home/major/Downloads/netboot.xyz.efi
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now your systems on your local network can PXE boot using netboot.xyz!
During the boot routine, you may need to press a key (usually F12, F11, F2, or maybe DEL) to bring up a boot selection menu.
Pick the PXE or network boot option (choose IPv4 if asked) and boot!&lt;/p&gt;
&lt;p&gt;During the boot, your machine will boot the locally downloaded PXE image and it will automatically call out to netboot.xyz for menu selections.
Scroll through the menus, choose your image, and enjoy! 🤓&lt;/p&gt;</description></item><item><title>Adventures with GRE and IPSec on Mikrotik routers</title><link>https://major.io/p/adventures-with-gre-and-ipsec-on-mikrotik-routers/</link><pubDate>Wed, 27 May 2015 13:46:28 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/adventures-with-gre-and-ipsec-on-mikrotik-routers/</guid><description>&lt;p&gt;&lt;img alt="1" loading="lazy" src="https://major.io/wp-content/uploads/2015/05/mikrotik-routerboard-rb8_6221.jpg"&gt;&lt;/p&gt;
&lt;p&gt;I recently picked up a &lt;a href="http://routerboard.com/RB850Gx2"&gt;RB850GX2&lt;/a&gt; from my favorite Mikrotik retailer, &lt;a href="https://www.roc-noc.com/mikrotik/routerboard/RB850Gx2.html"&gt;r0c-n0c&lt;/a&gt;. It&amp;rsquo;s a dual-core PowerPC board with five ethernet ports and some decent performance for the price.&lt;/p&gt;
&lt;p&gt;I still have the RB493G in a colocation and I usually connect my home and the colo via OpenVPN or IPSec. Networking is not one of my best skills and I&amp;rsquo;m always looking to learn more about it when I can. I decided to try out a GRE tunnel on top of IPSec this time around. Combining GRE and IPSec allows you to simplify connectivity between two network segments through an encrypted tunnel.&lt;/p&gt;
&lt;h2 id="the-setup"&gt;The Setup&lt;/h2&gt;
&lt;p&gt;The LAN in my colo and at home is fairly simple: a /24 of RFC1918 space behind a Mikrotik doing NAT. My goal was to get a tunnel up between both environments so that I could reach devices behind my colo firewall from home and vice versa. I do plenty of ssh back and forth along with backups from time to time.&lt;/p&gt;
&lt;p&gt;In this example, here&amp;rsquo;s the current network configuration:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Home: 192.168.50.0/24 on the LAN, 1.1.1.1 as the public IP&lt;/li&gt;
&lt;li&gt;Colo: 192.168.150.0/24 on the LAN, 2.2.2.2 as the public IP&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I want devices on 192.168.50.0/24 to talk to 192.168.150.0/24 and vice versa. Let&amp;rsquo;s get the GRE tunnel up first.&lt;/p&gt;
&lt;h2 id="gre"&gt;GRE&lt;/h2&gt;
&lt;p&gt;Plain GRE tunnels aren&amp;rsquo;t encrypted, but I prefer to set them up first to test connectivity prior to adding IPSec into the mix. IPSec can be a challenge to configure the first time around.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll first create a GRE interface at home:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/interface gre
add !keepalive local-address=1.1.1.1 name=home-to-colo remote-address=2.2.2.2
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;We&amp;rsquo;ll do the same on the colo router:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/interface gre
add !keepalive local-address=2.2.2.2 name=colo-to-home remote-address=1.1.1.1
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can check to see if the GRE tunnel is running from either router:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/interface gre print
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Look for the &lt;strong&gt;R&lt;/strong&gt; in the flags column.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;ve made it this far, you now have a GRE tunnel configured but we can&amp;rsquo;t pass any traffic across it yet. We need to add some IP&amp;rsquo;s to both sides and configure some routes.&lt;/p&gt;
&lt;h2 id="ips-and-routes"&gt;IP&amp;rsquo;s and Routes&lt;/h2&gt;
&lt;p&gt;You have some freedom here to choose the IP addresses for both ends of your tunnel but don&amp;rsquo;t choose anything that interferes with your current LAN IP addresses. In my case, I&amp;rsquo;ll choose 10.10.10.1/30 and 10.10.10.2/30 for both ends of the tunnel.&lt;/p&gt;
&lt;p&gt;I&amp;rsquo;ll give the 10.10.10.2 address to the home firewall:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip address
add address=10.10.10.2/30 interface=home-to-colo network=10.10.10.0
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And I&amp;rsquo;ll give the 10.10.10.1 address to the colo firewall:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip address
add address=10.10.10.1/30 interface=colo-to-home network=10.10.10.0
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;At this point, systems at home can ping 10.10.10.1 (the colo router&amp;rsquo;s GRE tunnel endpoint) and systems at the colo can ping 10.10.10.2 (the home router&amp;rsquo;s GRE tunnel endpoint). That&amp;rsquo;s great because we will use these IP&amp;rsquo;s to route our LAN traffic across the tunnel.&lt;/p&gt;
&lt;p&gt;We need to tell the home router how to get traffic from its LAN over to the colo LAN and vice versa. We can do that with the tunnel endpoints we just configured.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s tell the home router to use the colo router&amp;rsquo;s GRE tunnel endpoint to reach the colo LAN:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip route
add distance=1 dst-address=192.168.150.0/24 gateway=home-to-colo
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;And tell the colo router to use the home router&amp;rsquo;s GRE endpoint to reach the home LAN:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip route
add distance=1 dst-address=192.168.50.0/24 gateway=colo-to-home
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;We don&amp;rsquo;t have to tell the router about the tunnel&amp;rsquo;s IP address since those routes are generated automatically when we added the IP addresses to each side of the GRE tunnel.&lt;/p&gt;
&lt;p&gt;If you&amp;rsquo;ve made it this far, systems in your home LAN should be able to ping the colo LAN and vice versa. If not, go back and double-check your IP addresses on both sides of the tunnel and your routes.&lt;/p&gt;
&lt;h2 id="adding-ipsec"&gt;Adding IPSec&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;BEFORE YOU GO ANY FURTHER, ensure you have some sort of out-of-band access to both routers.&lt;/strong&gt; If you make a big mistake like I did (more on that later), you&amp;rsquo;re going to be glad you set up another way to reach your devices!&lt;/p&gt;
&lt;p&gt;We have an GRE tunnel without encryption already and that&amp;rsquo;s allowing us to pass traffic. That&amp;rsquo;s fine, but it&amp;rsquo;s not terribly secure to send our packets in that tunnel across a hostile internet. IPSec will allow us to tell both routers that we want packets between the public IP addresses of both routers to be encrypted. The GRE tunnel will take care of actually delivering the packets, however. IPSec isn&amp;rsquo;t an interface and it can&amp;rsquo;t be a conduit for networking all by itself.&lt;/p&gt;
&lt;p&gt;&lt;strong style="color: #D42020;"&gt;Have you configured another way to access both routers yet? Seriously, stop now and do that. I mean it.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you have native IPv6 access (not a IPv6 over IPv4 tunnel!) into each device, that can be a viable backup plan. Another option might be serial cables or a dedicated console connection. You&amp;rsquo;ll thank me later.&lt;/p&gt;
&lt;p&gt;Configuring IPSec is done in three chunks:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Make a proposal: both routers must agree on how to authenticate each other and encrypt traffic&lt;/li&gt;
&lt;li&gt;Configure a peer list: both routers need to know how to reach each other and have some shared secrets&lt;/li&gt;
&lt;li&gt;Set a policy: both routers need to agree on which packets must be encrypted&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will start with the proposal. The defaults are good for both routers. Add this configuration &lt;strong&gt;on both devices&lt;/strong&gt;:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip ipsec proposal
set [ find default=yes ] auth-algorithms=md5 enc-algorithms=aes-128-cbc,twofish
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Now our routers agree on what methods they&amp;rsquo;ll use to encrypt traffic. Feel free to adjust these algorithms later if needed. Let&amp;rsquo;s tell each router about its peer.&lt;/p&gt;
&lt;p&gt;At home:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip ipsec peer
add address=2.2.2.2/32 nat-traversal=no secret=letshavefunwithipsec
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;At the colo:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip ipsec peer
add address=1.1.1.1/32 nat-traversal=no secret=letshavefunwithipsec
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Both routers now know about each other and they both have the same shared secret (please use a better shared secret in production). All we have left is configuring a policy.&lt;/p&gt;
&lt;p&gt;At this point, ensure you&amp;rsquo;re accessing both routers via an out-of-band method (native IPv6, console, serial, etc). &lt;strong&gt;YOU ARE ABOUT TO LOSE CONNECTIVITY TO YOUR REMOTE DEVICE.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;At home, we set up a policy that says all traffic between the public addresses of both firewalls must be encrypted (GRE will carry the traffic for us). &lt;strong&gt;Ensure that the CIDR portion of the IP address for dst-address/src-address is present!&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip ipsec policy
add dst-address=2.2.2.2/32 sa-dst-address=2.2.2.2 sa-src-address=1.1.1.1 src-address=1.1.1.1/32 tunnel=yes
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;We will do something similar on the colo side. &lt;strong&gt;Again, ensure that the CIDR portion of the IP address for dst-address/src-address is present!&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip ipsec policy
add dst-address=1.1.1.1/32 sa-dst-address=1.1.1.1 sa-src-address=2.2.2.2 src-address=2.2.2.2/32 tunnel=yes
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You should now be able to ping across your GRE tunnel but it&amp;rsquo;s encrypted this time! If you find that one of your devices is inaccessible, don&amp;rsquo;t panic. Disable the policy you just added (&lt;code&gt;set disabled=yes number=[number of your policy]&lt;/code&gt;) and review your configuration.&lt;/p&gt;
&lt;p&gt;In the policy step, we told both routers that if traffic moves between the &lt;em&gt;src-address&lt;/em&gt; and &lt;em&gt;dst-address&lt;/em&gt;, we want it encrypted. Also, the &lt;em&gt;sa-src-address&lt;/em&gt; and &lt;em&gt;sa-dst-address&lt;/em&gt; gives the router a hint to figure out the identity of the peer and what their shared secret is.&lt;/p&gt;
&lt;h2 id="checking-our-work"&gt;Checking our work&lt;/h2&gt;
&lt;p&gt;You can check your work with something like this on the home router:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;[major@Home] &amp;gt; /ip ipsec remote-peers print
 0 local-address=1.1.1.1 remote-address=2.2.2.2 state=established side=initiator established=7h17m10s
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you have a line like that, your IPSec peers can communicate properly. To test the encryption, you have two options. One option is to put a device outside your firewall and dump traffic via a tap or hub.&lt;/p&gt;
&lt;p&gt;Another option (albeit less accurate) is to use the profile tool built into RouterOS. Run the following:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/tool profile
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You&amp;rsquo;ll see some output showing where the majority of your CPU is consumed. Now, transfer some large files between systems behind both routers. You can use &lt;a href="https://major.io/2010/03/20/testing-network-throughput-with-iperf/"&gt;iperf&lt;/a&gt; for this as well if you really want to stress out the network link. When you do that, you should see &lt;strong&gt;encrypting&lt;/strong&gt; in the profile output as a very large consumer of the CPU. If you only see something like &lt;strong&gt;gre&lt;/strong&gt; or &lt;strong&gt;ethernet&lt;/strong&gt; as your top CPU consumers, you may have missed something on your IPSec policy and your traffic is likely not being encrypted. This isn&amp;rsquo;t true for all routers — it depends on your normal workloads.&lt;/p&gt;
&lt;h2 id="how-i-made-a-huge-mistake"&gt;How I made a huge mistake&lt;/h2&gt;
&lt;p&gt;When I was going through this process, I made it through the GRE portion without a hitch. Everything worked well. Once I added IPSec to the mix, I used the GRE tunnel endpoints (10.10.10.1 and 10.10.10.2) as my &lt;em&gt;src-address&lt;/em&gt; and &lt;em&gt;dst-address&lt;/em&gt; in my IPSec policy. Nothing was getting encrypted and I was getting really frustrated.&lt;/p&gt;
&lt;p&gt;I kept reading tutorials on various sites and came to realize that I didn&amp;rsquo;t need an encryption policy between the tunnel endpoints, I needed a policy between the actual public addresses of the routers. I wasn&amp;rsquo;t aware that the GRE tunnel would happily keep working between the two public IP addresses even with the IPSec policy in place between the IP addresses.&lt;/p&gt;
&lt;p&gt;First mistake: I didn&amp;rsquo;t access my colo router via an out-of-band path. Second mistake: I applied my IPSec policy on the home router first and was shocked that I lost connectivity to the colo router. That was a quick fix — I just disabled the IPSec policy on the home router and I could access the colo router again.&lt;/p&gt;
&lt;p&gt;Just after adjusting the IPSec policy on the colo router to use the public IP addresses, I noticed that connectivity dropped. At this point, I expected that — I set up a policy there but I hadn&amp;rsquo;t done it on the home router yet. I enabled the policy on the home router and then started pinging. Nothing.&lt;/p&gt;
&lt;p&gt;Then came the Pingdom and UptimeRobot alerts for my sites in the colo. &lt;strong&gt;Oh crap.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="5" loading="lazy" src="https://major.io/wp-content/uploads/2015/05/ive-made-a-huge-mistake.gif"&gt;&lt;/p&gt;
&lt;p&gt;Once I was able to reach the colo router via IPv6 through some other VM&amp;rsquo;s, I realized what happened. I left the CIDR mask off the &lt;em&gt;src-address&lt;/em&gt; and &lt;em&gt;dst-address&lt;/em&gt; in the IPSec policy.&lt;/p&gt;
&lt;p&gt;Guess what RouterOS chose as a CIDR mask for me? &lt;strong&gt;/0.&lt;/strong&gt; Ouch.&lt;/p&gt;
&lt;p&gt;I quickly adjusted those to be /32&amp;rsquo;s. Within seconds, everything was up again and the GRE tunnel began working. As the Pingdom alerts cleared and my heart rate returned to normal, I figured the best thing I should do is share my story so that others don&amp;rsquo;t make the same mistake. ;)&lt;/p&gt;</description></item><item><title>HOWTO: Mikrotik OpenVPN server</title><link>https://major.io/p/howto-mikrotik-openvpn-server/</link><pubDate>Fri, 01 May 2015 15:33:35 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/howto-mikrotik-openvpn-server/</guid><description>&lt;p&gt;&lt;a href="https://major.io/wp-content/uploads/2015/05/rb850_picture.jpg"&gt;&lt;img src="https://major.io/wp-content/uploads/2015/05/rb850_picture-300x300.jpg" alt="RB850Gx2 mikrotik" width="300" height="300" class="alignright size-medium wp-image-5543" srcset="https://major.io/wp-content/uploads/2015/05/rb850_picture-300x300.jpg 300w, https://major.io/wp-content/uploads/2015/05/rb850_picture-150x150.jpg 150w, https://major.io/wp-content/uploads/2015/05/rb850_picture.jpg 800w" sizes="(max-width: 300px) 100vw, 300px" /&gt;&lt;/a&gt;Mikrotik firewalls have been good to me over the years and they work well for multiple purposes. Creating an OpenVPN server on the device can allow you to connect into your local network when you&amp;rsquo;re on the road or protect your traffic when you&amp;rsquo;re using untrusted networks.&lt;/p&gt;
&lt;p&gt;Although Miktrotik&amp;rsquo;s implementation isn&amp;rsquo;t terribly robust (TCP only, client cert auth is wonky), it works quite well for most users. I&amp;rsquo;ll walk you through the process from importing certificates through testing it out with a client.&lt;/p&gt;
&lt;h3 id="import-certificates"&gt;Import certificates&lt;/h3&gt;
&lt;p&gt;Creating a CA and signing a certificate and key is outside the scope of this post and there are plenty of sites that cover the basics of creating a &lt;a href="https://major.io/2007/08/02/generate-self-signed-certificate-and-key-in-one-line/"&gt;self-signed certificate&lt;/a&gt;. You could also create a certificate signing request (CSR) on the Mikrotik and have that signed by a trusted CA. In my case, I have a simple CA already and I signed a certificate for myself.&lt;/p&gt;
&lt;p&gt;Upload your certificate, key, and CA certificate (if applicable) to the Mikrotik. After that, import those files into the Mikrotik&amp;rsquo;s certificate storage:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt; import file-name=firewall.example.com.crt
passphrase:
 certificates-imported: 1
 private-keys-imported: 0
 files-imported: 1
 decryption-failures: 0
 keys-with-no-certificate: 0

[major@home] /certificate&amp;gt; import file-name=firewall.example.com.pem
passphrase:
 certificates-imported: 0
 private-keys-imported: 1
 files-imported: 1
 decryption-failures: 0
 keys-with-no-certificate: 0

[major@home] /certificate&amp;gt; import file-name=My_Personal_CA.crt
passphrase:
 certificates-imported: 1
 private-keys-imported: 0
 files-imported: 1
 decryption-failures: 0
 keys-with-no-certificate: 0
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Always import the certificate first, then the key.&lt;/strong&gt; You should be able to do a &lt;code&gt;/certificate print&lt;/code&gt; and see the entries for the files you imported. In the print output, look at the flags column and verify that the line with your certificate has a &lt;strong&gt;T&lt;/strong&gt; and a &lt;strong&gt;K&lt;/strong&gt;. If the K is missing, import the key one more time. If that still doesn&amp;rsquo;t work, ensure that your certificate and key match.&lt;/p&gt;
&lt;p&gt;The default naming conventions used for certificates is a little confusing. You can rename a certificate by running &lt;code&gt;set name=firewall.example.com number=0&lt;/code&gt; (run a &lt;code&gt;/certificate print&lt;/code&gt; to get the right number).&lt;/p&gt;
&lt;h3 id="openvpn-server-configuration"&gt;OpenVPN server configuration&lt;/h3&gt;
&lt;p&gt;We&amp;rsquo;re now ready to do the first steps of the OpenVPN setup on the Mikrotik. You can do this configuration via the Winbox GUI or via the web interface, but I prefer to use the command line. Let&amp;rsquo;s start:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/interface ovpn-server server
set certificate=firewall.example.com cipher=blowfish128,aes128,aes192,aes256 default-profile=default-encryption enabled=yes
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This tells the device that we want to use the certificate we imported earlier along with all of the available ciphers. We&amp;rsquo;re also selecting the &lt;strong&gt;default-encryption&lt;/strong&gt; profile that we will configure in more detail later. Feel free to adjust your cipher list later on but I recommend allowing all of them until you&amp;rsquo;re sure that the VPN configuration works.&lt;/p&gt;
&lt;p&gt;We&amp;rsquo;re now ready to add an OpenVPN interface. In Mikrotik terms, you can have multiple OpenVPN server profiles running under the same server. They will all share the same certificate, but each may have different authentication methods or network configurations. Let&amp;rsquo;s define our first profile:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/interface ovpn-server
add name=openvpn-inbound user=openvpn
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;There&amp;rsquo;s now a profile with a username of &lt;strong&gt;openvpn&lt;/strong&gt;. That will be the username that we use to connect to this VPN server.&lt;/p&gt;
&lt;h3 id="secrets"&gt;Secrets&lt;/h3&gt;
&lt;p&gt;The router needs a way to identify the user we just created. We can define a secret easily:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ppp secret
add name=openvpn password=vpnsarefun profile=default-encryption
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;We&amp;rsquo;ve set a password secret and defined a connection profile that corresponds to the secret.&lt;/p&gt;
&lt;h3 id="profiles"&gt;Profiles&lt;/h3&gt;
&lt;p&gt;We&amp;rsquo;ve been referring to this &lt;strong&gt;default-encryption&lt;/strong&gt; profile several times and now it&amp;rsquo;s time to configure it. This is one of the things I prefer to configure using the Winbox GUI or the web interface since there are plenty of options to review.&lt;/p&gt;
&lt;p&gt;The most important part is how you connect the VPN connection into your internal network. You have a few options here. You can configure an IP address that will always be assigned to this connection no matter what. There are upsides and downsides with that choice. You&amp;rsquo;ll always get the same IP on the inside network but you won&amp;rsquo;t be able to connect to the same profile with multiple clients.&lt;/p&gt;
&lt;p&gt;I prefer to set the bridge option to my internal network bridge (which I call &lt;strong&gt;lanbridge&lt;/strong&gt;). That allows me to use my existing bridge configuration and filtering rules on my OpenVPN tunnels. My configuration looks something like this:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ppp profile
set 1 bridge=lanbridge local-address=default-dhcp only-one=no remote-address=default-dhcp
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I&amp;rsquo;ve told the router that I want VPN connections to be hooked up to my main bridge and it should get local and remote IP addresses from my default DHCP server. In addition, I&amp;rsquo;ve also allowed more than one simultaneous connection to this profile.&lt;/p&gt;
&lt;p&gt;The other defaults are fairly decent to get started. You can go back and adjust them later if needed.&lt;/p&gt;
&lt;h3 id="openvpn-client"&gt;OpenVPN client&lt;/h3&gt;
&lt;p&gt;Every client has things configured a bit differently but I&amp;rsquo;ll be working with a basic OpenVPN configuration file here that should work on most systems (or at least show you what to click in your client GUI).&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s my OpenVPN client configuration file:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;remote firewall.example.com 1194 tcp-client
persist-key
auth-user-pass /etc/openvpn/firewall-creds.txt
tls-client
pull
ca /home/major/.cert/ca.crt
redirect-gateway def1
dev tun
persist-tun
cert /home/major/.cert/cert.crt
nobind
key /home/major/.cert/key.key
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;In my configuration, I refer to a &lt;strong&gt;/etc/openvpn/firewall-creds.txt&lt;/strong&gt; file to hold my credentials. You can store the file anywhere (or this might be configurable in a GUI) but it should look like this:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;username
password
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;That&amp;rsquo;s it - just a two line file with the username, a line feed, and a password.&lt;/p&gt;
&lt;p&gt;At this point, you should be able to test your client.&lt;/p&gt;
&lt;h3 id="troubleshooting"&gt;Troubleshooting&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Firewall&lt;/strong&gt; - Ensure that you have a firewall rule set to allow traffic into your OpenVPN port. This could be something as simple as:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ip firewall filter add chain=input dst-port=1194 protocol=tcp
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Certificates&lt;/strong&gt; - Check that your certificate and key were imported properly and that your client is configured to trust the self-signed certificate or the CA you used.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Compression&lt;/strong&gt; - For some reason, I have lots of problems if compression is enabled on the client. They range from connection failures to being unable to pass traffic through the tunnel after getting connected. Be sure that anything that mentions compression or LZO is disabled.&lt;/p&gt;
&lt;h3 id="security"&gt;Security&lt;/h3&gt;
&lt;p&gt;There are some security improvements that can be made after configuring everything:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Limit access to your OpenVPN port in your firewall to certain source IP&amp;rsquo;s&lt;/li&gt;
&lt;li&gt;Configure better passwords for your OpenVPN secret&lt;/li&gt;
&lt;li&gt;Consider making a separate bridge or network segment for VPN users when they connect and apply filters to it&lt;/li&gt;
&lt;li&gt;Adjust the list of ciphers in the default-encryption profile so that only the strongest can be used (may cause some clients to be unable to connect)&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>HOWTO: Time Warner Cable and IPv6</title><link>https://major.io/p/howto-time-warner-cable-ipv6/</link><pubDate>Thu, 11 Sep 2014 14:43:03 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/howto-time-warner-cable-ipv6/</guid><description>&lt;p&gt;&lt;a href="https://major.io/wp-content/uploads/2014/09/logo-top.png"&gt;&lt;img src="https://major.io/wp-content/uploads/2014/09/logo-top-251x300.png" alt="IPv6 world launch logo" width="251" height="300" class="alignright size-medium wp-image-5211" srcset="https://major.io/wp-content/uploads/2014/09/logo-top-251x300.png 251w, https://major.io/wp-content/uploads/2014/09/logo-top.png 324w" sizes="(max-width: 251px) 100vw, 251px" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Time Warner has &lt;a href="http://www.twcableuntangled.com/2014/03/what-is-ipv6-twc-upgrades-the-internet/"&gt;gradually rolled&lt;/a&gt; out &lt;a href="https://en.wikipedia.org/wiki/IPv6"&gt;IPv6 connectivity&lt;/a&gt; to their Road Runner customers over the past couple of years and it started appearing on my home network earlier this year.  I had some issues getting the leases to renew properly after they expired (TWC&amp;rsquo;s default lease length appears to be seven days) and there were some routing problems that cropped up occasionally.  However, over the past month, things seem to have settled down on TWC&amp;rsquo;s San Antonio network.&lt;/p&gt;
&lt;h3 id="do-you-have-ipv6-yet"&gt;Do you have IPv6 yet?&lt;/h3&gt;
&lt;p&gt;Before you make any adjustments to your network, I&amp;rsquo;d recommend connecting your computer directly to the cable modem briefly to see if you can get an IPv6 address via &lt;a href="https://en.wikipedia.org/wiki/IPv6#Stateless_address_autoconfiguration_.28SLAAC.29"&gt;stateless autoconfiguration&lt;/a&gt; (SLAAC).  You&amp;rsquo;ll only get one IPv6 address via SLAAC, but we can get a bigger network block later on (keep reading).  Check your computer&amp;rsquo;s network status to see if you received an IPv6 address.  If you have one, try accessing &lt;a href="http://ipv6.google.com/"&gt;ipv6.google.com&lt;/a&gt;.  You can always check &lt;a href="http://ipv6.icanhazip.com"&gt;ipv6.icanhazip.com&lt;/a&gt; or &lt;a href="http://ipv6.icanhaztraceroute.com"&gt;ipv6.icanhaztraceroute.com&lt;/a&gt; as well.&lt;/p&gt;
&lt;p&gt;There&amp;rsquo;s a chance your computer didn&amp;rsquo;t get an IPv6 address while directly connected to the cable modem.  Here are some possible solutions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Power off the cable modem for 30 seconds, then plug it back in and see if your computer gets an address&lt;/li&gt;
&lt;li&gt;Ensure you have one of TWC&amp;rsquo;s &lt;a href="http://www.timewarnercable.com/en/support/internet/topics/buy-your-modem.html"&gt;approved modems&lt;/a&gt;. &lt;em&gt;(Bear in mind that not all of these modems support IPv6.)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Verify that your computer has IPv6 enabled. &lt;em&gt;(Instructions for &lt;a href="http://windows.microsoft.com/en-us/windows/ipv6-faq"&gt;Windows&lt;/a&gt;, &lt;a href="http://support.apple.com/kb/HT4667"&gt;Mac&lt;/a&gt; and &lt;a href="http://www.linux.com/learn/tutorials/428331-ipv6-crash-course-for-linux"&gt;Linux&lt;/a&gt; are available.)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="but-i-want-more-addresses"&gt;But I want more addresses&lt;/h3&gt;
&lt;p&gt;If you were able to get an IPv6 address, it&amp;rsquo;s now time to allocate a network block for yourself and begin using it!  We will request an allocation via &lt;a href="https://en.wikipedia.org/wiki/DHCPv6"&gt;DHCPv6&lt;/a&gt;.  Every router is a little different, but the overall concept is the same.  Your router will request an allocation on the network and receive that allocation from Time Warner&amp;rsquo;s network.  From there, your router will assign that block to an interface (most likely your LAN, more on that in a moment) and begin handing our IPv6 addresses to devices in your home.&lt;/p&gt;
&lt;p&gt;By default, TWC hands out &lt;a href="https://en.wikipedia.org/wiki/IPv6_subnetting_reference"&gt;/64 allocations&lt;/a&gt; regardless of what you request via DHCPv6.  &lt;del datetime="2015-03-03T20:49:50+00:00"&gt;I had some success in late 2013 when I requested a /56 but it appears that allocations of that size aren&amp;rsquo;t available any longer.  Sure, a /64 allocation is gigantic (bigger than the entire IPv4 address space), but getting a /56 would allow you to assign multiple /64 allocations to different interfaces.&lt;/del&gt; &lt;strong&gt;See the last section of this post on how to get a /56 allocation.&lt;/strong&gt;  Splitting /64&amp;rsquo;s into smaller subnets is a bad idea.&lt;/p&gt;
&lt;h3 id="lets-talk-security"&gt;Let&amp;rsquo;s talk security&lt;/h3&gt;
&lt;p&gt;IPv6 eliminates the need for &lt;a href="https://en.wikipedia.org/wiki/Network_address_translation"&gt;network address translation&lt;/a&gt; (NAT).  This means that by the time you finish this howto, each device in your network with have a publicly accessible internet address.  Also, bear in mind that with almost all network devices, firewall rules and ACL&amp;rsquo;s that are configured with IPv4 will have no effect on IPv6.  This means that you&amp;rsquo;ll end up with devices on your network with all of their ports exposed to the internet.&lt;/p&gt;
&lt;p&gt;In Linux, be sure to use &lt;a href="http://ipset.netfilter.org/ip6tables.man.html"&gt;ip6tables&lt;/a&gt; (via &lt;a href="https://fedoraproject.org/wiki/FirewallD"&gt;firewalld&lt;/a&gt;, if applicable).  For other network devices, review their firewall configuration settings to see how you can filter IPv6 traffic.  &lt;strong&gt;This is a critical step.  Please don&amp;rsquo;t skip it.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;On my Mikrotik device, I have a separate IPv6 firewall interface that I can configure.  Here is my default ruleset:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ipv6 firewall filter
/ipv6 firewall filter
add chain=input connection-state=related
add chain=input connection-state=established
add chain=forward connection-state=established
add chain=input in-interface=lanbridge
add chain=forward connection-state=related
add chain=input dst-port=546 protocol=udp
add chain=input protocol=icmpv6
add chain=forward protocol=icmpv6
add chain=forward out-interface=ether1-gateway
add action=drop chain=input
add action=drop chain=forward
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The first five rules ensure that only related or established connections can make it to my internal LAN. I allow UDP 546 for DHCPv6 connectivity and I&amp;rsquo;m allowing all ICMPv6 traffic to the router and internal devices. Finally, I allow all of my devices inside the network to talk to the internet and block the remainder of the unmatched traffic.&lt;/p&gt;
&lt;h3 id="configuring-the-router"&gt;Configuring the router&lt;/h3&gt;
&lt;p&gt;It&amp;rsquo;s no secret that I&amp;rsquo;m a big fan of &lt;a href="https://www.roc-noc.com/Mikrotik-Desktop-Routers/"&gt;Mikrotik&lt;/a&gt; devices and I&amp;rsquo;ll guide you through the setup of IPv6 on the Mikrotik in this post.  &lt;strong&gt;Before starting this step, ensure that your firewall is configured (see previous section).&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;On the Mikrotik, just add a simple DHCPv6 configuration. I&amp;rsquo;ll call mine &amp;rsquo;twc':&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ipv6 dhcp-client
add add-default-route=yes interface=ether1-gateway pool-name=twc
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;After that, you should see an allocation pop up within a few seconds (run &lt;code&gt;ipv6 dhcp-client print&lt;/code&gt;):&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# INTERFACE STATUS PREFIX EXPIRES-AFTER
0 ether1-gat... bound 2605:xxxx:xxxx:xxxx::/64 6d9h15m45s
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Check that a new address pool was allocated by running &lt;code&gt;ipv6 pool print&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;# NAME PREFIX PREFIX-LENGTH EXPIRES-AFTER
0 D twc 2605:xxxx:xxxx:xxxx::/64 64 6d9h13m33s
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;You can now assign that address pool to an interface. Be sure to assign the block to your LAN interface. In my case, that&amp;rsquo;s called &lt;em&gt;lanbridge&lt;/em&gt;:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ipv6 address
add address=2605:xxxx:xxxx:xxxx:: from-pool=twc interface=lanbridge
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;By default, the Mikrotik device will now begin announcing that network allocation on your internal network. Some of your devices may already be picking up IPv6 addresses via SLAAC! Try accessing the Google or icanhazip IPv6 addresses from earlier in the post.&lt;/p&gt;
&lt;p&gt;Checking a Linux machine for IPv6 connectivity is easy. Here&amp;rsquo;s an example from a Fedora 20 server I have at home:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ ip -6 addr
2: em1: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu 1500 qlen 1000
 inet6 2605:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/64 scope global mngtmpaddr dynamic
 valid_lft 2591998sec preferred_lft 604798sec
 inet6 2605:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx/64 scope global deprecated mngtmpaddr dynamic
 valid_lft 1871064sec preferred_lft 0sec
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If you only see an address that starts with &lt;em&gt;fe80&lt;/em&gt;, that&amp;rsquo;s your &lt;a href="https://en.wikipedia.org/wiki/Link-local_address"&gt;link local&lt;/a&gt; address. It&amp;rsquo;s not an address that can be accessed from the internet.&lt;/p&gt;
&lt;h3 id="troubleshooting"&gt;Troubleshooting&lt;/h3&gt;
&lt;p&gt;If you run into some problems or your router can&amp;rsquo;t pull an allocation via DHCPv6, try the troubleshooting steps from the first section of this post.&lt;/p&gt;
&lt;p&gt;Getting assistance from Time Warner is a real challenge. Everyone I&amp;rsquo;ve contacted via phone or Twitter has not been able to help and many of them don&amp;rsquo;t even know what IPv6 is. I was even told &amp;ldquo;we have plenty of regular IPv4 addresses left, don&amp;rsquo;t worry&amp;rdquo; when I asked for help. Even my unusual methods haven&amp;rsquo;t worked:&lt;/p&gt;
&lt;blockquote class="twitter-tweet tw-align-center" width="500"&gt;
 &lt;p&gt;
 &lt;a href="https://twitter.com/TWC_Help"&gt;@TWC_Help&lt;/a&gt; I'll buy one of your engineers a six pack of beer if they can enable IPv6 for my internet connection. ;)
 &lt;/p&gt;
 &lt;p&gt;
 &amp;mdash; Major Hayden (@majorhayden) &lt;a href="https://twitter.com/majorhayden/status/498189483825983488"&gt;August 9, 2014&lt;/a&gt;
 &lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;My old &lt;a href="http://www.timewarnercable.com/en/residential-home/support/faqs/faqs-equipment-and-instruction-manuals/modems/motorola/motorola-surfboard-sbg6580.html"&gt;SBG6580&lt;/a&gt; that was issued by Time Warner wouldn&amp;rsquo;t ever do IPv6 reliably. I ended up buying a &lt;a href="http://www.newegg.com/Product/Product.aspx?Item=N82E16825122015"&gt;SB6121&lt;/a&gt; and I was able to get IPv6 connectivity fairly easily. The SB6121 only does 172mb/sec down - I&amp;rsquo;ll be upgrading it if TWC MAXX shows up in San Antonio.&lt;/p&gt;
&lt;h3 id="get-a-56"&gt;Get a /56&lt;/h3&gt;
&lt;p&gt;You can get a /56 block of IP addresses from Time Warner by adding &lt;code&gt;prefix-hint=::/56&lt;/code&gt; onto your IPv6 dhcp client configuration. You&amp;rsquo;ll need to carve out some /64 subnets on your own for your internal network and that&amp;rsquo;s outside the scope of this post. The prefix hint configuration isn&amp;rsquo;t available in the graphical interface or on the web (at the time of this post&amp;rsquo;s writing).&lt;/p&gt;</description></item><item><title>Native IPv6 connectivity in Mikrotik’s RouterOS</title><link>https://major.io/p/native-ipv6-connectivity-in-mikrotiks-routeros/</link><pubDate>Wed, 11 Jan 2012 13:30:07 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/native-ipv6-connectivity-in-mikrotiks-routeros/</guid><description>&lt;p&gt;It&amp;rsquo;s no secret that I&amp;rsquo;m a big fan of the &lt;a href="http://routerboard.com/"&gt;Routerboard&lt;/a&gt; devices and the &lt;a href="http://www.mikrotik.com/software.html"&gt;RouterOS software from Mikrotik&lt;/a&gt; that runs on them. The hardware is solid, the software is stable and feature-rich, and I found a &lt;a href="http://www.roc-noc.com/"&gt;great vendor&lt;/a&gt; that ships quickly.&lt;/p&gt;
&lt;p&gt;I recently added a &lt;a href="http://routerboard.com/RB493G"&gt;RB493G&lt;/a&gt; (&lt;a href="http://www.roc-noc.com/mikrotik/routerboard/rb493g-complete.html"&gt;~ $230 USD&lt;/a&gt;) to sit in front of a pair of colocated servers. The majority of the setup routine was the same as with my previous devices except for the IPv6 configuration.&lt;/p&gt;
&lt;p&gt;In the past, I&amp;rsquo;ve set up IPv6 tunnels with &lt;a href="http://ipv6.he.net/"&gt;Hurricane Electric&lt;/a&gt; and it&amp;rsquo;s been mostly a cut-and-paste operation from the sample configuration in their IPv6 tunnel portal. Setting up native IPv6 involved a little more legwork.&lt;/p&gt;
&lt;p&gt;If your provider will give you two /64&amp;rsquo;s or an entire /48, getting IPv6 connectivity for your WAN/LAN interfaces is simple. However, if you can only get one /64, you&amp;rsquo;ll have to see if your provider can route it to you via your Mikrotik&amp;rsquo;s &lt;a href="http://en.wikipedia.org/wiki/Link-local_address#IPv6"&gt;link local&lt;/a&gt; interface (I wouldn&amp;rsquo;t recommend this for many reasons).&lt;/p&gt;
&lt;p&gt;I split my Mikrotik into two interfaces: wan and lanbridge. The lanbridge bridge joins all of the LAN ethernet ports (ether2-9 on the RB493G) and the wan interface connects to the upstream switch.&lt;/p&gt;
&lt;p&gt;My configuration:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ipv6 address
add address=2001:DB8:0:1::2/64 advertise=yes disabled=no eui-64=no interface=wan
add address=2001:DB8:0:2::1/64 advertise=yes disabled=no eui-64=no interface=lanbridge
/ipv6 route
add disabled=no distance=1 dst-address=::/0 gateway=2001:DB8:0:1::1 scope=30 \
 target-scope=10
/ipv6 nd
add advertise-dns=no advertise-mac-address=yes disabled=no hop-limit=64 \
 interface=all managed-address-configuration=no mtu=unspecified \
 other-configuration=no ra-delay=3s ra-interval=3m20s-10m ra-lifetime=30m \
 reachable-time=unspecified retransmit-interval=unspecified
/ipv6 nd prefix default
set autonomous=yes preferred-lifetime=1w valid-lifetime=4w2d
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Explanation:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ipv6 address
add address=2001:DB8:0:1::2/64 advertise=yes disabled=no eui-64=no interface=wan
add address=2001:DB8:0:2::1/64 advertise=yes disabled=no eui-64=no interface=lanbridge
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;These two lines configure the IPv6 addresses for the firewall&amp;rsquo;s interfaces. My provider&amp;rsquo;s router holds the 2001:DB8:0:1::1/64 address and routes the remainder of that /64 to me via 2001:DB8:0:1::2/64. The second /64 is on the lanbridge interface and my LAN devices take their IP addresses from that block. My provider routes that second /64 to me via the 2001:DB8:0:1::2/64 IP on my wan interface.&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ipv6 route
add disabled=no distance=1 dst-address=::/0 gateway=2001:DB8:0:1::1 scope=30 \
 target-scope=10
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;I&amp;rsquo;ve set a &lt;a href="http://tldp.org/HOWTO/html_single/Linux+IPv6-HOWTO/#AEN1083"&gt;gateway&lt;/a&gt; for IPv6 traffic so that the Mikrotik knows where to send internet-bound IPv6 traffic (in this case, to my ISP&amp;rsquo;s core router).&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;/ipv6 nd
add advertise-dns=no advertise-mac-address=yes disabled=no hop-limit=64 \
 interface=lanbridge managed-address-configuration=no mtu=unspecified \
 other-configuration=no ra-delay=3s ra-interval=3m20s-10m ra-lifetime=30m \
 reachable-time=unspecified retransmit-interval=unspecified
/ipv6 nd prefix default
set autonomous=yes preferred-lifetime=1w valid-lifetime=4w2d
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;These last two lines configure the &lt;a href="http://en.wikipedia.org/wiki/Neighbor_Discovery_Protocol"&gt;neighbor discovery&lt;/a&gt; on my lanbridge interface. This allows my LAN devices to do &lt;a href="http://en.wikipedia.org/wiki/IPv6#Stateless_address_autoconfiguration_.28SLAAC.29"&gt;stateless autoconfiguration&lt;/a&gt; (which gives them an IPv6 address as well as the gateway).&lt;/p&gt;
&lt;p&gt;Want to read up on IPv6?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://tldp.org/HOWTO/html_single/Linux+IPv6-HOWTO/"&gt;Linux IPv6 HOWTO&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://en.wikipedia.org/wiki/IPv6"&gt;IPv6 on Wikipedia&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.roesen.org/files/ipv6_cheat_sheet.pdf"&gt;IPv6 Cheat Sheet&lt;/a&gt; [PDF]&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.ripe.net/lir-services/resource-management/number-resources/ipv6/ipv6-subnetting-card"&gt;IPv6 Subnetting Card&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Measure traffic flows with Mikrotik’s RouterOS and ntop on Fedora 15</title><link>https://major.io/p/measure-traffic-flows-with-mikrotiks-routeros-and-ntop-on-fedora-15/</link><pubDate>Sun, 05 Jun 2011 14:58:26 +0000</pubDate><author>major@mhtx.net (Major Hayden)</author><guid>https://major.io/p/measure-traffic-flows-with-mikrotiks-routeros-and-ntop-on-fedora-15/</guid><description>&lt;p&gt;It&amp;rsquo;s no secret that I&amp;rsquo;m a big fan of the &lt;a href="http://www.routerboard.com/"&gt;RouterBoard&lt;/a&gt; network devices paired with &lt;a href="http://www.mikrotik.com/software.html"&gt;Mikrotik&amp;rsquo;s RouterOS&lt;/a&gt;. I discovered today that these devices offer Cisco NetFlow-compatible statistics gathering which can be directed to a Linux box running &lt;a href="http://www.ntop.org/"&gt;ntop&lt;/a&gt;. Mikrotik calls it “traffic flow” and it&amp;rsquo;s much more efficient than setting up a mirrored or spanned port and then using ntop to dump traffic on that interface.&lt;/p&gt;
&lt;p&gt;These instructions are for Fedora 15, but they should be pretty similar on most other Linux distributions. Install ntop first:&lt;/p&gt;
&lt;pre lang="html"&gt;yum -y install ntop&lt;/pre&gt;
&lt;p&gt;Adjust &lt;code&gt;/etc/ntop.conf&lt;/code&gt; so that ntop listens on something other than localhost:&lt;/p&gt;
&lt;pre lang="html"&gt;# limit ntop to listening on a specific interface and port
--http-server 0.0.0.0:3000 --https-server 0.0.0.0:3001
&lt;/pre&gt;
&lt;p&gt;I had to comment out the &lt;code&gt;sched_yield()&lt;/code&gt; option to get ntop to start:&lt;/p&gt;
&lt;pre lang="html"&gt;# Under certain circumstances, the sched_yield() function causes the ntop web
# server to lock up. It shouldn't happen, but it does. This option causes
# ntop to skip those calls, at a tiny performance penalty.
# --disable-schedyield
&lt;/pre&gt;
&lt;p&gt;Set an admin password for ntop:&lt;/p&gt;
&lt;pre lang="html"&gt;ntop --set-admin-password&lt;/pre&gt;
&lt;p&gt;Once you set the password, you may need to press CTRL-C to get back to a prompt in some ntop versions.&lt;/p&gt;
&lt;p&gt;Start ntop:&lt;/p&gt;
&lt;pre lang="html"&gt;/etc/init.d/ntop start&lt;/pre&gt;
&lt;p&gt;Open a web browser and open &lt;a href="http://example.com:3000"&gt;http://example.com:3000&lt;/a&gt; to access the ntop interface. Roll your mouse over the &lt;strong&gt;Plugins&lt;/strong&gt; menu, then &lt;strong&gt;NetFlow&lt;/strong&gt;, and then click &lt;strong&gt;Activate&lt;/strong&gt;. Roll your mouse over the &lt;strong&gt;Plugins&lt;/strong&gt; menu again, then &lt;strong&gt;NetFlow&lt;/strong&gt;, and then click &lt;strong&gt;Configure&lt;/strong&gt;. Click &lt;strong&gt;Add NetFlow Device&lt;/strong&gt; and fill in the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Type “Mikrotik” in the &lt;strong&gt;NetFlow Device&lt;/strong&gt; section and click &lt;strong&gt;Set Interface Name&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Type 2055 in the &lt;strong&gt;Local Collector UDP Port&lt;/strong&gt; section and click &lt;strong&gt;Set Port&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Type in your router&amp;rsquo;s IP/netmask in the &lt;strong&gt;Virtual NetFlow Interface Network Address&lt;/strong&gt; section and click &lt;strong&gt;Set Interface Address&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Enabling traffic flow on the Mikrotik can be done with just two configuration lines:&lt;/p&gt;
&lt;pre lang="html"&gt;/ip traffic-flow
set enabled=yes interfaces=all
/ip traffic-flow target
add address=192.168.10.65:2055 disabled=no version=5&lt;/pre&gt;
&lt;p&gt;Wait about a minute and then try reviewing some of the data in the ntop interface. Depending on the amount of traffic on your network, you might see data in as little as 10-15 seconds.&lt;/p&gt;</description></item></channel></rss>