OpenWRT, or What else can you do with your router
In this article, we will consider installing a torrent download on almost any router with USB and support for OpenWRT firmware. I have a Linksys E3000 in stock, but there is no particular difference in installing and configuring OpenWRT. What we need for this:
- Directly a router with a USB connector, ideally, of course, with two.
- A flash drive / USB HDD of arbitrary size for your needs, the more the better.
- Literally half an hour of free time to set everything up and set up.
- Straight arms.
Installing / configuring OpenWRT
First of all, I will immediately make a reservation that you do everything at your own peril and risk, since there is a possibility of "oskirpichivaniya" your router. We check if your router is in the list of supported devices, for this we go to the OpenWrt website.
Click on the appropriate link and look for your device there in the list. In principle, the information there is not always up-to-date, I was convinced of this from my personal experience with my router, which is listed as not fully supported in this list , although it is already included in the trunk. It is advisable to remember on which chipset your router is built to facilitate the search for your particular firmware.
After that, go to the "Downloads" tab
Here it is worth choosing which branch to use the stable (Attitude Adjustment) or, accordingly, "trunk" in the snapshots folder, I will immediately notice if your router is of a more or less new model, then most likely you will not find it in the stable branch.
We proceed directly to downloading the firmware.
After the firmware has been downloaded, go to the firmware of your router. To do this, you need to go to its web interface, which is usually located at 192.168.1.1 or 192.168.0.1 , depending on the router manufacturer. For more information on the process of flashing and configuring Wi-Fi and everything else for a specific router, you can contact Google, otherwise this article can stretch to an indecent size, but we will focus on the installation and configuration of Transmission.
Installing and configuring Transmission
After flashing the router, launch PuTTY if your OS is Windows, if Linux, then just start the terminal. In the address field, drive in 192.168.1.1 for PuTTY or a command
telnet 192.168.1.1
for Linux. After successful connection, proceed to installing / configuring packages.There is a small digression before downloading the packages. Since the physical memory in the router is quite small, it ranges from 4 to 16 megabytes, depending on the advancement and price of your router, we should worry about its increase in advance. After all, in any case, we are going to connect a USB flash drive or hard drive to it, so why don't we make the router boot directly from the partition on our media? Let's do that! Before all manipulations with the router, you need to "split" your HDD / flash drive into several partitions.
- A swap partition (100-200 MB will be enough) * when using an HDD, when using a flash drive, it is not recommended, since there is a large but still limited supply of rewriting cycles
- The section from which the router will be loaded (at your discretion from 50 MB and above) with the Ext3 or Ext4 file system * This is where the second flash drive can come in handy, where it is better to place the boot area and the area for storing downloads on different devices in order to painlessly extract it to dump information without turning off the router.
- The section for your downloads / storage all the remaining space is also desirable in Ext3 / 4 if you want to periodically use the media on the computer, then NTFS, but get ready for periodic errors, since Linux is "friendly" with this type of FS, you will also have to install one more package
ntfs-3g
.
Of course, all this could be done on a router, but on a computer it all happens much faster and you can use programs with a graphical interface, and not just a command line of the terminal, which for a beginner significantly speeds up the process. How to do all this on Windows and Linux, again, you can look at Google for the same reason as the first call to this source.
Let's get started. We enter sequentially commands in the terminal
opkg update
opkg install block-mount kmod-usb-core kmod-usb2 kmod-usb-ohci kmod-usb-storage kmod-fs-ext4
With these commands, we updated the repository database on the router and installed the packages we needed: kernel modules for USB support and file system modules
block info
And we are looking for our partitions on the USB flash drive / HDD * You did not forget to connect your USB flash drive / HDD to the router, right?
mount /dev/sdaX /mnt
mkdir /tmp/cproot
mkdir /home
mount --bind / /tmp/cproot
tar -C /tmp/cproot -cvf - . | tar -C /mnt -x
sync
umount /mnt
umount /tmp/cproot
Here, instead, sdaX
you need to select the section from which we are going to download in the future. All other commands are designed to copy the boot partition of the router to a USB flash drive / HDD.
block detect > /etc/config/fstab
This command writes all found sections for automatic connection to a file /etc/config/fstab
. Next, we need to slightly edit this file to look like this:
config 'global'
option anon_swap '0'
option anon_mount '0'
option auto_swap '1'
option auto_mount '1'
option delay_root '0'
option check_fs '0'
config 'mount'
option target '/'
option uuid '7d3abfaf-493a-46bb-9730-1d793ecb9783'
option enabled '1'
config 'mount'
option target '/home'
option uuid '7d3abfaf-463a-46db-9730-1d793ecb4593'
option enabled '1'
config 'swap'
option uuid '76d36596-5710-4b77-a3a7-02a66d469750'
option enabled '1'
Open this file for editing:
vi /etc/config/fstab
You can see how to use this editor here or, again, contact Google .
Reboot the router. Again we go to the console and check if everything is correctly mounted:
root@OpenWrt:~# df
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 2758072 118004 2501828 5% /
/dev/root 2048 2048 0 100% /rom
tmpfs 63340 76 63264 0% /tmp
tmpfs 512 0 512 0% /dev
/dev/sda1 2758072 118004 2501828 5%
Here you should pay attention to the fact that it
rootfs
matches the parameters with /dev/sda1
, if this is the case, then everything worked out for us. Let's move on to the next point.Installing the torrent client Transmission.
opkg update
opkg install transmission-daemon transmission-cli transmission-web transmission-remote
/etc/init.d/transmission enable
Open the client settings file and edit it to fit your needs:
vi /etc/config/transmission
config transmission
option enable 1 # непосредственно включает клиент
option config_dir '/etc/transmission' # расположение фалов настроек клиента
option alt_speed_down 50 # ограничение скорости
option alt_speed_enabled false
option alt_speed_time_begin 540
option alt_speed_time_day 127
option alt_speed_time_enabled false
option alt_speed_time_end 1020
option alt_speed_up 50
option bind_address_ipv4 '0.0.0.0'
option bind_address_ipv6 '::'
option blocklist_enabled false
option dht_enabled true
option download_dir '/home/' # директория для загрузок
option encryption 0 # шифрование
option incomplete_dir '/home' # директория для не завершенных загрузок
option incomplete_dir_enabled false # включение/выключение директории для незавершенных загрузок
option lazy_bitfield_enabled true
option lpd_enabled false
option message_level 2
option open_file_limit 32
option peer_limit_global 240
option peer_limit_per_torrent 60
option peer_port 51413
option peer_port_random_high 65535
option peer_port_random_low 49152
option peer_port_random_on_start false
option peer_socket_tos 0
option pex_enabled true
option port_forwarding_enabled false
option preallocation 1
option proxy ""
option proxy_auth_enabled false
option proxy_auth_password ''
option proxy_auth_username ''
option proxy_enabled false
option proxy_port 80
option proxy_type 0
option ratio_limit 2.0000
option ratio_limit_enabled false
option rename_partial_files true
option rpc_authentication_required false
option rpc_bind_address '0.0.0.0'
option rpc_enabled true
option rpc_password ''
option rpc_port 9091
option rpc_username ''
option rpc_whitelist '127.0.0.1,192.168.1.*'
option rpc_whitelist_enabled false
option script_torrent_done_enabled false
option script_torrent_done_filename ''
option speed_limit_down 100
option speed_limit_down_enabled false
option speed_limit_up 40
option speed_limit_up_enabled true
option start_added_torrents false
option trash_original_torrent_files false
option umask 18
option upload_slots_per_torrent 14
option watch_dir_enabled false
option watch_dir ''
Run and check:
/etc/init.d/transmission start
Launch the browser and enter 192.168.1.1:9091 if everything works then that's it.
If this article is of interest to someone, I am ready to tell you about setting up a "file looser", raising a VPN server, setting up IPTV on OpenWRT.
I tried to describe the entire installation and configuration process as detailed and simply as possible. Also recently, in OpenWRT, the principle of using a flash drive as a root partition has changed slightly, now this information is already available in the project wiki, but only in English.
UPD: This article does not describe how to set up an Internet connection from your provider, as there are too many nuances of settings. Naturally, nothing will work without connecting the router to the Internet.