Over the years I have flashed OpenWRT into many routers. Recently, I bought
my first Mikrotik (an hEX S RB760iGS) and I am having a hard time trying to
netboot OpenWRT. As prescribed in the wikis, through the web interface, I set:
System → Routerboard → Settings → Boot device: Try ethernet once then NAND
System → Routerboard → Settings → Boot protocol: DHCP
System → Routerboard → Settings → Force Backup Booter
and shut the router down. Whence, I run on my machine:
But, when I turn the router back on, it looks like the bootloader downloads the image file dozens of times for a minute or so. Then, after a number of tries, it aborts and reboots the router with RouterOS from flash memory.
Thank you, u/frolic. I tried the upgrade but it did not work. Methinks, upgrading does not touch the boot loader.
Nevertheless, I finally managed to flash OpenWRT departing from the instructions in the Wiki in two fundamental ways. The DHCP client of the boot loader seems to be broken, so I used BOOTP. There was no way to make it work in DHCP netboot mode. Secondly, instead of dnsmasq, I resorted to TFTP-HPA and standard ISC DHCP implementations.
The procedure is as follows:
# I use Void linux, but Debian is similar (packages tftp-hpa and isc-dhcp).
sudo xbps-install -Su tftp-hpa dhcp
sudo ip addr flush dev enp0s20f0u2u2
sudo ip addr add 192.168.88.2/24 dev enp0s20f0u2u2
sudo ip link set enp0s20f0u2u2 up
# Find out the MAC address of the Wan port of the router.
# Enter the RouterOS terminal and execute the command
# "/interface ethernet print"
# Take note of the MAC address of interface "ether1":
# "08:55:31:aa:bb:e4".
# Log into the web interface of RouterOS and set router to boot from
# ethernet once and with BOOTP:
# System → Routerboard → Settings → Boot device: Try ethernet once then NAND
# System → Routerboard → Settings → Boot protocol: BOOTP
# System → Routerboard → Settings → Force Backup Booter: Checked
# (if supported by your routerboard - !IMPORTANT)
# System → Shutdown
# Pull off the router's power cord.
#
# CAVEAT: Contrary to what is incentivized in the wiki, the boot protocol set through
# the RouterOS's web interface must be "BOOTP", instead of "DHCP".
# Set the stage for the TFTP server.
sudo mkdir -p -m 1777 /tmp/tftpd
sudo cp ~/pathto/openwrt-21.02.1-ramips-mt7621-mikrotik_routerboard-760igs-initramfs-kernel.bin /tmp/tftpd/openwrt.bin
sudo chmod 0777 /tmp/tftpd/*
# Set the stage for the DHCP/BOOTP server.
sudo mkdir -p -m 1777 /tmp/dhcpd
sudo bash -c 'cat > /tmp/dhcpd/dhcpd.conf << _EOF
subnet 10.1.1.0 netmask 255.255.255.0 {
range 10.1.1.100 10.1.1.110;
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 10.1.1.255;
option routers 10.1.1.1;
option domain-name-servers 10.1.1.2;
option domain-name "mikrotik2openwrt.io";
authoritative;
}
#allow bootp;
host mikrotik {
hardware ethernet 08:55:31:aa:bb:e4;
fixed-address 10.1.1.1;
filename "openwrt.bin";
option domain-name-servers 10.1.1.2;
option domain-name "mikrotik2openwrt.io";
}
_EOF'
sudo touch /tmp/dhcpd/dhcpd.leases
# Test the DHCPd configuration file.
sudo dhcpd -f -d -cf /tmp/dhcpd/dhcpd.conf -lf /tmp/dhcpd/dhcpd.leases -t
# Run the TFTP and DHCP servers.
sudo ip addr flush dev enp0s20f0u2u2
sudo ip addr add 10.1.1.2/24 dev enp0s20f0u2u2
sudo ip link set enp0s20f0u2u2 up
# On a terminal, execute:
sudo in.tftpd -v -L -s -a 10.1.1.2:69 /tmp/tftpd
# And, on a second terminal, run:
sudo dhcpd -f -d -cf /tmp/dhcpd/dhcpd.conf -lf /tmp/dhcpd/dhcpd.leases
# Connect the cable to the WAN port and turn the router on.
# Watch the DHCP server output as the bootloader fetches the IP address.
# Wait until the DHCP server starts reporting successive requests again and
# the blue LED on the router stops blinking.
# The router should now be running OpenWRT from RAM.
# Press Ctrl-C to finish both daemons.
sudo ip addr flush dev enp0s20f0u2u2
sudo ip addr add 192.168.1.2/24 dev enp0s20f0u2u2
# Disconnect the cable from the WAN port and plug it into a LAN port.
ping 192.168.1.1
# Access the OpenWRT web interface and navigate to
# System -> Backup/Flash Firmware
# Finally, flash the sysupgrade image file:
# "~/pathto/openwrt-21.02.1-ramips-mt7621-mikrotik_routerboard-760igs-squashfs-sysupgrade.bin".