April 2007 Archives

Creating DNS Pointer Records using C

| 0 Comments | 0 TrackBacks
#include <stdio>
/* creates pointer records */ 

main() 
{ 
 int i; 
 FILE * readfile; readfile=fopen("point.txt","a"); 

 for (i = 150; i <= 250; i++) 
  fprintf(readfile,"%d\t\tIN\tPTR\tdhcp-%d.domain.com.\n",i,i); 
  fclose(readfile); 
} 

Import DiskGroup & Enable

| 0 Comments | 0 TrackBacks
dg="devint_appsdg devint_datadg devint_homedg prod_appsdg prod_datadg prod_homedg" for diskgroup in ${dg} do echo echo Importing the diskgroup $diskgroup .... vxdg import $diskgroup echo Enabling the diskgroup $diskgroup vxrecover -g $diskgroup -sb echo Done importing diskgroup $diskgroup .... done 

Cloning a disk using dd

| 0 Comments | 0 TrackBacks
#!/bin/sh # # To dd copy the bootdisk # # bootdisk=/dev/rdsk/c0t0d0s2 altdisk=/dev/rdsk/c0t1d0s2 echo echo Starting dd of boot disk : ${bootdisk} ... `date +%T` echo echo dd if=${bootdisk} of=${altdisk} bs=65536k echo dd if=${bootdisk} of=${altdisk} bs=65536k echo Finished dd of ${bootdisk} to ${altdisk} ...`date +%T` echo 

Convert password to LDIF password

| 0 Comments | 0 TrackBacks
#!/usr/bin/perl open(PWD, "/etc/passwd") || die "Can't open input file!"; open(LDIF, ">/home/staff/bsung/passwd.ldif") || die "Can't open output file"; while () { ($userid, $pwd, $uid, $gid, $gecos, $homedir, $shell) = split($_, ":"); print LDIF "dn: uid=$userid, ou=People, o=domain.org\n"; print LDIF "objectclass: top\n"; print LDIF "objectclass: account\n"; print LDIF "objectclass: posixaccount\n"; print LDIF "uid: $userid\n"; print LDIF "userPassword: {crypt}$pwd\n"; print LDIF "uidNumber: $uid\n"; print LDIF "gidNumber: $gid\n"; print LDIF "gecos: $gecos\n"; print LDIF "homeDirectory: $homedir\n"; # Blank line needed between records, so two newlines on the last one... print LDIF "loginShell: $shell\n\n"; } close (LDIF); close (PWD); 

Convert /etc/passwd to LDIF

| 0 Comments | 0 TrackBacks
!/bin/ksh -x OUTPUT_FILE=/home/staff/bsung/doit.ldif if [ -f ${OUTPUT_FILE}]; then rm ${OUTPUT_FILE} fi touch ${OUTPUT_FILE} for user in `cat /etc/passwd` do UN="`echo ${user} | cut -d: -f1`" PW="`grep ${UN} /etc/shadow | cut -d: -f2`" UID="`echo ${user} | cut -d: -f3`" GID="`echo ${user} | cut -d: -f4`" GECOS="`echo ${user} | cut -d: -f5`" HD="`echo ${user} | cut -d: -f6`" SHELL="`echo ${user} | cut -d: -f7`" echo "dn: cn=${UN}, ou=People,dc=domain,dc=org" >> ${OUTPUT_FILE} echo "changetype: add" >> ${OUTPUT_FILE} echo "objectclass: top" >> ${OUTPUT_FILE} echo "objectclass: account" >> ${OUTPUT_FILE} echo "objectclass: posixAccount" >> ${OUTPUT_FILE} echo "uid: ${UN}" >> ${OUTPUT_FILE} echo "userpassword: ${PW}" >> ${OUTPUT_FILE} echo "uidnumber: ${UID}" >> ${OUTPUT_FILE} echo "gidnumber: ${GID}" >> ${OUTPUT_FILE} echo "gecos: ${GECOS}" >> ${OUTPUT_FILE} echo "homedirectory: ${HD}" >> ${OUTPUT_FILE} echo "loginshell: ${SHELL}" >> ${OUTPUT_FILE} echo " " >> ${OUTPUT_FILE} echo " " >> ${OUTPUT_FILE} done 

