jueves, 7 de marzo de 2013

Servidor TFTP en Ubuntu con permisos de escritura

Mucho hardware de red todavía utiliza TFTP para subir y bajar configuraciones y para copiar firmware, etc.
Existen pequeños programas para windows que como administrador de sistemas te sacan del apuro cundo los necesitas, pero en este articulo trataremos de explicar como configurar un servidor TFTP en Ubuntu.


Elegimos tftpd-hpa por que no tiene limitacion de 32MB (atftpd la tiene) y por que permite que utilicemos los comandos put y get.

Instalamos el cliente tftp, y los demonios tftpd-hpa y xinetd
apt-get install tftp tftpd-hpa xinetd

Una vez instalado configuramos los siguiente archivos de la siguiente manera:
root@hostname:~# nano /etc/default/tftpd-hpa
# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
#la opción --create es la que permite                               #que se puedan crear archivos cuando realizamos put
TFTP_OPTIONS="--secure --create"



root@hostname:~#nano /etc/inetd.conf
#FIJAROS QUE ESTA TODO COMENTADO
# /etc/inetd.conf:  see inetd(8) for further informations.
#
# Internet superserver configuration database
#
#
# Lines starting with "#:LABEL:" or "#<off>#" should not
# be changed unless you know what you are doing!
#
# If you want to disable an entry so it isn't touched during
# package updates just comment it out with a single '#' character.
#
# Packages should modify this file by using update-inetd(8)
#
# <service_name> <sock_type> <proto> <flags> <user> <server_path> <args>
#
#:INTERNAL: Internal services
#discard                stream  tcp     nowait  root    internal
#discard                dgram   udp     wait    root    internal
#daytime                stream  tcp     nowait  root    internal
#time           stream  tcp     nowait  root    internal
#:STANDARD: These are standard services.
#:BSD: Shell, login, exec and talk are BSD protocols.
#:MAIL: Mail, news and uucp services.
#:INFO: Info services
#:BOOT: TFTP service is provided primarily for booting.  Most sites
#       run this only on machines acting as "boot servers."
#:RPC: RPC based services
#:HAM-RADIO: amateur-radio services
#:OTHER: Other services

Por si acaso alguno tiene iniciativa recordar que NO hay que crear un archivo dentro de la ruta /etc/xinet.d/tftpd o algo parecido

A continuación creamos los directorios necesarios y asignamos los  permisos adecuados.
root@hostname:~# sudo mkdir /var/lib/tftpboot
root@hostname:~# sudo chmod -vfR 777 /var/lib/tftpboot
root@hostname:~# sudo chown -vfR tftp:tftp /var/lib/tftpboot

Reiniciamos los servicios
root@hostname:~# sudo service xinetd stop;sudo service tftpd-hpa stop;sudo service tftpd-hpa start;sudo service xinetd start

Comprobamos que se esta ejecutando el servicio TFTPD
root@hostname:~# ps -aux | grep tftpd
root     29285  0.0  0.0  15088   332 ?        Ss   20:07   0:00 /usr/sbin/in.tftpd --listen --user tftp --address 0.0.0.0:69 --secure --create /var/lib/tftpboot
root@hostname:~# netstat -nap | grep tftp
udp        0      0 0.0.0.0:69              0.0.0.0:*                           29285/in.tftpd
unix  2      [ ]         DGRAM                    98078    29285/in.tftpd

Ahora podemos probar el tftp con el cliente
root@hostname:~# tftp 127.0.0.1
tftp> ?
Commands may be abbreviated.  Commands are:

connect         connect to remote tftp
mode            set file transfer mode
put             send file
get             receive file
quit            exit tftp
verbose         toggle verbose mode
trace           toggle packet tracing
status          show current status
binary          set mode to octet
ascii           set mode to netascii
rexmt           set per-packet retransmission timeout
timeout         set total retransmission timeout
?               print help information
tftp> get prueba1.txt
Received 9350 bytes in 0.0 seconds
tftp> put prueba2.txt
Sent 9350 bytes in 0.0 seconds

tftp> quit




No hay comentarios: