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.



Tuesday, June 1, 2010

Configure Cisco Router

Last time in the first post, Lock had explained configuration for cisco router setting.

Now I do a simple post with step only..
Mostly the ISP will assign some information such as:

Serial IP : 123.123.123.121
Serial Netmask : 255.255.255.252
LAN IP : 58.123.111.97 until 58.123.111.126
LAN Netmask : 255.255.255.224
Default gateway (IP Route) : 202.188.129.113

Then the setup will be:

en
conf t
hostname routername
username routeruser password 0 routerpassword
line vty 0 4
login local
int fast 0/0
ip address 192.168.1.1 255.255.255.0
ip nat inside
no shutdown
exit
int se 0/1/0
ip address 123.123.123.121 255.255.255.252
ip nat outside
no shutdown
exit
ip route 0.0.0.0 0.0.0.0 123.123.123.122
ip nat pool public 58.123.111.97 58.123.111.97 prefix-length 27
ip nat inside source list private pool public overload
ip access-list standard private
permit 192.168.1.0 0.0.0.255
exit
exit
copy run start

Monday, May 31, 2010

Reset cisco router to factory default

Sometimes.. you may forget the password for cisco router..
or prefer set back to factory default setting..

Then can use this way to reset back..

1. Connect to the cisco router using hyper terminal..
2. Restart the router..
3. Once see booting, press
Ctrl + break
4. you will access to RONMON
5. In ronmon, type
ronmon 1> confreg 0x2142
6. Hit enter and
ronmon 2> reset
7. Wait the router boot, then press "n" and enter, when asked to enter dialogue wizard.
8. Then start tpe the following command
enable
conf t
config-register 0x2102
exit
write erase
press enter
reload

9. That all, you will see the router in factory default setting

Tested on Router 1841.

Monday, May 24, 2010

rc.local in Suse

Suse do not have any rc.local script..
Which this script useful is..
In RedHat, after the init start, it will invoke the command in rc.local..
It is very useful which almost same function with startup in windows..

I had do some google.. and turn out..
This link is a lot helpful..
HERE

1. create a new file named rclocal at /etc/init.d/
vi /etc/init.d/rclocal

2. Then add the the following in the beginning script..
#!/bin/sh
### BEGIN INIT INFO
# Provides: rclocal
# Required-Start: $network $remote_fs
# Required-Stop: $network $remote_fs
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Description: whatever
### END INIT INFO

3. Change mode for the file
chmod 755 /etc/init.d/rclocal

4. add service
chkconfig --add rclocal

Thank all..
Then add the service you need start at the end of the file.

Below is the sample rclocal file I created..



There is some reason the file I created is rclocal instead of rc.local..
In the man innserv, it does not allow files with .local in used..
The error will appear
insserv: script name rc.local is not valid, skipped!

Friday, May 14, 2010

Installation PHP ssh2 extension on PHP5, Apache2

Here is the way for the installation of ssh2 on php5 and apache2..
Here is the document about the ssh2 php..
Try search around the google..Try doing the compilation..
It is working..So here some guide can be use for the installation

Requirements..Installer file for ssh2 and libssh2
1. "wget http://pecl.php.net/get/ssh2-0.11.0.tgz"
2. "wget http://downloads.sourceforge.net/project/libssh2/old-libssh2-releases/1.1/libssh2-1.1.tar.gz?use_mirror=nchc"

First, install libssh2..
1. tar zxf libssh2-1.1.tar.gz
2. cd libssh2-1.1
3. ./configure
4. make
5. make install

Second, install ssh2..
1. tar zxf ssh2-0.11.0.tgz
2. cd ssh2-0.11.0
3. /usr/local/php/bin/phpize
4. ./configure --with-ssh2 --with-php-config=/usr/local/php/bin/php-config
5. make
6. make install
7. make note on the "Installing shared extensions:" directory path which need in below step
Third, change the php.ini file and restart apache..
1. Edit the php.ini file
vi /usr/local/php/lib/php.ini
2. Add this column to the end of php.ini file..
[ssh2]
extension_dir= ssh2 installed library path
extension=ssh2.so
3. save and exit the php.ini
ctrl + c
:wq
4. restart the apache2
/usr/local/apache2/bin/apachectl restart
# if apache cannot be down..
/usr/local/apache2/bin/apachectl graceful

Check the phpinfo, will see ssh2 is enabled..