IRC on the Tenda 4G185 (ZX297520V3)
Introduction
Following getting root access on the device and installing a webserver (which hosts this page) it was time to get a bit more complicated and realtime. It felt like the next step was to get some form of chat server working, while I’ve learnt that something like XMPP would be ideal that was a bit too complicated to start with and as I wanted my early internet vibes I went with getting an IRC server running.
Getting Root
Check out my previous post about getting root access to the device and installing some actually useful programs including setting up a webserver.
Finding a simple C IRC server
Following on from getting root access to the device and installing a webserver which I can manage it felt like the next step would be to install an irc server. I spent a while trying to get various simple irc servers to statically compile and finally managed with MiniChat. Its a super basic IRC server written in C++ - I have a suspicion that it might have had some AI contribution.
MiniChat
MiniChat is hosted on github, it has a simple Makefile which I edit to use CXX = arm-linux-gnueabi-g++ and added --static to CXXFLAGS and then it was a simple cross compile to create a static binary which I transferred across to the 4G185. It was then a matter of adding Minichat to the global.sh start up script as /mnt/userdata/minichat 6667 linux & and we had a IRC server hosted on 6667 with a password of linux.
/quote commands,
/quote PASS <serverpassword>
/quote NICK <nickname>
/quote USER <username> <hostname> <servername> <realname>
This is not ideal as most people have auto login setup on their IRC clients and some clients didn’t even allow for custom /quote commands to be even used. That said the server did work and was fairly stable on the device itself.
I’ve cloned the git repository and added the simple changes as well as uploaded a binary - solarcene gitea
Cross compiling with musl libc
It was clear that a more established IRC server would work better but it would need to be possible to cross-compile a static binary, I tried with a number of IRC servers but using arm-linux-gnueabi-gcc as expected they would still link to glibc often around functions that required getting a servers’ hostname. Further research brought me to using musl libc which is an alternative implementation of the standard C library and is very good at cross compling and also statically building small binaries.
I’ve used musl before and it wasn’t difficult to get a cross compiling environment setup using musl-cross-make. Once this was setup it was just a matter of putting a CC variable before the ./configure for a project and it would then allow you to use the standard Makefile when cross compiling. This revolutionised the work I was doing and allowed me to build more complicated programs.
Building ngIRCd
Continuing my review of IRC servers with established features one that jumped out was ngIRCd which is a lightwight IRC server written in C. Using musl it was easy to compile:
CC="/home/radxa/development/tenda/musl-cross-make/output/bin/arm-linux-musleabi-gcc -static" ./configure --without-epoll --without-syslog --disable-ipv6 --disable-ircplus
make
Then it was a matter of copying over the binary adb push ngircd /mnt/userdata/ and then with a simple irc.conf:
[Global]
Name = irc.solarcene.community
AdminInfo1 = IRC on the Tenda 4G185
AdminInfo2 = Hosted on ZX297520V3
AdminEMail = solarcene@protonmail.com
Listen = 0.0.0.0
Ports = 6667
;ServerUID = 65534
[Limits]
MaxConnectionsIP = 20
Finally to get it to start on boot I’ve added it to the global.sh:
/mnt/userdata/ngircd -n -f /mnt/userdata/irc.conf &
Success but…
And now we have a reliable irc server which is easily accessed over wifi and while I have plans to develop this device into a local community hub right now there aren’t that many people on my local wifi who want to chat with me on IRC. Luckily we have a 4G/LTE modem built into the device to take advantage of.
Adding a simcard
As we haven’t actually modified or reflashed the original firmware it was as simple as getting a nano sim card (found a deal for 80gb for £10 a month). On inserting it it immediately connected and started serving internet to the internal bridge. The issue is that 4G mobile/cell connection doesn’t have simple IP4/6 connections and instead is some sort of CGNAT hell.
This means that while the irc server is accessible locally on WiFi it isn’t easily accessed over the internet. I have a static IP on my home server and therefore worked out I could make a reverse ssh tunnel to port forward the irc port from the home server to the Tenda device. The ‘reverse’ bit is needed as I need the device to connect as a client and then for the server to pass the data back over the tunnel as I don’t have a public IP for the Tenda device.
Cross compiling OpenSSH
Initially I cross compiled dropbear (an alternative ssh server which is often used for embedded systems) and while I could get it to run as a server I couldn’t get it to work as a reverse tunnel. Therefore I drew upon all my cross-compiling magic and attempted to cross compile OpenSSH.
I actually forgot to properly document the exact steps however I had success with:
openssh-8.8p1zlib-1.3.1ncurses-6.2
I cross compiled the individual libriaries using musl similar to previous declaring the musl CC before ./configure. I then compiled openssl-1.1.1w using:
CC="/home/radxa/development/tenda/musl-cross-make/output/bin/arm-linux-musleabi-gcc -static" ./configure --host=arm-linux-musl --disable-strip --disable-pam --with-zlib=/home/radxa/super_build/zlib-1.3.1 --with-ssl-dir=/tmp/ssh --without-pie --with-curses=/home/radxa/super_build/install/include/ncurses LDFLAGS="-static -Wl,-Bsymbolic -Wl,--allow-multiple-definition -Wl,-z,notext" CFLAGS="-static"
make
This successfully built me a number of static binaries for armv7 which i’ve uploaded to solarcene gitea.
While I had hoped that it would have been as easy as just now running the ssh client and doing a reverse tunnel it turns out that openSSH didn’t work with the limited root system on the device, it was therefore necessary to setup a rudimentary chroot filesystem using a busybox-armv7l binary with a lot of built in features, a proper writable /etc as well as mounting files such as /dev:
# Setup chroot
mount --rbind /dev /mnt/userdata/sysroot/dev/
mount -t proc /proc /mnt/userdata/sysroot/proc/
mount --rbind /sys /mnt/userdata/sysroot/sys/
Reverse SSH Tunnel to a static IP
Finally we could setup a reverse ssh tunnel to my home internet and then with a bit of port forwarding it was then possible to access the IRC server from the world wide web (I aslo ssh tunnelled this webserver that you are reading this blog on!).
/mnt/userdata/chroot /mnt/userdata/sysroot /bin/ash -c "/usr/bin/ssh -R '*:6668:127.0.0.1:6667' -p 8022 -N user@example.com" &
/mnt/userdata/chroot /mnt/userdata/sysroot /bin/ash -c "/usr/bin/ssh -R '*:8082:127.0.0.1:8082' -p 8022 -N user@example.com" &
Finally connecting to the server

If you’ve made it to this point, awesome, feel free to join the irc server. Please note that the server is a tiny bit unreliable - thats more related to the 4G connection dropping out. Also the server is based in the UK which means that I will put together a risk assessment in the near future as per the Online Safety Act - the IRC server is solely for adult and will be for discussing hardware/linux development.
For example using irssi
- Install and run irssi (
irssi -n <your_nickname>) /connect solarcene.community 6668/join #general
Also the server is based in the UK which means that I will put together a risk assessment in the near future as per the Online Safety Act - the IRC server is solely for adults and as the topic is about hardware/linux development there will be moderation regarding illegal content as described in various guidance.