Linksys AC Series Router Configuration Tips for OpenWRT
Most of this article is focused on the OpenWRT Firmware / OS (Operating System) and the WRT1900ACS and WRT3200ACM routers. The WRT32X is essentially the same as the WRT3200ACM and is not mentioned specifically in this article. The WRT1900AC series is older and because the price difference between it and the WRT1900ACS is negligible, along with better hardware specification for the WRT1900ACS, it is recommended to purchase the ACS, thus the AC model is not fully covered here. The information below does work for the most part on the WRT1900AC and WRT32X.
See WRT1900AC, WRT1900ACS, and WRT3200ACM Routers, SoS (CPU), and Hardware for information about hardware specifics.
Firmware Installation
REMEMBER: The AC Series of routers has dual boot partitions, so if you're installing firmware it will flash it to the non-active flash partition. The same occurs if upgrading existing OpenWRT firmware. So if one happens to be running OpenWRT on one partition and DD-WRT or the stock Linksys firmware on the other partition, if installing from the OpenWRT / LUCI GUI, it will overwrite the other partition.
So how does one upgrade OpenWRT firmware on the current / active boot partition when the process upgrades the other inactive partition? What about changing the boot partition to the inactive one and then upgrade the firmware (See the Switching Boot Partitions section of this article for the commands to view or change the boot partition)? After several attempts, this trick didn't work. Documentation exists that says this trick works with DD-WRT (https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=311117). It seems the flashing of the NVRAM is left up to the Marvell SoS / CPU and there is no way around it via OpenWRT. Alternative?
The solution is to upgrade from the other partition. IE, if Partition 1 needs to be upgraded, boot to Partition 2 and perform an upgrade, which will then upgrade Partition 1. This will obviously work if OpenWRT is installed on both partitions. But how can one install DD-WRT on the other partition from OpenWRT?
Solution: Use the command line. IE, it won't work from the OpenWRT LUCI GUI.
- Download the DD-WRT Factory Firmware (factory-to-ddwrt.bin) to the /tmp Directory
- For WGET to work, this may be needed: opkg install libustream-mbedtls
- Type the following command: sysupgrade -n -v -F /tmp/factory-to-ddwrt.bin (-n = do NOT keep current settings, -v = verbose, -F = Force)
The firmware will be installed on the other partition.
Only Upgrade versions of OpenWRT can be flashed via the GUI. Factory firmware will result in an error. , but not sure if it is possible to "cross update" between DD-WRT and OpenWRT.
Use the OpenWRT Install / Factory image in this instance.
WRT1900AC
There are two hardware versions of the WRT1900AC (v1 and v2, v1 will not appear on the label, it is used here to differentiate between v1 and v2) so check the label on the bottom of the router and get the right firmware.
WRT1900ACS
There are two hardware versions of the WRT1900ACS (v1 and v2, v1 will not appear on the label, it is used here to differentiate between v1 and v2), but unlike the WRT1900AC, both versions of the router use the same firmware.
WRT3200ACM
As of the writing of this article on 7.2020, there is only one version of the WRT3200ACM
Package Installation with OPKG
opkg is the package management utility on OpenWRT.
Dual Booting
This allows for rebooting to the alternate partition;
- opkg update
- opkg install luci-app-advanced-reboot
Remember: When attempting to utilize this within the LUCI GUI (if already logged in and connected), refresh the browser windows (CTRL Key plus Refresh Button in Firefox).
USB Flash Drives
Believe it or not, the stock installation of OpenWRT does not come with the capability to access USB or eSATA devices. Considering how prevalent a USB port is on routers these days, that's a bit baffling. Plus it's really frustrating for so many web sites that refer to the LuCI, System, Mount Point menu that doesn't exist unless the previously mentioned items are installed. Big woof on this one.
The following allows for ext2, ext4, and ntfs partitions to be recognized via USB and includes the LUCI GUI Interface (Under System, Mount Points);
- opkg update
- opkg install block-mount e2fsprogs kmod-fs-ext4 kmod-usb-storage kmod-usb2 kmod-usb3 ntfs-3g
Samba Server and File Sharing
- opkg update
- opkg install samba36-server luci-app-samba
- smbpasswd -a root (or whatever user is desired)
The stock Samba Server Configuration should be replaced with something similar in the LUCI GUI, Service, Network Shares, Edit Template Tab
[global]
netbios name = OpenWRT
server string = Samba on OpenWRT
workgroup = ESTUARY-A
guest account = nobody
security = user
map to guest = Bad User
guest ok = yes
guest only = no
timestamp logs = no
preserve case = yes
short preserve case = yes
socket options = TCP_NODELAY SO_KEEPALIVE IPTOS_LOWDELAY SO_RCVBUF=65536 SO_SNDBUF=65536
log level = 0
syslog = 0
passdb backend = smbpasswd
smb encrypt = disabled
smb passwd file = /etc/samba/smbpasswd
If any attempts are made to edit the /etc/samba/smb.conf file directly, it will be overwritten each time by OpenWRT as that's the way it functions in OpenWRT. It can be prevented, but it is recommended not to do that in order to preserve the standard functionality of OpenWRT.
And lastly, remember if one attempts to share the "Root Directory" ( / ), none of the sub directories will open, because of the way the OpenWRT file system works.
Multiple IP Addresses assigned to an interface, AKA Aliases in OpenWRT
The OpenWRT article on Basic Networking and Aliases includes a lot of information. But they leave out a few interesting details that would be nice to know;
- Bridge / Switch: The br-lan name (seen when using the ifconfig command) is not explicitly assigned. Instead, if an interface defined in the /etc/config/network file is option type 'bridge' then "br" with a hyphen ( br- ) is prepended to the name of the interface ( interface 'lan' ) in the /etc/config/network file
- Make sure each new "Interface" is include in the firewall setting (GUI: Interface, Firewall Settings, Assign Firewall Zone OR File: /etc/config/firewall, config zone (lan), option network, add the name of the interface)
- OpenWRT examples tend to vacillate between one of two different syntax in their examples, for instance;
- option 'type' 'bridge' OR option type 'bridge' (the latter seems to reflect how the actual configuration files are done)
- The option ifname item should be set to the above mentioned br-lan OR br-lan1 name ( option ifname 'br-lan1' ), not eth0.1 as examples give and the configuration file might imply. IE, the br-lan OR br-lan1 interface name doesn't exist in the /etc/config/network file, so how is one supposed to know? Well, as mentioned in the bullet point, this was discovered after a bit of experimenting. Thus the initial comment about the OpenWRT documentation leaving out a key detail to actually making things function.
Note: Items in the above bullet points noted in italic represent configuration statements in a file.
Example;
A.B.C.D and W.X.Y.Z are place holders for an IP Address
# When using IFCONFIG, this interface will be displayed as br-lan1 and eth0.1 will not
# have an IP Address
config interface 'lan1'
option type 'bridge'
option ifname 'eth0.1'
option proto 'static'
option netmask '255.255.255.0'
option ip6assign '60'
option ipaddr 'A.B.C.D'
config interface 'lan2'
option proto 'static'
option ipaddr 'W.X.Y.Z'
option netmask '255.255.255.0'
# The ifname needs to be set to the br-lan1 name, not eth0.1
option ifname 'br-lan1'
...and don't forget to type the following command for settings to take effect: service network reload
OpenVPN
For some reason if one installs OpenVPN via opkg install openvpn, the mbedTLS version is installed as opposed to the OpenSSL. Hint: Use the OpenSSL. Why?
To install OpenVPN with OpenSSL and the LUCI GUI for it (under VPN)
- opkg update
- opkg install openvpn-ssl luci-app-openvpn
Telnet
Telnet is supported (and works) on DD-WRT, but OpenWRT has essentially discontinued use of telnet in the name of security. It is possible to build a custom version of the OpenWRT software that supports telnet.
Swap Partitions / Files
Most references to Swap Partitions or Files indicate performance is quite poor. But this may have been written during the USB 2.0 period and doesn't reflect the performance of USB3 or eSATA devices in 2020. That said, "Virtual RAM" is slower no matter what. The AC Series comes with an astounding amount of RAM (512 MB), so this may not be an issue.
If a Swap Partition is added, it can will potentially consume an entire USB Flash drive.
A Swap File may be a good alternative.
Inactive Partition and Linksys Reserved NVRAM / Flash Memory Partition Mounting and Information
To mount the Inactive Partition (keep in mind the directory structure will not be the same as viewed from the root directory, but all the configuration files are under etc);
- ubiattach -m 6 OR ubiattach -m 8 (an error will occur if the current / active partition is selected, so attach the other one)
- mkdir /tmp/ubi2_1
- mount -t ubifs /dev/ubi2_1 /tmp/ubi2_1
To mount the syscfg partition / mtd9 (if needed, the WRT1900ACS doesn't seem to mount it automatically, but the WRT1900ACM does);
- mkdir /tmp/ubi1_0
- mount -t ubifs /dev/ubi1_0 /tmp/ubi1_0
View available partitions to mount
ls -la /dev/ubi*
Information
/dev/ubi0_1 is the mtd6 OR mtd8 partition (whichever is active)
/dev/ubi1_0 is the syscfg / mtd9 partition (this is only used by the Linksys Firmware and is just wasted NVRAM / Flash that is not used by OpenWRT
cat /proc/mtd = shows the available partitions (should match the OpenWRT documentation)
/sys/devices/virtual/ubi/ubi0/mtd_num is a file that indicates the current / active partition, which is 6 / mtd6 or 8 / mtd8
/sys/devices/virtual/ubi/ubi1/mtd_num is the file that indicates thesyscfg partition (9 / mtd9)
Sources
https://forum.openwrt.org/t/script-mount-alternate-nand-firmware-linksys/33588
https://forum.openwrt.org/t/solved-how-to-mount-ubifs-in-openwrt-kirkwood/32443/4
Switching Boot Partitions
Commands for OpenWRT
- To determine which boot partition is active: /usr/sbin/fw_printenv -n boot_part
- To change which boot partition is active: /usr/sbin/fw_setenv boot_part 1 OR /usr/sbin/fw_setenv boot_part 2
Commands for DD-WRT
- To determine which boot partition is active:ubootenv get boot_part
- To change which boot partition is active: ubootenv set boot_part 1
Power Switch
Per this site: https://community.linksys.com/t5/Wireless-Routers/WRT1900AC-May-have-bricked-it/td-p/811096
- Reset the router by holding the reset button in until the PWR light starts to flash, appx. 15 seconds.
- Once the power light stops flashing, you can power off the router with the power switch.
- Turn the power back on and the PWR light will light. As soon as any other light turns on, power off the router with the power switch.
- Turn the power back on and the PWR light will light. As soon as any other light turns on, power off the router with the power switch.
- Turn the power back on and the PWR light will light. As soon as any other light turns on, power off the router with the power switch.
- Turn the power back on and the PWR light will light. This time just let the router power all the way up. It should now be on the alternate
Per this site: https://forum.archive.openwrt.org/viewtopic.php?id=70202
- Start with the power switch off, then switch on. Watch the power LED:
- Power LED: on (a few seconds)
- Power LED: off (a second or two)
- Power LED: on (immediately when the power light turns on, flip the power switch off)
- That is 1 cycle of the 3 required to revert to the other partition. Repeat the above procedure two more times, making sure to flip the switch off as soon as the power LED comes on the second time.
- The fourth time you turn the power switch on you can let the device boot and it should boot into the other partition.