Convert VxVM UFS to VxVM VxFS

| 0 Comments | 0 TrackBacks
Verify the space to convert storvol1 from ufs to vxfs /opt/VRTSvxfs/sbin/vxfsconvert -e /dev/vx/rdsk/storedgedg/storvol1 /opt/VRTSvxfs/sbin/vxfsconvert -e /dev/vx/rdsk/storedgedg/storvol2 Convert storvol1 from ufs to vxfs /opt/VRTSvxfs/sbin/vxfsconvert /dev/vx/rdsk/storedgedg/storvol1 /opt/VRTSvxfs/sbin/vxfsconvert /dev/vx/rdsk/storedgedg/storvol2 Run fsck to clean up the fs fsck -F vxfs -o full -y /dev/vx/rdsk/storedgedg/storvol1 fsck -F vxfs -o full -y /dev/vx/rdsk/storedgedg/storvol2 Verify fs type fstyp /dev/vx/dsk/storedgedg/storvol1 fstyp /dev/vx/dsk/storedgedg/storvol2 Remove plex storvol1-02 from storvol1 vxplex -o rm dis storvol1-02 Remove plex storvol2-02 from storvol2 vxplex -o rm dis storvol2-02 Verify volumes vxprint -ht Remove c5t1d0s2 & c5t1d1S2 disks from storedgedg diskgroup vxdg -g storedgedg rmdisk c5t1d0s2 vxdg -g storedgedg rmdisk c5t1d1S2 Remove the c5t1d0s2 & c5t1d1S2 disks from veritas control vxdisk rm c5t1d0s2 vxdisk rm c5t1d1S2 Console to the T3 array On Mac OS X, Zterm On Solaris, tip hardwire or tip -9600 /dev/ttyb Umount volumes on T3 array vol umount v0 vol umount v1 Remove volumes on T3 array vol remove v0 vol remove v1 Create RAID 7+1 (RAID 5) disk with a hot spare on T3 master vol add v0 data u1d1-8 raid 5 standby u1d9 Create RAID 7+1 (RAID 5) disk with a hot spare on T3 slave vol add v1 data u2d1-8 raid 5 standby u2d9 Reboot system with the reconfigure flag reboot -- -r Verify LUNs can now be reconized format Bring new disks under veritas control to a existing diskgroup called storedgedg, nohotuse vxdiskadd c5t1 Mirror the volume storvol1 to c5t1d0 (verify luns) vxassist -g storedgedg mirror storvol1 c5t1d0 & Mirror the volume storvol2 to c5t1d1 (verify luns) vxassist -g storedgedg mirror storvol2 c5t1d1 & Monitor mirroring progress vxtask list 

Shell script to add users

| 0 Comments | 0 TrackBacks
#/bin/ksh # ID=200 for USER in `cat sun` do echo "Creating sun account for $USER ..." useradd -c Staff -d /home/sun/$USER -g sun -s /bin/ksh -u $ID $USER echo "Assigning default passwords of sun..." passwd $USER sun echo "Creating directory for $USER..." mkdir /home/sun mkdir /home/sun/$USER echo "Setting permissions..." chown -fR $USER:sun /home/sun/$USER chmod 700 /home/sun/$USER (( ID = ID + 1 )) done 

Modify Solaris HostID

