Available: Dlink DSL2650u router from the
previous topic , which has a USB host and is stitched with OpenWRT firmware, and the Dingoo A320 prefix, on which OpenDingux is installed (Linux for Dingoo).
Task: To organize round-the-clock distribution of torrents in order to raise the rating a little on the tracker. Kill a whole day with an interesting activity and increase your knowledge of Linux.
The topic is written more for entertainment purposes, rather than as a practical guide, as many may be confused by the expediency of what was started.
What can be useful to extract from the topic?
- Learn how to connect and mount flash drives to the router
- How to still raise the torrent client (transmission) on the router
- How to connect UsbNet device and install the bridge to the local network
- How can you be interesting to kill a whole day
Some technical characteristics of a piece of iron:
- Router: 300mhz CPU, ~ 30mb (29668kb) RAM
- Dingoo A320: 333mhz CPU (accelerates to 430mhz), ~ 30mb (29500kb) RAM
As you can see, the characteristics are similar.
First attempts
At first, attempts were made to raise the distribution directly on the router: a 4GB flash drive is inserted into the USB and torrents are distributed from there. Following
the wiki page , installed the necessary packages with the command:
opkg install usbutils kmod-usb-core kmod-usb-ohci kmod-usb-uhci kmod-usb2 kmod-usb-storage kmod-usb-storage-extras block-mount block-hotplug kmod-fs-ext4
After connecting the flash drive, it was normally determined and two devices
/ dev / sda and
/ dev / sda1 appeared . The flash drive was formatted in FAT32, so I had to deliver the packages:
')
opkg install kmod-fs-vfat kmod-nls-cp437 kmod-nls-utf8 kmod-nls-cp1251
The last two packages are optional, because
mount mounts in cp437 encoding, and does not accept any parameters about changing the encoding. In any case, if you can’t mount the partition, you need to look at the
dmesg output for a reason.
You can configure automounting, for this you need to edit the
/etc/config/fstab
. For automounting, the previously installed
block-hotplug package is responsible. Read more in the
OpenWRT documentation .
After connecting and mounting the flash drive, you need to install the
transmission . Why he? Because it can work as a daemon, has an rpc and web interface. RPC means the ability to control the distribution directly on the computer in a convenient gui interface. And the first guide found on the Internet was about him. Therefore:
opkg install transmission-daemon transmission-web
After installation, you need to edit the configuration file
/etc/config/transmission
. Setting the transmission in OpenWRT is not the essence of the topic, so for additional data please contact
here . The web interface is available at
192.168.1.1 : 9091, the RPC is connected there too. The transmission-remote-gui-bin package from the AUR (in Archlinux) was downloaded and installed as an RPC client.
After setting up and running the
transmission , disappointment came - the router is too weak for that. The RAM was running out, the processor was loaded to capacity, and after a few minutes the router stopped responding. The only salvation was a reboot. I tried to make a swap partition on a flash drive and connect it to the router. I broke the flash drive into two sections, allocated 100 MB for the swap, formatted it, connected it ... but the situation did not change much. The testimony of the
free command showed that the swap was engaged for no more than 1mb.
Therefore, the flight of thought flew on.
And then came the delusional

