mldonkey mlnet p2p mula emule amule xmule mldonkey-server ====== Mldonkey ====== Se trata de un servidor para redes p2p tales como donkey bittorrent gnutella... ===== Instalación ===== Yo opto por la instalación binaria, que no se cuantas redes soporta: aptitude update && aptitude install mldonkey-server Responder 'Sí'/'Yes' a la pregunta de si se debe ejecutar al arrancar el sistema. ===== Arranque, parada, reinicio ===== Para arrancar mldonkey: sudo /etc/init.d/mldonkey-server start Para comprobar que ha arrancado: ps ax | grep mlnet 13435 ? Dl 1:20 /usr/bin/mlnet -pid /var/run/mldonkey Si hubiera cualquier error en el fichero '/var/lib/mldonkey/downloads.ini', mldonkey no arranca. **SOLUCIÓN** sudo cp /var/lib/mldonkey/old_config/downloads.ini /var/lib/mldonkey/ Para parar mldonkey: sudo /etc/init.d/mldonkey-server stop Para reiniciar mldonkey: sudo /etc/init.d/mldonkey-server restart ===== Configuración ===== Hay tres formas de configurar mldonkey: 1. Mediante una sesión de telnet: telnet 127.0.0.1 4000 2. Editando el fichero de configuración: /etc/init.d/mldonkey-server stop nano /var/lib/mldonkey/downloads.ini Realizar los cambios oportunos. /etc/init.d/mldonkey-server start 3. Mediante la interfaz web (supongo que hay cosas que no se pueden hacer): Abrir un navegador en la misma máquina donde está instalado mldonkey y teclear: http://localhost:4080 Si está definida contraseña para el superusuario aparecerá una ventana pidiendo usuario y contraseña. A continuación vamos a ver un ejemplo de configuración inicial: 1. Conectamos al servidor: telnet 127.0.0.1 4000 **ERROR** Telnet connection from 127.0.0.1 rejected (see allowed_ips setting) Connection closed by foreign host. **SOLUCIÓN**: ver sección 'Errores' al final de éste artículo 2. Le cambiamos la contrasenya: passwd mi_contrasenya > passwd mi_contrasenya Password of user admin changed 3. Permitir acceso de otras ip's, por ejemplo para acceder por el puerto 4080 a la web que administra mldonkey: set allowed_ips "127.0.0.1 192.168.1.30 192.168.1.31" **NOTA**: en mi opinión es mejor dar barra libre a todo el mundo, pues una vez se conecta la servidor de todas formas va a pedir usuario y contraseña: set allowed_ips "0.0.0.0/0" 4. Grabar cambios save 5. Salir de la sesión de telnet exit ===== Cambiar los directorios por defecto ===== Por defecto el paquete 'mldonkey-server' deja los ficheros de configuración y los directorios donde irán a parar las descargas en: /var/lib/mldonkey Fichero de configuración: /var/lib/mldonkey/downloads.ini Existen las siguientes directivas: shared_directories = [ { dirname = "shared" strategy = all_files priority = 0 }; { dirname = "incoming/files" strategy = incoming_files priority = 0 }; { dirname = "incoming/directories" strategy = incoming_directories priority = 0 };] Pero por mucho que he intentado sacar los directorios fuera de '/var/lib/mldonkey' no lo he conseguido. **CHAPUZA** sudo /etc/init.d/mldonkey-server stop mkdir -p /ruta/mldonkey/personal/temp mkdir -p /ruta/mldonkey/personal/incoming/files mkdir -p /ruta/mldonkey/personal/incoming/directories sudo rm -fr /var/lib/mldonkey/incoming sudo rm -fr /var/lib/mldonkey/temp sudo ln -s /ruta/mldonkey/personal/incoming /var/lib/mldonkey/ sudo ln -s /ruta/mldonkey/personal/temp /var/lib/mldonkey/ sudo chown -R mldonkey:mldonkey /var/lib/mldonkey/* /ruta/mldonkey/personal sudo /etc/init.d/mldonkey-server start Para comprobar que arranca: ps ax | grep mlnet 13435 ? Sl 4:27 /usr/bin/mlnet -pid /var/run/mldonkey **POSIBLES ERRORES** Tras ejecutar el 'ps ax | grep mlnet' no vemos ningún proceso, luego no se ha arrancado. **SOLUCIÓN** Revisar los permisos de /ruta/mldonkey/personal/incoming/directories **MEJORAR** No he conseguido, pese a haber movido los fichero de /temp, aprovechar las descargas a medias de una instalación vieja de mldonkey. Quizá porque al mover archivos haya perdido algo ===== Puertos ===== Tema peliagudo, porque sinceramente no se si hace falta mapear puertos en el router, pero lo cierto es que hasta que no los he mapeado, no he tenido id alta. Crear un fichero 'puertos_mldonkey.sh' con el siguiente contenido: #!/bin/bash ####################################################################### # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version # # This program is distributed in the hope that it will be useful # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA ####################################################################### # This script check what networks are enabled/disabled and display port # numbers binded by the clients ####################################################################### # Changelog: # * Sun Aug 08 2004 - v0.3 # - Added an error message when the network configuration file exist # but no port number was found. # # * Sat Aug 07 2004 - v0.2 # - Bugfix, ${BASEDIR} was missing when calling the findPort() function # - Code cleanup # # * Sat Aug 07 2004 - v0.1 # - Initial Release ####################################################################### # (C)2004/08 - GCN (http://gcnweb.free.fr/) - gcnweb(at)free(dot)fr ####################################################################### ## Some vars # MLDonkey config dir BASEDIR="/var/lib/mldonkey/" ########### YOU SHOULD NOT MODIFY SOMETHING BELOW THIS LINE ########### # Colors and positionning MOVE_TO_COL="\\033[22G" COLOR_ENABLED="\\033[1;32m" COLOR_DISABLED="\\033[1;31m" COLOR_WARNING="\\033[1;33m" COLOR_NORMAL="\\033[0;39m" # MLDonkey main configuration file MAINCFGFILE="${BASEDIR}downloads.ini" ## Network section cnt=0 # NAME == Network name # GSECTION == Section name in the main configuration file # FILE == Network's configuration file # FESCTION == Section name in the network configuration file # TCP == Unused # UDP == Tell if the network also needs UDP # value: 0 => UDP not used # value: 1 => UDP used. Port number is equal to TCP Port # value: +/-xxx => UDP port value is +/- relative to TCP port # BitTorrent - Client let cnt++ NAME[$cnt]="BitTorrent [Client]" GSECTION[$cnt]="enable_bittorrent" FILE[$cnt]="${BASEDIR}bittorrent.ini" FSECTION[$cnt]="client_port" TCP[$cnt]=1 UDP[$cnt]=0 # BitTorrent - Tracker let cnt++ NAME[$cnt]="BitTorrent [Tracker]" GSECTION[$cnt]="enable_bittorrent" FILE[$cnt]="${BASEDIR}bittorrent.ini" FSECTION[$cnt]="tracker_port" TCP[$cnt]=1 UDP[$cnt]=0 # Direct Connect let cnt++ NAME[$cnt]="Direct Connect" GSECTION[$cnt]="enable_directconnect" FILE[$cnt]="${BASEDIR}directconnect.ini" FSECTION[$cnt]="client_port" TCP[$cnt]=1 UDP[$cnt]=1 # eDonkey 2000 let cnt++ NAME[$cnt]="eDonkey 2000" GSECTION[$cnt]="enable_donkey" FILE[$cnt]="${BASEDIR}donkey.ini" FSECTION[$cnt]="port" TCP[$cnt]=1 UDP[$cnt]=+4 # FastTrack let cnt++ NAME[$cnt]="FastTrack" GSECTION[$cnt]="enable_fasttrack" FILE[$cnt]="${BASEDIR}fasttrack.ini" FSECTION[$cnt]="client_port" TCP[$cnt]=1 UDP[$cnt]=0 # Gnutella let cnt++ NAME[$cnt]="Gnutella" GSECTION[$cnt]="enable_gnutella" FILE[$cnt]="${BASEDIR}gnutella.ini" FSECTION[$cnt]="client_port" TCP[$cnt]=1 UDP[$cnt]=1 # Gnutella2 let cnt++ NAME[$cnt]="Gnutella2" GSECTION[$cnt]="enable_gnutella2" FILE[$cnt]="${BASEDIR}gnutella2.ini" FSECTION[$cnt]="client_port" TCP[$cnt]=1 UDP[$cnt]=1 # Open Napster let cnt++ NAME[$cnt]="Open Napster" GSECTION[$cnt]="enable_opennap" FILE[$cnt]="${BASEDIR}opennap.ini" FSECTION[$cnt]="client_port" TCP[$cnt]=1 UDP[$cnt]=0 # Overnet let cnt++ NAME[$cnt]="Overnet" GSECTION[$cnt]="enable_overnet" FILE[$cnt]="${BASEDIR}donkey.ini" FSECTION[$cnt]="overnet_port" TCP[$cnt]=1 UDP[$cnt]=1 # SoulSeek let cnt++ NAME[$cnt]="SoulSeek" GSECTION[$cnt]="enable_soulseek" FILE[$cnt]="${BASEDIR}soulseek.ini" FSECTION[$cnt]="client_port" TCP[$cnt]=1 UDP[$cnt]=0 ## Functions # Test if a network is Enabled / Disabled # $1 == Option Name # $2 == File Name function checkNetwork() { grep "^\ *$1\ *=\ *\(true\|false\)" $2 | sed -e 's/^.*\(true\|false\)$/\1/' } # Find the reserved port number # $1 == Option Name # $2 == File Name function findPort() { grep "^\ *$1\ *=\ *[0-9]*$" $2 | sed -e 's/^.*\ *=\ *\([0-9]*\)$/\1/' } # # Main Routine # echo -e "\nChecking MLDonkey configuration files:\n" for (( i=1; $i <= $cnt; i++ )); do echo -en "${NAME[$i]}${MOVE_TO_COL}: " VALUE=`checkNetwork ${GSECTION[$i]} ${MAINCFGFILE}` # If $VALUE == True, check if the configuration file exists if [ "$VALUE" == "true" ]; then if [ ! -f ${FILE[$i]} ]; then echo -en ${COLOR_WARNING} echo -en "WARNING Configuration file \"${FILE[$i]}\" is missing" echo -e ${COLOR_NORMAL} else # Assume there is _ALWAYS_ a TCP port PORTNUMBER=`findPort ${FSECTION[$i]} ${FILE[$i]}` if [ "x${PORTNUMBER}" == "x" ]; then echo -en ${COLOR_WARNING} echo -en "WARNING No ports found in the file \"${FILE[$i]}\"" echo -e ${COLOR_NORMAL} else echo -en ${COLOR_ENABLED} echo -en "ENABLED " echo -en "${COLOR_NORMAL} [" echo -n "TCP: ${PORTNUMBER}" # Check if a UDP port exists and display it if [ ${UDP[$i]} -eq 1 ]; then echo -n " / UDP: ${PORTNUMBER}" elif [ ${UDP[$i]} -ne 0 ]; then # echo -n " / UDP: $(( ${PORTNUMBER} ${UDP[$i]} ))" echo -n " / UDP: ${UDP[$i]}" fi echo "]" fi fi else echo -en ${COLOR_DISABLED} echo -en "DISABLED" echo -e ${COLOR_NORMAL} fi done Darle permisos de ejecución: chmod +x puertos_mldonkey.sh Y ejecutarlo como root: ./puertos_mldonkey Al loro con la salida, porque puede haber saltos de linea. Ir al router y mapear esos puertos en la sección 'NAT'. Por último reiniciar mldonkey: /etc/init.d/mldonkey-server restart Debería aparecer, en la sección 'Servers' la tan ansiada 'Id HI' ===== Redes ===== Los comandos para habilitar las distintas redes: set enable_opennap "true" set enable_kademlia "true" set enable_opennap "true" set enable_soulseek "true" set enable_gnutella "true" set enable_gnutella2 "true" set enable_fasttrack "true" set enable_directconnect "true" set enable_fileTP "true" **AVISO** Se requiere los siguientes ficheros: FastTrack : WARNING Configuration file "/var/lib/mldonkey/fasttrack.ini" is missing Gnutella : WARNING Configuration file "/var/lib/mldonkey/gnutella.ini" is missing Gnutella2 : WARNING Configuration file "/var/lib/mldonkey/gnutella2.ini" is missing Open Napster : WARNING Configuration file "/var/lib/mldonkey/opennap.ini" is missing Overnet : WARNING No ports found in the file "/var/lib/mldonkey/donkey.ini" SoulSeek : WARNING Configuration file "/var/lib/mldonkey/soulseek.ini" is missing ===== Servidores ===== Para la red eDonkey: 1. Acceder vía telnet a mldonkey: telnet 127.0.0.1 4000 auth admin "mi_contrasenya" 2. Lanzar los siguientes comandos: set ED2K-update_server_list_client false set ED2K-update_server_list_server false set ED2K-update_server_list_server_met true urladd server.met http://www.gruk.org/server.met 36 urladd server.met HTTP://WWW.PEERATES.NET/SERVERS.PHP 36 rem all force_web_infos server.met Ni p... idea de lo que hace 3. Grabar y salir (no sé si es necesario) save exit ===== Ancho de banda ===== Para fijar un ancho de banda de subida ilimitado: set max_hard_upload_rate 0 Para fijar un ancho de banda de bajada ilimitado: set max_hard_download_rate 0 ===== Usuarios ===== ==== Para crear un usuario desde la interfaz web ==== 1. Entrar en la interfaz web http://mi_url.com:4080 2. Introducir usuario y contraseña del administrador 3. Pulsar en el botón 'Options' de la primera fila de opciones 4. Pulsar en el botón 'Users' de la segunda fila de opciones 5. Pulsar en el botón 'Add user' un poco debajo de la segunda fila de opciones 6. En la ventana que nos ha aparecido, teclear los siguientes valores, separados por un espacio: mi_usuario contrasenya usuarios usuarios/mi_usuario Y pulsar sobre el botón 'Aceptar' **Comprobar**: debe crear el siguiente directorio: /var/lib/mldonkey/incoming/files/usuarios/mi_usuario 7. Para probar que funciona, borrar datos personales del navegador, cerrarlo, abrirlo, paso 1 y en el paso 2 teclear los datos suministrados en el paso 6 ==== Crear usuario desde linea de comandos ==== Nos conectamos a mldonkey: # telnet localhost 4000 Trying ::1... Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Welcome to MLDonkey 3.0.3 Welcome on mldonkey command-line Use ? for help Nos logamos como admin: > auth admin contrasenya Full access enabled Listar usuarios: > users User Admin Groups Dgroup Email Commit dir Max dls Dls admin true mldonkey mldonkey unlimited 2 Group Admin Members Downloads mldonkey true 1 2 useradd Por ejemplo: useradd usuario contrasenya users . probando@correo.com Añadir usuarios: useradd usuario contrasenya Cambiar el correo: usermail usuario correo@dominio.com ===== Enviar un correo informando de que la descarga finalizó ===== **REQUISITOS** Tener configurado un [[http://wiki.legido.com/doku.php?id=informatica:linux:mail:postfix&s=smtp|servidor de correo]] (Mediante interfaz web) 1. Abrir una navegador (Mozilla firefox...) 2. Teclear la dirección del servidor y pulsar 'enter': http://mi_servidor:4080 3. Introducir usuario y contraseña 4. Pulsar sobre el botón 'Options' en la primera fila de opciones 5. Pulsar sobre el enlace 'Mail', en la tercera fila de opciones 6. Teclear la dirección de correo en la caja de texto justo a la izquierda de 'mail' y pulsar 'enter'. A partir de ahora recibiremos un correo en esa dirección cuando se complete la descarga de cualquier fichero añadido por cualquier usuario a la mula. ===== Bittorrent ===== 1. Descargar el archivo .bittorrent **en el servidor** (si, es un toston) 2. En la interfaz grafica (http://localhost:4080) teclear en la ventana justo a la derecha de "DL": dllink /ruta/archivo.torrent Y pulsar "Enter" ===== Cortafuegos ===== IF=ppp0 IPTABLES=/sbin/iptables MLDONKEY_HOST=192.168.1.2 EDONKEY_PORT=4662 KAD_PORT=8443 OVERNET_PORT=5865 BITTORRENT_PORT=6882 OPENNAP_PORT=9999 ## MLDonkey acting as Edonkey2000 client $IPTABLES -I FORWARD -p tcp --dport $EDONKEY_PORT -j ACCEPT $IPTABLES -I FORWARD -p udp --dport $(($EDONKEY_PORT + 4)) -j ACCEPT $IPTABLES -t nat -I PREROUTING -i $IF -p tcp --dport $EDONKEY_PORT -j DNAT --to-destination $MLDONKEY_HOST $IPTABLES -t nat -I PREROUTING -i $IF -p udp --dport $(($EDONKEY_PORT + 4)) -j DNAT --to-destination $MLDONKEY_HOST ## MLDonkey acting as Kad client $IPTABLES -I FORWARD -p tcp --dport $KAD_PORT -j ACCEPT $IPTABLES -I FORWARD -p udp --dport $KAD_PORT -j ACCEPT $IPTABLES -t nat -I PREROUTING -i $IF -p tcp --dport $KAD_PORT -j DNAT --to-destination $MLDONKEY_HOST $IPTABLES -t nat -I PREROUTING -i $IF -p udp --dport $KAD_PORT -j DNAT --to-destination $MLDONKEY_HOST ## MLDonkey acting as Overnet client $IPTABLES -I FORWARD -p tcp --dport $OVERNET_PORT -j ACCEPT $IPTABLES -I FORWARD -p udp --dport $OVERNET_PORT -j ACCEPT $IPTABLES -t nat -I PREROUTING -i $IF -p tcp --dport $OVERNET_PORT -j DNAT --to-destination $MLDONKEY_HOST $IPTABLES -t nat -I PREROUTING -i $IF -p udp --dport $OVERNET_PORT -j DNAT --to-destination $MLDONKEY_HOST ## MLDonkey acting as BitTorrent client $IPTABLES -I FORWARD -p tcp --dport $BITTORRENT_PORT -j ACCEPT $IPTABLES -t nat -I PREROUTING -i $IF -p tcp --dport $BITTORRENT_PORT -j DNAT --to-destination $MLDONKEY_HOST ## MLDonkey acting as OpenNap client $IPTABLES -I FORWARD -p tcp --dport $OPENNAP_PORT -j ACCEPT $IPTABLES -t nat -I PREROUTING -i $IF -p tcp --dport $OPENNAP_PORT -j DNAT --to-destination $MLDONKEY_HOST ## Mula manual iptables -A INPUT -i $INTERFAZ -p tcp --dport 13861 -j ACCEPT iptables -A INPUT -i $INTERFAZ -p udp --dport 13861 -j ACCEPT ===== Errores ===== telnet localhost 4000 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. Telnet connection from 127.0.0.1 rejected (see allowed_ips setting) Connection closed by foreign host. **Solución**: 1. Parar el servidor: sudo /etc/init.d/mldonkey-server stop 2. Editar: sudo vim /var/lib/mldonkey/downloads.ini Y dejar las lineas tal que así: allowed_ips = [ "127.0.0.0/8";] Grabar y salir 3. Arrancar de nuevo: sudo /etc/init.d/mldonkey-server start 4. Probar de nuevo: telnet localhost 4000 ==== Error "Too many open files" ==== Nos conectamos a la consola de mldonkey: # telnet localhost 4000 Ponemos el usuario > auth admin xxxxxx Full access enabled Miramos configuración: > runinfo --Runinfo-- MLDonkey user: admin (PW Protected) - uptime: 9m 57s - running as mldonkey:mldonkey Enabled nets: Donkey BitTorrent FileTP Server usage: enabled Geoip: enabled, GeoLite data created by MaxMind, available from http://maxmind.com/ IP blocking: no blocking list loaded System info: Linux donquixot 2.6.32-5-686 #1 SMP Fri Dec 10 16:12:40 UTC 2010 i686 language: EN - locale: UTF-8 - UTC offset: +0100 max_string_length: 16777211 - word_size: 32 - max_array_length: 4194303 - max_int: 1073741823 max file descriptors: 1024 - max useable file size: 2^63-1 bits (do the maths ;-p) Miramos ulimit > debug_rlimit cpu -1 -1 fsize -1 -1 data -1 -1 stack 8388608 -1 core 0 -1 rss -1 -1 nprof -1 -1 nofile 1024 1024 memlock 65536 65536 as -1 -1 Para cambiarlo en caliente hacemos: # ulimit -n 2048 Para modificarlo para el usuario (se necesita reiniciar) editamos el fichero: /etc/security/limits.conf mldonkey hard nofile 2048 mldonkey soft nofile 2048 Para aber cuantos ficheros tenemos abiertos: Sacamos el proceso del mldonkey: # ps -ef | grep mldonkey mldonkey 12895 1 4 18:46 ? 00:01:10 /usr/bin/mlnet -log_file /var/log/mldonkey/mlnet.log -pid /var/run/mldonkey Miramos ficheros abiertos: # lsof -p 12895 | wc -l 212