| 0 Comments | 0 TrackBacks
#!/bin/sh adb -w -k /dev/ksyms /dev/mem << END hw_serial/W 0x31393230 hw_serial+4/W 0x33383839 hw_serial+8/W 0x36390000 END 
#!/bin/ksh echo "adding queues to local spooler" /opt/hpnpl/hppi -addq -q sa_1 -h sa_1 /opt/hpnpl/hppi -addq -q lab1_1 -h lab1_1 /opt/hpnpl/hppi -addq -q lab2_1 -h lab2_1 /opt/hpnpl/hppi -addq -q admin1_1 -h admin1_1 /opt/hpnpl/hppi -addq -q admin2_1 -h admin2_1 echo "finished." echo "executing lpstat -s" lpstat -s echo "adding default of admin1_1..." echo " " >> /etc/printers.conf echo "_default:\\" >> /etc/printers.conf echo " :use=admin1_1:" >> /etc/printers.conf echo "completed." 

IOS Access Control List

| 0 Comments | 0 TrackBacks
 ! ! remove current access-list 101 no access-list 101 ! ! Permit established connections access-list 101 permit tcp any any established ! ! Permit ssh access-list 101 permit tcp any host 10.0.0.20 eq 22 access-list 101 permit tcp any host 10.0.0.21 eq 22 access-list 101 permit tcp any host 10.0.0.31 eq 22 access-list 101 permit tcp any host 10.0.0.32 eq 22 access-list 101 permit tcp any host 10.0.0.41 eq 22 access-list 101 permit tcp any host 10.0.0.42 eq 22 access-list 101 permit tcp any host 10.0.0.51 eq 22 access-list 101 permit tcp any host 10.0.0.52 eq 22 access-list 101 permit tcp any host 10.0.0.61 eq 22 ! ! Permit email services plus webmail 80 access-list 101 permit tcp any host 10.0.0.20 eq 25 access-list 101 permit tcp any host 10.0.0.20 eq 110 access-list 101 permit tcp any host 10.0.0.20 eq 143 access-list 101 permit tcp any host 10.0.0.20 eq 80 ! ! Permit web services access-list 101 permit tcp any host 10.0.0.41 eq 80 access-list 101 permit tcp any host 10.0.0.51 eq 80 access-list 101 permit tcp any host 10.0.0.41 eq 443 access-list 101 permit tcp any host 10.0.0.51 eq 443 ! ! Permit DNS access-list 101 permit tcp any host 10.0.0.41 eq 53 access-list 101 permit tcp any host 10.0.0.51 eq 53 access-list 101 permit udp any any eq 53 ! ! Permit ident to not slow stuff down access-list 101 permit tcp any any eq 113 ! ! Permit high tcp and udp for streaming media access-list 101 permit tcp any any gt 1023 access-list 101 permit udp any any gt 1023 ! ! Deny everything else and send it the syslog machine access-list 101 deny ip any any log 

Shell script to create LDIF

| 0 Comments | 0 TrackBacks
!/bin/bash touch new-import.ldif for CUST in `cat address-com.txt` do REP_FIRSTNAME="`echo $CUST | cut -d, -f1`" REP_LASTNAME="`echo $CUST | cut -d, -f2`" REP_EMAIL="`echo $CUST | cut -d, -f3`" REP_FULLNAME="$REP_FIRSTNAME$REP_LASTNAME" cat importthis-address-template.ldif | sed -e \ "s/FULLNAME/$REP_FULLNAME/" | \ sed -e "s/FIRSTNAME/$REP_FIRSTNAME/" \ | sed -e "s/LASTNAME/$REP_LASTNAME/" | \ sed -e "s/EMAIL/$REP_EMAIL/" >> new-import.ldif done 

Force Duplex for Linux

| 0 Comments | 0 TrackBacks

Add the following to /etc/sysconfig/network-scripts/ifcfg-eth0 to enable 100 Mbps Full Duplex upon bootup.

ETHTOOL_OPTS="speed 100 duplex full autoneg off" 

Configuring NIC Bonding on CentOS & RHEL

