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.


Friday, September 9, 2011

Change UserID (uid) and GroupID (gid) in Linux

In case, required to change certain user uid and gid in Linux. We can editing the /etc/passwd will be sufficient. But going to face some serious issue on the file permission which been associate with the user.

For example, changing the uid and gid for mysql user daemon. May face MySQL directory not working or cant start the mysql services. Same applied to apache or whatever services daemon.

So, here the step can use to solve all the headache.
Existing zabbix user uid and gid from /etc/passwd
zabbix:x:1008:1008::/home/zabbix:/bin/bash

New uid and gid for zabbix is 300:300

1. Change the uid and gid:
groupmod -g 300 zabbix
usermod -u 300 -g 300 zabbix

2. Find all directory and change to new uid and gid:
find / -user 1008 -print0 | xargs -0 chown -h 300
find / -group 1008 -print0 | xargs -0 chgrp -h 300

That all.. job done.