I continued to think that you can connect to an affordable usb port for business. Only the Motorola Z6 mobile phone (on Linux), and the Dingoo A320 came to mind. Since the motorola was not at hand, he continued to experiment with dingy. With Dingux (and OpenDingux), you can make a network via UsbNet. Having examined the name of the module (cdc_ether), I began to install it in OpenWRT. This package turned out to be installed without any problems:
opkg install kmod-usb-net-cdc-ether
After connecting to
ifconfig
a new interface appeared: usb0. Having set the IP address by DHCP (udhcpd is used on Dingux), I checked that everything works. The task was to distribute the Internet via usb0, and, preferably, to make access from the local network. My thoughts were about creating a set of rules for iptables, for masquerading, for transferring packets, etc., but the solution turned out to be much simpler: you need to add
usb0 to
ifname in the
/etc/config/network
file in the
config interface lan
section . It turned out this line:
option ifname "eth1.0 usb0"
It remains to force Dingoo to receive data via DHCP, rather than installing a static 10.1.0.2. Having rummaged through the
/etc/init.d/network
initialization script, I saw that several user variables are being used.
if [ -z $DINGOO_IP_ADDRESS ]; then DINGOO_IP_ADDRESS="10.1.0.2"; fi
if [ -z $PC_IP_ADDRESS ]; then
if [ $DINGOO_IP_ADDRESS != "10.1.0.1" ]; then PC_IP_ADDRESS="10.1.0.1"
else PC_IP_ADDRESS="10.1.0.2"
fi
fi
if [ -z $DINGOO_NETMASK ]; then DINGOO_NETMASK="255.255.255.252"; fi
if [ -z $PC_NETMASK ]; then PC_NETMASK=$DINGOO_NETMASK; fi
I asked smart people who are related to the development of OpenDingux, where you can override them. Since there are no rights to write to / etc (there is a squashfs image there), the developers have made it possible to override variables in the
/usr/local/etc/initvars
. I couldn’t get IP from DHCP, so I decided to manually register the IP address 192.168.1.2:
DINGOO_IP_ADDRESS=192.168.1.2
PC_IP_ADDRESS=192.168.1.1
DINGOO_NETMASK=255.255.255.0
Additionally, you need to register the DNS server address in
/usr/local/etc/resolv.conf
nameserver 192.168.1.1
After restarting all the services, I was convinced of the efficiency of the scheme: Dingoo pinged from the network, Pinging the network and the Internet from Dingoo. A separate problem was when I assigned IP not 192.168.1.2, but more - 192.168.1.254, and did not pay attention to the subnet mask (Dingoo's standard mask is 255.255.255.252), and for a long time could not understand why nothing was working.
Install the transmission
OpenDingux does not have such a convenient repository as in OpenWRT, so the transmission had to be assembled with pens. Toolchain (a set of utilities for compiling for a specific platform) is taken
from here . I downloaded the source, read
./configure --help
, turning off all unnecessary things, began to try to compile.
./configure --host=mipsel-linux-uclibc --disable-gtk --disable-mac --disable-cli --disable-libnotify --disable-libappindicator --disable-libcanberra --disable-nls --disable-utp
make
According to dependencies, we had to build openssl, libevent and curl. I copied the transmission-daemon binary file along with the missing Dingoo libraries into / usr / local / apps / transmission and created a regular script to run. It turned out this list of files:
ls /usr/local/apps/transmission/
libcurl.so.4 libevent-2.0.so.5 transmission transmission-daemon
and this script:
#!/bin/sh
LD_LIBRARY_PATH=.
./transmission-daemon -T -w /usr/local/torrent/ -g /usr/local/torrent/config -a 192.168.1.* -e /usr/local/torrent/log
There was a problem with the launch, transmission wrote briefly "Bus error". By scientific method, it turned out that the problem disappears if you do not specify the watch directory. Perhaps the kernel in Dingux without inotify support.
Conclusion
You are unrealistic persistent, if you have read to this point. Now I just download torrents for distribution. The limits on the number of peers (50), on the download speed (300kbyte / s) and return (200kbyte / s) were chosen experimentally. It works stably, you can experiment with increasing the limits.
Why not pick up on the router after all, with equal gland? Firstly, it is less interesting, and secondly, the router still has a whole bunch of other tasks - distributing the Internet and taking resources from it is not good. MiniSD card for 4GB allows you to download a small amount of torrents for distribution, but thanks to that too.
I did not install the web interface, since I still have to play with the web server. I control via RPC and
Transgui .
Why not buy a NAS for this purpose? While not ready for such a large purchase, and not so actively using torrents. In this problem, the solution was more interesting for me than the result.
I would like to thank the OpenWRT development team, made a very thoughtful system with an application repository, a unified system of configs. Pulls on the whole distribution, only for routers.
And, finally, a few links: