Thursday, December 29, 2011

Transfer file via tftp for Cisco, Netscaler and Linux box

Once the TFTP server installed. We have to start do some test to perform the backup..
Here I do face some error or failure when transfering..
Do some twit and tune around and here the some way to do it..
Do advise most of the information do plug from some other blog..
Appreciate for their solution and option..


Now... let's get back to business..
Do notes, my tftp server IP is 192.168.1.250
1. Backup for Cisco devices...

Cisco#write net
This command has been replaced by the command:
'copy system:/running-config '
Address or name of remote host []? 192.168.1.250
Destination filename [ cisco-config ]? cisco-config
Write file tftp://192.168.1.250/cisco-config? [confirm]y!! [OK]
Cisco#


2. Backup for Netscaler devices..
For the netscaler devices, if do not have any function for tftp, then required to login to shell mode of the devices. From there, we required to write 2 script for the backup.

i. Create a folder to store backup script.
mkdir /var/backup

ii. create Script backup.sh - backup all the configuration, license and ssl certificate


#!/bin/sh

cd /nsconfig
tar -zcf /tmp/ns-backup.tar ns.conf license/ ssl/
cd /tmp
tftp < /var/backup/tftp.cmd
rm ns-backup.tar


iii. Create Script tftp.cmd - for run the tftp command


connect 192.168.1.250
binary
put ns-backup.tar
quit

iv. If intent to perform the backup daily, can consider to add a crontab for the script run base on your preference time.


3. Backup for Linux Box..
For this option, I do face some error such as Transfer timed out or nothing transfer. Therefore if face some of the issue, might try to perform some tuning on the client machine.

i. At the client machine add the ip_conntrack_tftp
modprobe ip_conntrack_tftp

ii. Then run tftp to put the file into the server.
root@ client[~]# tftp 192.168.1.250
tftp> put my.cnf
tftp> quit

If intent to do some auto backup, do advise use the same solution as suggest on Netscaler Backup solution.



Install TFTP Server on CentOS

Recently did some new installation on CentOS 5.6 machine with TFTP server..
For more information regarding TFTP, kindly refer to the following link..

My main reason to build a tftp server due to perform some backup server for my Cisco and Netscaler devices..
Been google all day long and at last found few nice written and well explain site that able complete my task..

Here are the steps... *sorry if my English is written in bad way..@@

1. do install tftp server, it will run together with xinetd services.
yum install tftp-server

2. move the tftpboot directory for your own easy maintain purpose. I used to located all my datafile at /var/lib. So will run the command as..
mv /tftpboot/ /var/lib/

3. Change the ownership and folder permission for tftpboot. It will run as nobody user with permission 777..
chown -R nobody:nobody /var/lib/tftpboot/
chmod 777 /var/lib/tftpboot/

4. Edit the tftp file at /etc/xinetd.d/tftp
vi /etc/xinetd.d/tftp

Then add and edit the file to have same line..
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -c -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

For the server_args, change the path to your tftpboot location. Add -c to able creating new file if/no file exist on the tftp server.

5. Start the xinetd service
service xinetd start

6. Able to see the port 69 exist when running
netstat -ntulp

7. Add iptables policy to allow port 69 udp.
-A RH-Firewall-1-INPUT -s (TFTP Subnet) -m udp -p udp --dport 69 -j ACCEPT

That all.. Can try do some file transfer from the client to server..

Will continue in next post.. how the transfer can be done from Cisco, Netscaler and Linux machine to the TFTP Server.