# No dhcpd or tftpd, no problem. Load OpenWRT firmware on Mikrotik RouterBoards the easy way using dnsmasq. Open two bash shell windows. In the 1st window execute the following and create your loader file:
# FIRST BASH SHELL WINDOW
mkdir -p /var/lib/tftpboot vi /var/lib/tftpboot/loader.sh
# Create your loader.sh file
#/bin/bash ifconfig enp6s0 192.168.1.10 up dnsmasq -i enp6s0 --dhcp-range=192.168.1.100,192.168.1.200 \ --dhcp-boot=openwrt-18.06.1-<your supported routerboard-initramfs>-kernel.bin \ --enable-tftp --tftp-root=/var/lib/tftpboot/ -d -u root -p0 -K --log-dhcp --bootp-dynamic
# Make it executable.
chmod 755 /var/lib/tftpboot/loader.sh
# Ensure both your desired initram AND upgrade image files (2 files) have been moved to the above tftpboot directory. If you forget the corresponding upgrade file, on reboot you’ll find RouterOS is back. Once you’re interfacing with OpenWRT, make sure to manually execute the upgrade in order to purge the RouterOS. It will ensure your OpenWRT kernel sticks and survives power cycles.
# Unplug your ethernet cable that connects the Linux host you are currently on from your current internet router. Then connect this loose end into the WAN/Internet port on your MikroTik Routerboard.
# In your second bash window, execute the following commands: First we determine what the main interface name is that’s using your ethernet connection (in my case its enp6s0). Then we create a virtual interface assigning it an IP address that resides on the 192.168.88.0/24 network.
# SECOND BASH SHELL WINDOW
ifconfig | grep Ethernet | cut -d" " -f1 #enp6s0 <-- e.g. output. You may have more than one listed, its usually the top. ifconfig enp6s0:0 192.168.88.2 up
# Now telnet to 192.168.88.1 and login (u:admin p:
/system routerboard settings set boot-device=try-ethernet-once-then-nand /system routerboard settings set boot-protocol=dhcp
# FIRST BASH SHELL WINDOW
cd /var/lib/tftpboot/ ./loader.sh
# Now quickly Unplug the power source from your Routerboard and plug it back in. You should soon see in your FIRST BASH WINDOW dhcp and a tftp directives and the sending of your OpenWRT image to the Routerboard. Give it some time to complete. A sign of completion is you will see OpenWRT dhcp messages in your FIRST BASH WINDOW.
# Once the first flashing is complete, unplug your ethernet cable from the Routerboard WAN port and plug it into its first LAN port. Depending on which Routerboard you have it may vary. You should now be able use a browser and log into OpenWRT via ip address 192.168.1.1. NOTE! you’re NOT FINISHED! Log into OpenWRT and navigate to System> Backup / Flash Firmware. In the Flash new firmware image section click choose file and load the OpenWRT sysupgrade image you stored in /var/lib/tftpboot then click Flash Image. Now your new OpenWRT router will survive reboots.
# Lastly decide to delete, or keep but disable and lock loader.sh until its needed again.
chmod 000 /var/lib/tftpboot/loader.sh chattr +i /var/lib/tftpboot/loader.sh
# Visual confirmation loader.sh is locked down using lsattr.
# Sample results: root@host:/var/lib/tftpboot# lsattr -------------e-- ./openwrt-18.06.1-ramips-mt7621-mikrotik_rbm33g-initramfs-kernel.bin -------------e-- ./openwrt-18.06.1-ar71xx-mikrotik-rb-nor-flash-16M-squashfs-sysupgrade.bin -------------e-- ./openwrt-18.06.1-ar71xx-mikrotik-rb-nor-flash-16M-initramfs-kernel.bin ----i--------e-- ./loader.sh -------------e-- ./openwrt-18.06.1-ramips-mt7621-mikrotik_rbm33g-squashfs-sysupgrade.bin