| 0 Comments | 0 TrackBacks
cp /etc/modprobe.conf /etc/modprobe.conf.orig
cat >> /etc/modprobe.conf << EOF
alias bond0 bonding
options bond0 miimon=80 mode=5
EOF
 
cat >  /etc/sysconfig/network-scripts/ifcfg-bond0 << EOF
DEVICE=bond0
IPADDR=192.168.0.2
NETMASK=255.255.255.0
NETWORK=192.168.0.0
BROADCAST=192.168.0.255
GATEWAY=192.168.1.1
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
EOF
 
mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.orig
cat >  /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes
EOF
 
mv /etc/sysconfig/network-scripts/ifcfg-eth1 /etc/sysconfig/network-scripts/ifcfg-eth1.orig
cat >  /etc/sysconfig/network-scripts/ifcfg-eth1 << EOF
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
MASTER=bond0
SLAVE=yes
EOF

Adding swap to Linux

| 0 Comments | 0 TrackBacks
dd if=/dev/zero of=/var/swapfile bs=1024 count=2048000 sync mkswap /var/swapfile swapon /var/swapfile swapon -s echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab 

Configuring SAN Connectivity for Solaris 9

| 0 Comments | 0 TrackBacks
The Sun branded QLogic HBAs require you to install the Sun SAN Software for Solaris 9. Download the software from this link. Uncompress the software, install it via pkgadd and reboot the box:
server01 # uncompress SFS_base_packages.S9.tar.Z
server01 # tar xvf SFS_base_packages.S9.tar
server01 # cd SFS_base_packages.S9
server01 # pkgadd -d .
server01 # reboot
Confirm your HBAs are now seen by Solaris:
server01 # luxadm qlgc
Found Path to 3 FC100/P, ISP2200, ISP23xx Devices Opening 

Device: /devices/pci@9,600000/SUNW,qlc@2/fp@0,0:devctl
Detected FCode Version: ISP2200 FC-AL Host Adapter Driver: 1.15 04/03/22 Opening 

Device: /devices/pci@8,600000/SUNW,qlc@2/fp@0,0:devctl
Detected FCode Version: QLA2462 Host Adapter Driver(SPARC): 1.11 10/03/05 Opening 

Device: /devices/pci@8,600000/SUNW,qlc@2,1/fp@0,0:devctl
Detected FCode Version: QLA2462 Host Adapter Driver(SPARC): 1.11 10/03/05 Complete
Note: If you see ISP2200 FC-AL Host Adapter Driver, that is your internal Fiber-Channel Adapter. For more information, refer to http://developers.sun.com/solaris/articles/fc_drivers_sfs.html.

Other Useful troubleshooting tips:

From the OpenBOOT PROM, type show-devs, probe-scsi-all

From Solaris, luxadm -e qlgc, luxadm -e port, luxadm -e forcelip (reset)

SNEEP (SUNWsneep) Serial Number in EEPROM

| 0 Comments | 0 TrackBacks

SNEEP stands for Serial Number in EEPROM.

The SNEEP tool stores a manually entered Chassis Serial Number (CSN) in the NVRAM portion of the EEPROM, which is available in all currently used Sun Servers. The persistent location of such key information does survive operating system reloads or upgrades, even if the SNEEP package is not installed anymore.

Download SNEEP from http://www.sun.com/download/products.xml?id=4304155a

Using GNU tar to preserve access times

| 0 Comments | 0 TrackBacks

There is a directory of files that you want to tar and untar on to another box but you want to preserve the access times. Use GNU tar:

gtar cvf filename.tar directory_to_be_tarred --atime-preserve
Install the SUNWrsc package
pkgadd -d `pwd` SUNWrsc
Execute the RSC configuration program
/usr/platform/`uname -i`/rsc/rsc-config program
Configure the OpenBOOT PROM to redirect input & output from and to the rsc-console
eeprom input-device=rsc-console eeprom output-device=rsc-console
Done! Now just go ahead and telnet or ssh to the RSC.