{"id":395,"date":"2014-07-11T19:22:30","date_gmt":"2014-07-12T03:22:30","guid":{"rendered":"http:\/\/jacksontech.net\/?p=395"},"modified":"2014-10-31T13:44:20","modified_gmt":"2014-10-31T21:44:20","slug":"fun-with-routers-part-1-routerboard-411","status":"publish","type":"post","link":"https:\/\/jacksontech.net\/index.php\/2014\/07\/fun-with-routers-part-1-routerboard-411\/","title":{"rendered":"Fun with routers, part 1: MicroTik Routerboard 411 + OpenWRT"},"content":{"rendered":"<p>My father uses a WISP for his Internet access. His equipment malfunctioned recently and a technician came out to examine the antenna. He discovered that the circuitry inside it had failed; instead of throwing it away, he offered it to me.<\/p>\n<p>Meet the MicroTik Routerboard 411.<\/p>\n<p><!--more--><\/p>\n<div id=\"attachment_397\" class=\"wp-caption aligncenter\" style=\"width: 1024px\"><a href=\"http:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard1.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-397\" src=\"http:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard1.jpg\" alt=\"Routerboard 411\" width=\"1024\" height=\"804\" srcset=\"https:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard1.jpg 1024w, https:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard1-300x235.jpg 300w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><p class=\"wp-caption-text\">Routerboard 411 &#8211; with professional antenna attachment!<\/p><\/div>\n<p>The specs:<\/p>\n<ul>\n<li>300MHZ AR7130 CPU<\/li>\n<li>32MB RAM<\/li>\n<li>4MB NAND Flash<\/li>\n<li>AR5413 802.11a\/b\/g MiniPCI wireless radio<\/li>\n<li>Serial port<\/li>\n<li>1 Fast Ethernet port (supports PoE over non-data pairs, 10-28V)<\/li>\n<li>MicroTek RouterOS<\/li>\n<li>Professional low-gain adjustable wifi antenna (Oh, no, wait&#8211;that&#8217;s aftermarket!)*<\/li>\n<\/ul>\n<p>The cause of the board&#8217;s failure is evident in the photos; four of the five capacitors on the board have vented. As a result, the board has trouble booting up with some power supplies and is very picky about voltages. However, I found one power brick that provides just the right voltage for it to boot up without errors. (I&#8217;m waiting on replacement capacitors to solder in.)<\/p>\n<p>Once I got the router to boot, I tried logging in to the admin panel. However, the default RouterOS username\/password combo didn&#8217;t work, and I&#8217;m not a huge fan of RouterOS anyhow, so I decided to put OpenWRT on the device for a test run. OpenWRT is a Linux-based router firmware distribution. <a href=\"http:\/\/wiki.openwrt.org\/toh\/mikrotik\/rb411\" target=\"_blank\">The Routerboard is one of the many devices supported by OpenWRT.<\/a><\/p>\n<p>I began by gaining access to the router&#8217;s bootloader, which behaves much like the BIOS in a computer. The bootloader is stored in a section of the router&#8217;s flash memory and is the first code that runs when the router is powered on. Most routers offer access to the bootloader via a serial cable, although very few have an actual serial port like the Routerboard&#8211;the other router I&#8217;m working on at the moment has a 4-pin serial header on the circuit board. More on that in another post. Since this router has a serial port, all I needed was a cable and a null-modem adapter, which swaps the transmit and receive lines.<\/p>\n<p>My serial cable is a cheap USB-&gt;Serial adapter. When plugged in, Linux produces the device <strong>\/dev\/ttyUSB0<\/strong>. To talk to the router, I used GNU Screen, which is secretly a serial console. The command is as follows:<\/p>\n<pre>screen \/dev\/ttyUSB0 115200<\/pre>\n<p>115200 is the router&#8217;s baud rate. This is specific to certain manufacturers, although 115200 and 9600 are common. Firing it up and then plugging in the router, this appears:<\/p>\n<div id=\"attachment_405\" class=\"wp-caption aligncenter\" style=\"width: 659px\"><a href=\"http:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-405\" src=\"http:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard1.png\" alt=\"Bootloader\" width=\"659\" height=\"463\" srcset=\"https:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard1.png 659w, https:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard1-300x210.png 300w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/a><p class=\"wp-caption-text\">Bootloader<\/p><\/div>\n<p>Pressing a key brings up a menu with various settings:<\/p>\n<div id=\"attachment_404\" class=\"wp-caption aligncenter\" style=\"width: 659px\"><a href=\"http:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-404\" src=\"http:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard2.png\" alt=\"Settings menu\" width=\"659\" height=\"463\" srcset=\"https:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard2.png 659w, https:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard2-300x210.png 300w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/a><p class=\"wp-caption-text\">Settings menu<\/p><\/div>\n<p>&#8230;from here, I chose Ethernet as a boot device:<\/p>\n<p><a href=\"http:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-403\" src=\"http:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard3.png\" alt=\"routerboard3\" width=\"659\" height=\"463\" srcset=\"https:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard3.png 659w, https:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard3-300x210.png 300w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/a><\/p>\n<p>Now, instead of loading from the NAND flash memory, the router will try to load firmware from the network via TFTP, which means we need a TFTP server! Since my laptop had dnsmasq on it, I used that. I was too lazy to write a configuration file. Instead, I ran it from the command line:<\/p>\n<pre>dnsmasq --tftp-root=\/tftpboot --enable-tftp --dhcp-boot=boot.bin --dhcp-range=192.168.100.25,192.168.100.60 -d<\/pre>\n<p>I don&#8217;t know if the dhcp-range is necessary; it may not be. It worked the first time I tried it, so I didn&#8217;t experiment with the dnsmasq command line. Note that by default the router appears to use BOOTP; if you&#8217;re using something other than dnsmasq, you may need to change this to DHCP in the &#8220;boot protocol&#8221; menu of the bootloader.<\/p>\n<p>Note that you&#8217;ll need to either add a firewall exception for DHCP\/TFTP or, if you&#8217;re impatient, just disable it entirely. In addition, you&#8217;ll need to give your network interface a static IP address on the appropriate netblock. I chose 192.168.100.1.<\/p>\n<p>Now dnsmasq is running and is ready to serve up the file boot.bin from \/tftpboot to any device that requests it on bootup. What is boot.bin? It&#8217;s OpenWRT itself.<\/p>\n<p>I decided to build OpenWRT from source because 1) I was bored and 2) I wanted the experience. It turns out, it&#8217;s very easy. The OpenWRT wiki has several pages on building OpenWRT from source. Unfortunately, the documentation is split into multiple pages and some of them contradict each other. <a href=\"http:\/\/wiki.openwrt.org\/doc\/howto\/build\" target=\"_blank\">Here&#8217;s a good place to start.<\/a> My workflow went something like this:<\/p>\n<ol>\n<li><a href=\"http:\/\/wiki.openwrt.org\/doc\/howto\/buildroot.exigence\" target=\"_blank\">Fetch the OpenWRT source and install prerequisites.<\/a><\/li>\n<li><em>Update<\/em> the feeds<\/li>\n<li><em>Install<\/em> only the feed I needed (luci)<\/li>\n<li>Run <strong>make menuconfig<\/strong><\/li>\n<li>Use the convenient &#8220;Disable Unnecessary Packages&#8221; script <a href=\"http:\/\/wiki.openwrt.org\/doc\/howto\/easy.build\" target=\"_blank\">here<\/a> (scroll down) so you don&#8217;t build everything.<\/li>\n<li>Run <strong>make menuconfig<\/strong> again<\/li>\n<li>Build it<\/li>\n<\/ol>\n<p>In detail:<\/p>\n<h1>1. Fetch source and prerequisites<\/h1>\n<p>Easy. Follow the directions. You&#8217;ll want Attitude Adjustment or trunk.<\/p>\n<h1>2. Update the feeds<\/h1>\n<p>Also easy. Follow the directions.<\/p>\n<h1>3. Install <em>necessary <\/em>feeds<\/h1>\n<p>What feeds are <em>necessary<\/em>? The only feed I found to be necessary was &#8220;luci&#8221;. This is the web GUI for OpenWRT. You probably won&#8217;t be very happy without it. Install it using the <strong>feeds<\/strong> scripts.<\/p>\n<h1>4. Run <em>make menuconfig<\/em><\/h1>\n<p>And this is where we configure a billion options! Actually, just a few. Use the keyboard arrows to navigate, Enter to go into a submenu, Spacebar to toggle between selections, and Esc to go back. Entries with a &#8212;&gt; are submenus. You&#8217;ll want to set the following:<\/p>\n<ul>\n<li>Target: Atheros AR7xxx\/AR9xxx<\/li>\n<li>Subtarget: Devices with NAND flash (mostly Microtek)<\/li>\n<li>Target Profile: Atheros WiFi (ath5k)<\/li>\n<\/ul>\n<p>Uncheck the following:<\/p>\n<ul>\n<li>Build the OpenWRT SDK<\/li>\n<li>Build the OpenWRT based toolchain<\/li>\n<\/ul>\n<p>Under image configuration, select &#8220;ramdisk&#8221;. (At least, that&#8217;s what I did&#8211;I wanted to test OpenWRT BEFORE flashing it.)<\/p>\n<p>Keep pressing escape until it asks you to save, and tell it to save the information. This puts the configuration into a file called .config.<\/p>\n<h1>5. Run the &#8220;disable unnecessary packages&#8221; script<\/h1>\n<p>Do you want to build a billion packages? Do you want to increase your carbon footprint unnecessarily? Neither do I! <a href=\"http:\/\/wiki.openwrt.org\/doc\/howto\/easy.build\" target=\"_blank\">Take the script<\/a>, (scroll down), put it in a file called disable.pl in the root directory of your openwrt source, and do the following:<\/p>\n<pre>perl disable.pl &gt; newconfig\r\nmv newconfig .config<\/pre>\n<h1>6. Run <em>make menuconfig<\/em> again!<\/h1>\n<p>Because repetition is fun. Repetition is fun! Repetition is <em>fun<\/em>, especially if you change something just a little bit each time so your audience doesn&#8217;t catch on to the fact that repetition is fun too soon. The second time you run\u00a0<strong>make menuconfig<\/strong>, go down to LuCI, then Collections, then check\u00a0<em>luci<\/em>. Exit out and save your changes.<\/p>\n<h1>7. Build it<\/h1>\n<pre>make V=s -j5<\/pre>\n<p>Adjust the number after the -j according to the formula (number of CPU cores + 1). Now walk away and go do something else for an hour or so. Read a book. Listen to music. If you see build errors, you&#8217;re likely missing prerequisites. Be aware that OpenWRT will download lots of stuff, so if you have a metered connection, this might be something worth doing at a friend&#8217;s house or, if you&#8217;re a college student, at campus.<\/p>\n<p>In the end, your shiny new image should be in bin\/ar71xx\/. Copy the file openwrt-ar71xx-nand-vmlinux-initramfs.elf to \/tftpboot\/boot.bin and start DNSMasq (if you haven&#8217;t already).<\/p>\n<p>Now the router is ready to rock! Reboot it. You should see the bootloader print information about loading the image from the network. A moment later, you should see the OpenWRT kernel start. After it&#8217;s booted up, change your IP address to 192.168.1.2 (or run dhclient so OpenWRT can give you an IP address on the appropriate netblock) and access 192.168.1.1 in your browser.<\/p>\n<div id=\"attachment_396\" class=\"wp-caption aligncenter\" style=\"width: 943px\"><a href=\"http:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard2.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-396\" src=\"http:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard2.jpg\" alt=\"Routerboard running OpenWRT Attitude Adjustment\" width=\"943\" height=\"707\" srcset=\"https:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard2.jpg 943w, https:\/\/jacksontech.net\/wp-content\/uploads\/2014\/07\/routerboard2-300x224.jpg 300w\" sizes=\"auto, (max-width: 943px) 100vw, 943px\" \/><\/a><p class=\"wp-caption-text\">Routerboard running OpenWRT Attitude Adjustment<\/p><\/div>\n<p>The next step is to put OpenWRT on the NAND flash memory itself, overwriting RouterOS. I&#8217;m holding off on this until I have replacement capacitors.<\/p>\n<p>So what could this little router be used for? It has only one Ethernet port. This brings to mind some possible scenarios:<\/p>\n<ol>\n<li>Wireless access point<\/li>\n<li>Wireless bridge<\/li>\n<li>Wireless-only router<\/li>\n<\/ol>\n<p>In addition, with a VLAN-capable switch attached to the router, it would be possible to use this device as a wired router as well. Most routers use some sort of VLAN-capable programmable switch internally to separate the WAN port from the LAN ports. I don&#8217;t have an external VLAN-capable switch so I haven&#8217;t tried this yet.<\/p>\n<p>Stay tuned!<\/p>\n<p>* The antenna was borrowed from another router and stuck into the bottom of a yogurt cup, a-la Michael Weston. C&#8217;mon, don&#8217;t look at me like I&#8217;m some kind of cannibal. it had two antennas! It only needs one!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My father uses a WISP for his Internet access. His equipment malfunctioned recently and a technician came out to examine the antenna. He discovered that the circuitry inside it had failed; instead of throwing it away, he offered it to me. Meet the MicroTik Routerboard 411.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,5,3,9],"tags":[36,39,38,35,37],"class_list":["post-395","post","type-post","status-publish","format-standard","hentry","category-comptech","category-linux","category-networking","category-projects","tag-mikrotik","tag-openwrt","tag-rb411","tag-router","tag-routerboard"],"_links":{"self":[{"href":"https:\/\/jacksontech.net\/index.php\/wp-json\/wp\/v2\/posts\/395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jacksontech.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jacksontech.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jacksontech.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jacksontech.net\/index.php\/wp-json\/wp\/v2\/comments?post=395"}],"version-history":[{"count":14,"href":"https:\/\/jacksontech.net\/index.php\/wp-json\/wp\/v2\/posts\/395\/revisions"}],"predecessor-version":[{"id":437,"href":"https:\/\/jacksontech.net\/index.php\/wp-json\/wp\/v2\/posts\/395\/revisions\/437"}],"wp:attachment":[{"href":"https:\/\/jacksontech.net\/index.php\/wp-json\/wp\/v2\/media?parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jacksontech.net\/index.php\/wp-json\/wp\/v2\/categories?post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jacksontech.net\/index.php\/wp-json\/wp\/v2\/tags?post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}