How To: iptables example

Posted: April 21, 2011 in FOSS

This is an example script for iptables

# IP addresses

# Subnets

# Flushing all chains
iptables -F
iptables -X

# Setting default filter policy
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP

Read the rest of this entry »


Postfix –

1) Append smtp_generic_maps to Postfix
[root@server1 ~]# echo ‘smtp_generic_maps = hash:/etc/postfix/generic’ >> /etc/postfix/

2) Append the necessary outgoing email masks to Postfix address mapping table
<user>@<your_server> <your_email_address>

[root@server1 ~]# echo ‘root@server1.mydomain.local’ >> /etc/postfix/generic

3) Create lookup table for Postfix address mapping table
[root@server1 ~]# postmap /etc/postfix/generic

4) Restart Postfix to take effect Postfix changes
[root@server1 ~]# /etc/init.d/postfix restart

Mutt –

1) ‘set envelope_from=yes‘ in /etc/Muttrc file

2) Create .muttrc file if it’s not alredy created at your user’s home
[sajithr@server1 ~]$ touch ~/.muttrc

3) Add the necessary masks to ~/.muttrc
set from=”<from_email_address>”
set realname=”<username>”

[sajithr@server1 ~]$ cat ~/.muttrc
set from=”
set realname=”foo, server1″

The following scripts were written to bulk upgrade VMware virtual machines’ hardware from v4 to v7.

After the upgrade of a specific virtual machine, the first NIC adapter is also changed to use the new VMXNET3 adapter. And finally some of the changes are done to the virtual machine configuration to gain maximum performance (disable VM logging, set unlimited CPU and memory reservations)

Download the script collection from here.

The script collection includes three scripts.

Read the rest of this entry »

1)    Extend the LUN from storage array (If you HP EVA, locate the LUN, extend it and finally save the changes). And you need wait a few seconds here (to allow the changes to be identified by the OS) before you proceed with the next step.

2)    Identify the underlying SCSI devices (use multipath -ll to see the underlying devices) and rescan the SCSI devices

[root@zenhat ~]# echo 1 > /sys/block/sds/device/rescan
[root@zenhat ~]# echo 1 > /sys/block/sdr/device/rescan

3)    Drop and add each device path from multipath(no problem, multipath will correctly failover the paths) and resize the related multipath map ( OR reloading the multipathd will do the same job sometimes)

[root@zenhat ~]# multipathd -k
multipathd> del path sds
multipathd> add path sds
multipathd> del path sdr
multipathd> add path sdr
multipathd> resize map dm-23
Read the rest of this entry »

Here’s a Nagios plug-in for backing up Cisco config files to a tftp or a rcp server using cisco-config-copy-mib. The script does support both tftp and rcp, but I need to fix it a bit to work it with rcp properly (rcp server authentication part). AFAIK, Cisco IOS 12.3 has added scp support, so now scp option can also be added.

This will only works under Windows TFTP server as in Unix tftpd, the expected file should be created on the file system before the backup config arrives from Cisco device.

Download the script from this share.

This is a sample kickstart file for VMware ESXi 4.1 installations.

PXE environment is setup under CentOS 5.5-x86_64, with restricted dhcpd (i.e. no free leases), tftp-server and httpd (for hosting installation and some configuration files). Instructions for setting up PXE environment for VMware ESXi 4.1 can be founded here. Here, the typical VMware scripted installation processe has slightly been modified to automatically install multiple hosts simultaneously without any user interaction. The host needs to be *manually* PXE boot. Then it will install OS according to the ks.cfg file and reboot. After the reboot the %firstboot section will execute. During the %firstboot execution, it will look for file, post_install.cfg which includes all the post installation configurations. post_install.cfg requires a file called arp_table to grab the correct IPv4 addresses and hostname(based on vmnic0 MAC address). After executing all post configurations, the host will enter into the maintenance mode and reboots.

According to this setup, all files, ks.cfg, post_install.cfg and arp_table, should be placed under http://<pxe_server>/kickstart directory.

Note: At the time of this writing, in VMware ESXi 4.1 scripted installation, %post section changes are only applied to the pre-boot environment. i.e. the changes you made in %post section will be lost after the first reboot. So %firstboot section is used to make the post installation changes.

Read the rest of this entry »

How To: Setup DBD::Oracle in Ubuntu

Posted: September 11, 2010 in FOSS, How-to

This how-to outlines the setup of Perl-Oracle connectivity under Ubuntu.

  • Install DBI (DBI module should be installed before installing DBD::Oracle)

root@cratlk1:~# perl -MCPAN -e shell

cpan shell — CPAN exploration and modules installation (v1.9402)
Enter ‘h’ for help.

cpan[1]> m DBI
CPAN: Storable loaded ok (v2.21)
Going to read ‘/home/sajithr/.cpan/Metadata’
Database was generated on Tue, 24 Aug 2010 07:47:51 GMT
Module id = DBI
DESCRIPTION  Generic Database Interface (see DBD modules)
CPAN_USERID  TIMB (Tim Bunce <>)
CPAN_FILE    T/TI/TIMB/DBI-1.613.tar.gz
UPLOAD_DATE  2010-07-25
DSLIP_STATUS MmcOp (mature,mailing-list,C,object-oriented,Standard-Perl)
MANPAGE      DBI – Database independent interface for Perl
INST_FILE    /usr/local/lib/perl/5.10.1/

(If it’s not installed, install DBI)

  • Download DBD::Oracle

cpan[2]> get DBD::Oracle

  • Install libaio, libaio-dev (for Oracle instant-client)

root@cratlk1:~# sudo aptitude install libaio libaio-dev

  • Download and install oracle-instant-client-basic and oracle-instant-client-devel

root@cratlk1:~# alien –scripts oracle-instantclient11.2-*.rpm
root@cratlk1:~# sudo dpkg -i *.deb

Read the rest of this entry »