PirateBox - OpenWrt sur TP-Link TL-MR3020
Article en cours de rédaction |
---|
Sommaire
Présentation
La PirateBox permet, via un petit routeur neuf ou de récupération, de mettre à disposition en wifi un espace de stockage en écriture ou en lecture seulement. Les utilisateurs se connecte en wifi sur la PirateBox et peuvent prendre des fichiers. Le routeur est coupé du réseau internet. La PirateBox utilise le système d'exploitation libre OpenWrt.
Coût
TP-Link ≈ 30 €
Niveau de difficulté
Outillage nécessaire
- Ordinateur
- Connexion internet
Composants nécessaires
- TP-Link
Schémas
Étape par étape
Préparer le routeur
- placer le routeur en mode WISP (Wireless Information Service Point ou Wireless Internet Service Provider selon l'usage)
- alimenter électriquement le routeur (USB)
- connecter le routeur directement à votre ordinateur à l'aide d'un câble réseau
Se connecter au routeur et mettre à jour le firmware
Il faut être sur le même réseau, pour cela :
ifconfig eth0 192.168.0.50
Alors on peut ouvrir un navigateur et aller sur le routeur à l'adresse suivante http://192.168.0.254
L'identifiant est : admin et le mot de passe : admin
Il faut télécharger le firmware OpenWRT concu pout le TP-Link MR3020 sur son poste de travail :
$ wget http://downloads.openwrt.org/snapshots/trunk/ar71xx/openwrt-ar71xx-generic-tl-mr3020-v1-squashfs-factory.bin
Dans l'interface du TP-Link, à l'adresse http://192.168.0.254 il faut se rendre dans System Tools > Firmware Upgrade.
Un formulaire propose d'uploader le nouveau firmware via un formulaire.
Après la mise à jour, le MR3020 redémarre et l'on perd la connexion dans le navigateur, en effet l'installation change l'adresse IP du routeur.
Se reconnecter
Le câble relie toujours le routeur et votre ordinateur, il faut se mettre sur le même réseau que le routeur :
# ifconfig eth0 192.168.1.2
Puis on accède en telnet
# telnet 192.168.1.1
root@asus:~# telnet 192.168.1.1 Trying 192.168.1.1... Connected to 192.168.1.1. Escape character is '^]'. === IMPORTANT ============================ Use 'passwd' to set your login password this will disable telnet and enable SSH ------------------------------------------ BusyBox v1.19.4 (2013-10-03 07:24:50 UTC) built-in shell (ash) Enter 'help' for a list of built-in commands. _______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M ----------------------------------------------------- BARRIER BREAKER (Bleeding Edge, r38294) ----------------------------------------------------- * 1/2 oz Galliano Pour all ingredients into * 4 oz cold Coffee an irish coffee mug filled * 1 1/2 oz Dark Rum with crushed ice. Stir. * 2 tsp. Creme de Cacao ----------------------------------------------------- root@OpenWrt:/#
Une fois connecté la première chose à faire est de changer le mot de passe, cela va activer le SSH et désactiver le telnet :
root@OpenWrt:/# passwd
Une confirmation est demandée, il faut donc saisir deux fois de suite le même mot de passe.
root@OpenWrt:/# passwd Changing password for root New password: Retype password: Password for root changed by root root@OpenWrt:/#
Configuration du routeur
Les paramètres du réseaux vont nous permettre de se reconnecter au routeur mais non plus en telnet mais en SSH.
L'idée est que votre routeur aura accès à internet pendant que vous vous aurez accès au routeur en SSH, pour cela il faut que tout le monde soit sur le même réseau, votre réseau local.
Admettons que notre réseau local soit dans l'adressage suivant 192.168.0.x alors nous allons choisir une adresse fixe pour le routeur, non prise sur le réseau, par exemple 192.168.0.50
Il faut également connaître la passerelle de votre réseau (dans le cas le plus c'est l'adresse de votre boîtier ADSL), ici notre passerelle est 192.168.0.254
Ses paramètres vont nous servir à configurer le routeur pour y avoir accès en SSH.
On est toujours en telnet on édite le fichier /etc/config/network avec la commande vi :
root@OpenWrt:~# vi /etc/config/network
On modifie les paramètres suivants :
option ipaddr ‘192.168.0.50‘ option netmask ’255.255.255.0′ option gateway ‘192.168.0.254‘
On ajoute les paramètres suivants :
list dns ‘192.168.0.254‘ list dns ’8.8.8.8′
Puis il faut éditer les règles de parefeu :
root@OpenWrt:~# vi /etc/config/firewall
Il faut passer les règles des 3 premières sections de REJECT à ACCEPT.
root@OpenWrt:~# vi /etc/config/firewall config defaults option syn_flood 1 option input ACCEPT option output ACCEPT option forward ACCEPT # Uncomment this line to disable ipv6 rules # option disable_ipv6 1 config zone option name lan list network 'lan' option input ACCEPT option output ACCEPT option forward ACCEPT config zone option name wan list network 'wan' list network 'wan6' option input ACCEPT option output ACCEPT option forward ACCEPT option masq 1 option mtu_fix 1 […] on ne touche pas au reste du fichier
On active maintenant le wifi en éditant le fichier /etc/config/wireless
root@OpenWrt:~# vi /etc/config/wireless
Et on passe la variable option disabled 1 à option disabled 0
option disabled 0
La configuration est terminée, on peut se déconnecter ctrl + d et on peut éteindre le routeur !
Installation de l'application PirateBox
Pour l'installation il faut que le routeur soit connecté à internet.
On branche le TP-Link et l'ordinateur sur notre réseau local.
Il faut que notre ordinateur reprenne une adresse du réseau local :
# dhclient eth0
On alimente denouveau électriquement le routeur (USB) et cette fois on se connecte en SSH :
# ssh root@192.168.0.50
Une confirmation de l’authenticité de l'hôte est demandée, il faut répondre yes.
The authenticity of host '192.168.0.50 (192.168.0.50)' can't be established. RSA key fingerprint is 3c:31:f7:cb:7f:94:cb:49:b1:10:b1:ac:f1:55:90:b6. Are you sure you want to continue connecting (yes/no)? yes
Le mot de passe demandé ensuite est celui que nous avons redéfini plus haut avec la commande passwd.
root@machine:/home/user# ssh root@192.168.0.50 The authenticity of host '192.168.0.50 (192.168.0.50)' can't be established. RSA key fingerprint is 3c:31:f7:cb:7f:94:cb:49:b1:10:b1:ac:f1:55:90:b6. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.0.50' (RSA) to the list of known hosts. root@192.168.0.50's password: BusyBox v1.19.4 (2013-10-03 07:24:50 UTC) built-in shell (ash) Enter 'help' for a list of built-in commands. _______ ________ __ | |.-----.-----.-----.| | | |.----.| |_ | - || _ | -__| || | | || _|| _| |_______|| __|_____|__|__||________||__| |____| |__| W I R E L E S S F R E E D O M ----------------------------------------------------- BARRIER BREAKER (Bleeding Edge, r38294) ----------------------------------------------------- * 1/2 oz Galliano Pour all ingredients into * 4 oz cold Coffee an irish coffee mug filled * 1 1/2 oz Dark Rum with crushed ice. Stir. * 2 tsp. Creme de Cacao ----------------------------------------------------- root@OpenWrt:~#
On vérifie que le routeur a bien accès à internet :
root@OpenWrt:/# ping free.fr
Si le routeur n'a pas accès vérifier vos branchements et la configuration réseau du routeur (/etc/config/network).
Il faut ajouter le support USB à notre routeur :
root@OpenWrt:~# opkg update Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/Packages.gz. Updated list of available packages in /var/opkg-lists/barrier_breaker. root@OpenWrt:~# root@OpenWrt:~# opkg install kmod-usb-uhci Installing kmod-usb-uhci (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-usb-uhci_3.10.13-1_ar71xx.ipk. Configuring kmod-usb-uhci. root@OpenWrt:~# root@OpenWrt:~# insmod usbcore kmod: module is already loaded - usbcore root@OpenWrt:~# root@OpenWrt:~# insmod uhci kmod: missing module (null) kmod: failed to insert (null) root@OpenWrt:~# root@OpenWrt:~# opkg install kmod-usb-ohci Package kmod-usb-ohci (3.10.13-1) installed in root is up to date. root@OpenWrt:~# root@OpenWrt:~# insmod usb-ohci kmod: missing module (null) kmod: failed to insert (null) root@OpenWrt:~#
Il se peut que certains insmod ne soient pas possible, on poursuit.
On peut maintenant connecter notre clé USB FAT 32 à notre routeur. Notre clé USB ne doit avoir qu'une seule et même partition.
Dans la fenêtre SSH toujours ouverte, on installe l'application PirateBox :
root@OpenWrt:~# cd /tmp root@OpenWrt:/tmp# opkg update && opkg install http://piratebox.aod-rpg.de/piratebox_0.6.3_all.ipk
Once the install is completed, unplug the ethernet cable and disconnect the power for at least 10 seconds.
5. Restart the device and join the “PirateBox – Share Freely” network. Open any web page and you should be redirected to the PirateBox menu.
root@OpenWrt:/tmp# opkg update && opkg install http://piratebox.aod-rpg.de/piratebox_0.6.3_all.ipk Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/Packages.gz. Updated list of available packages in /var/opkg-lists/barrier_breaker. Downloading http://piratebox.aod-rpg.de/piratebox_0.6.3_all.ipk. Installing piratebox (0.6.3) to root... Installing kmod-usb-storage (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-usb-storage_3.10.13-1_ar71xx.ipk. Installing kmod-scsi-core (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-scsi-core_3.10.13-1_ar71xx.ipk. Installing kmod-fs-vfat (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-fs-vfat_3.10.13-1_ar71xx.ipk. Installing kmod-nls-cp437 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-nls-cp437_3.10.13-1_ar71xx.ipk. Installing kmod-nls-cp850 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-nls-cp850_3.10.13-1_ar71xx.ipk. Installing kmod-nls-iso8859-1 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-nls-iso8859-1_3.10.13-1_ar71xx.ipk. Installing kmod-nls-iso8859-15 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-nls-iso8859-15_3.10.13-1_ar71xx.ipk. Installing kmod-fs-ext4 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-fs-ext4_3.10.13-1_ar71xx.ipk. Installing kmod-lib-crc16 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-lib-crc16_3.10.13-1_ar71xx.ipk. Installing block-mount (2013-09-29-887256e92838ef94eeea8d7ba06ff078c7e05296) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/block-mount_2013-09-29-887256e92838ef94eeea8d7ba06ff078c7e05296_ar71xx.ipk. Installing kmod-loop (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-loop_3.10.13-1_ar71xx.ipk. Installing losetup (2.21.2-2) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/losetup_2.21.2-2_ar71xx.ipk. Configuring kmod-scsi-core. kmod: failed to insert /lib/modules/3.10.13/sd_mod.ko Configuring kmod-usb-storage. Configuring kmod-lib-crc16. Configuring block-mount. Configuring kmod-fs-vfat. Configuring kmod-fs-ext4. kmod: failed to insert /lib/modules/3.10.13/ext4.ko Configuring losetup. Configuring kmod-nls-cp437. Configuring kmod-nls-cp850. Configuring kmod-nls-iso8859-1. Configuring kmod-nls-iso8859-15. Configuring kmod-loop. Configuring piratebox. Please connect USB disk. If it is already plugged-in, wait for a few seconds, and if nothing happens, please reconnect the device. Keep in mind that your router's ports may not be able to supply enough power to spin-up a USB HDD. ..............................................................................................................................................................................................................................................Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/Packages.gz. Updated list of available packages in /var/opkg-lists/barrier_breaker. Downloading http://piratebox.aod-rpg.de/piratebox_0.6.3_all.ipk. Installing piratebox (0.6.3) to root... Installing kmod-usb-storage (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-usb-storage_3.10.13-1_ar71xx.ipk. Installing kmod-scsi-core (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-scsi-core_3.10.13-1_ar71xx.ipk. Installing kmod-fs-vfat (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-fs-vfat_3.10.13-1_ar71xx.ipk. Installing kmod-nls-cp437 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-nls-cp437_3.10.13-1_ar71xx.ipk. Installing kmod-nls-cp850 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-nls-cp850_3.10.13-1_ar71xx.ipk. Installing kmod-nls-iso8859-1 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-nls-iso8859-1_3.10.13-1_ar71xx.ipk. Installing kmod-nls-iso8859-15 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-nls-iso8859-15_3.10.13-1_ar71xx.ipk. Installing kmod-fs-ext4 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-fs-ext4_3.10.13-1_ar71xx.ipk. Installing kmod-lib-crc16 (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-lib-crc16_3.10.13-1_ar71xx.ipk. Installing block-mount (2013-09-29-887256e92838ef94eeea8d7ba06ff078c7e05296) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/block-mount_2013-09-29-887256e92838ef94eeea8d7ba06ff078c7e05296_ar71xx.ipk. Installing kmod-loop (3.10.13-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/kmod-loop_3.10.13-1_ar71xx.ipk. Installing losetup (2.21.2-2) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/losetup_2.21.2-2_ar71xx.ipk. Configuring kmod-scsi-core. kmod: failed to insert /lib/modules/3.10.13/sd_mod.ko Configuring kmod-usb-storage. Configuring kmod-lib-crc16. Configuring block-mount. Configuring kmod-fs-vfat. Configuring kmod-fs-ext4. kmod: failed to insert /lib/modules/3.10.13/ext4.ko Configuring losetup. Configuring kmod-nls-cp437. Configuring kmod-nls-cp850. Configuring kmod-nls-iso8859-1. Configuring kmod-nls-iso8859-15. Configuring kmod-loop. Configuring piratebox. Please connect USB disk. If it is already plugged-in, wait for a few seconds, and if nothing happens, please reconnect the device. Keep in mind that your router's ports may not be able to supply enough power to spin-up a USB HDD. ..................................................................................................................................................................................
Réinstallation du firmware d'origine
Connecter le TP-Link au réseau locale ou brancher le cable directement sur le routeur.
Configurer votre ordinateur pour être sur le même réseau :
# ifconfig eth0 192.168.1.2
Connexion au routeur en SSH :
# ssh root@192.168.1.1
On édite le fichier de configuration réseau pour avoir accès à internet depuis le routeur :
root@4hB7NtLb:~# vi /etc/config/network
On vérifie et change les paramètres :
option ipaddr '192.168.0.50' option gateway '192.168.0.254'
On débranche l'alimentation USB du routeur
Si la connexion réseau était directe entre le PC et le routeur il faut les remettre tous les deux sur le réseau local.
Puis on rebranche l'alimentation USB du routeur.
On se connecte en SSH sur le routeur :
root@asus:/home/user# ssh root@192.168.0.50
Pour que le routeur puisse aller sur internet il faut arrêter le service piratebox :
root@m5c6OCzc:~# /etc/init.d/piratebox stop
On test la connexion réseau :
root@4hB7NtLb:~# ping free.fr
On installe unzip s'il n'y est pas :
root@4hB7NtLb:~# opkg update && opkg install unzip
root@m5c6OCzc:~# opkg update && opkg install unzip Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/Packages.gz. Updated list of available packages in /var/opkg-lists/barrier_breaker. Installing unzip (5.52-1) to root... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/unzip_5.52-1_ar71xx.ipk. Configuring unzip. Configuring piratebox. /etc/rc.common: line 139: /opt/piratebox/init.d/piratebox_router: not found Command failed: Not found /etc/init.d/piratebox: Mounting external USB storage... @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ Caution @@ @@ It seems there is already the file @@ @@ /mnt/usb/PirateBox/OpenWRT.img @@ on your USB Stick @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ This can happen, if you installed a new firmware on your router, or if you did an upgrade of the PirateBox package. If you are upgrading the package, DO NOT overwrite the file! Do you want to reinitiate your USB and overwrite the file? ( y / n) n /etc/init.d/piratebox: Skipping further USB prepare-steps /etc/init.d/piratebox: Creating piratebox loop image... dest piratebox /mnt/ext Check for WAN Connection .. PING google.com (173.194.45.64): 56 data bytes 64 bytes from 173.194.45.64: seq=0 ttl=54 time=35.130 ms 64 bytes from 173.194.45.64: seq=1 ttl=54 time=35.249 ms 64 bytes from 173.194.45.64: seq=2 ttl=54 time=34.522 ms --- google.com ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 34.522/34.967/35.249 ms Installing python from repository Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/Packages.gz. Updated list of available packages in /var/opkg-lists/barrier_breaker. Installing python (2.7.3-2) to piratebox... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/python_2.7.3-2_ar71xx.ipk. Installing libpthread (0.9.33.2-1) to piratebox... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libpthread_0.9.33.2-1_ar71xx.ipk. Installing zlib (1.2.8-1) to piratebox... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/zlib_1.2.8-1_ar71xx.ipk. Installing libffi (3.0.11-1) to piratebox... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/libffi_3.0.11-1_ar71xx.ipk. Installing python-mini (2.7.3-2) to piratebox... Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/python-mini_2.7.3-2_ar71xx.ipk. Configuring libpthread. Configuring zlib. Configuring libffi. Configuring python-mini. Configuring python. Configuring piratebox. /etc/rc.common: line 139: /opt/piratebox/init.d/piratebox_router: not found losetup: /dev/loop0: detach failed: No such device or address Command failed: Not found /etc/init.d/piratebox: Mounting external USB storage... @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ Caution @@ @@ It seems there is already the file @@ @@ /mnt/usb/PirateBox/OpenWRT.img @@ on your USB Stick @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ This can happen, if you installed a new firmware on your router, or if you did an upgrade of the PirateBox package. If you are upgrading the package, DO NOT overwrite the file! Do you want to reinitiate your USB and overwrite the file? ( y / n) n
root@m5c6OCzc:~# cd /tmp On télécharge le firware :
root@m5c6OCzc:~# wget http://www.tp-link.com/Resources/software/TL-MR3020_V1_120320.zip
Une altérnative consiste à télécharger le firmware sur l'ordinateur et à le copier sur le routeur avec scp :
root@/home/user:# scp TL-MR3020_V1_120320.zip root@192.168.0.50:/tmp
On dézippe l'archive :
root@m5c6OCzc:~# unzip TL-MR3020*.zip
On installe le firmware :
root@m5c6OCzc:~# mtd -r write mr3020*up*.bin firmware
Unlocking firmware ... Writing from mr3020nv1_en_3_12_11_up(120320).bin to firmware ... [w] […] on patiente Writing from mr3020nv1_en_3_12_11_up(120320).bin to firmware ... Rebooting ...
On rebranche le routeur en direct sur le PC pour ne pas avoir d'interférence avec la box. Dans un navigateur saisir l'adresse : http://192.168.0.254 Le firmware est celui d'origine.
Liens
Routeur sans fil N 3G/4G portable TL-MR3020 http://www.tp-link.fr/products/details/?model=TL-MR3020
Tutoriel sur le blog de Nicolas Hachet
http://blog.nicolashachet.com/fonctionnement-du-web/tutoriel-installer-une-piratebox-en-images/
TP-Link TL-MR3020 sur le site d'OpenWrt
http://wiki.openwrt.org/toh/tp-link/tl-mr3020
PirateBox DIY – OpenWrt
(en)http://daviddarts.com/piratebox-diy-openwrt/?title=PirateBox_DIY_OpenWrt
http://wiki.labomedia.org/index.php/PirateBox
Auteurs
- Dlareg