Tuesday, May 5, 2015

Assign additional IP address on the interface

Assign additional IP address on the interface

If you need additional IP address and you have only one interface, you can create a virtual interface and assign the ipaddress.

Make a copy of primary interface.
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
here, 0 is the first instance.

Edit the file and change the device name, ipaddress.
You may want to remove the hostname, UUID info..



Below is a comparison of two files. The one on the left is the original ifcfg-eth0 file, the one on the right is ifcfg-eth0:0 with the changes and deletions.

Restart network services for the additional interface to be activated:
$ sudo service network restart

Verify the new interface is active and has the correct IP. Ex:
$ ifconfig eth0:0
Output should resemble the following:

OLD info NEW info
--------- ---------
DEVICE=eth0 DECVICE=eth0:0
BOOTPROTO=static BOOTPROTO=static
GATEWAY=192.168.10.1 HWADDR=00:00:00:00:00:00
HOSTNAME=sam IPADDR=192.168.10.201
IPADDR=... IPV6INIT=yes
IPV6INIT=yes MTU=1500
MTU=1500 NETMASK=255.155.155.0
NETMASK=255.155.155.0 NM_CONTROLLED=yes
NM_CONTROLLED=yes ONBOOT=yes
ONBOOT=yes TYPE=Ethernet
TYPE=Ethernet
UUID=0000000-0000-2222-2222-000000000000

Now, restart network service
# service network restart
# ifcfg eth0:0

Disk Wipe- Using Darik’s Boot and Nuke tool

Wipe your system disk using Darik’s Boot and Nuke (DBAN)
Version used: 2.7.7

Instructions:

1. Login to the console and boot the system using cd/iso.
   On the tool bar, you will see cd/dvd dropdown list. Select ISO and click mount and mount the DBAN image from your PC.

2. Once you set up to boot the system off the CD, reboot your system.

3. Upon reboot, you will see different options. just press enter to start DBAN on interactive mode.

4. You will be presented with new screen. Press M for the method and pick the one best suites your environment.
a. Quick Erase
b. RCMP TSSIT OPS-II
c. DoD Short
d. DoD 5220-22.M
e. Gutmann Wipe:- For sensetive data.
f. PRNG Stream

select the one and press enter to continue.

5. You will be on different screen where you can select the disk available on the system.
Use arrow key to move and press space bar to select the disk.

6. Press F10 to start the cleaning process. You will see the status about the disk.

Note: DoD short and Gutmann option take a long time to finish the job.
Please allocate enough time based on the size of the disk. [ 10-12 hrs ]

7. Finally your wipe process will be completed soon.

Friday, May 1, 2015

Step by step Guide to create Glusterfs

Plan:
1. Prepare 2 hosts with CentOS 6.3, thats what I am using
Server1: moti.expanor.local
server2: goma.expanor.local

2. Veryfy dns is working, and each host can ping each other.

3. Create a shared disk on both hosts: /opt/home


Software installation:

1. Install glusterfs-server package.
You can set up and repo

download the software
http://download.gluster.org/pub/gluster/glusterfs/

download the repo

# wget -P /etc/yum.repos.d/ http://download.gluster.org/pub/gluster/glusterfs/3.6/3.6.3/CentOS/glusterfs-epel.repo.el5

# yum clean all
# yum install gluster-server
# chkconfig --list | grep glust
# service glusterd start


At this poing, you either disable iptables or enable the port to have a communicate with each other host.
I disabled iptables but you can let running SElinux.

Monday, April 27, 2015

RHEL7- Reset forgot root password

Boot your system and, on the GRUB boot screen, where count begins, press any key and press the e key to edit.
Scroll down with the arrow down key and go to the line where it says "linux16. Go to the end of the line and add the following entry. rd.break selinux=0

--> add " rd.break selinux=0 "  to the end of the linux16 line

Once its added type  ctrl-x  to save and exit.

You will be at the shell prompt. Just type to following commands below to reset the password.

# mount -o remount,rw /sysroot
# chroot /sysroot
# passwd
# exit / exit


Machine reboot's  (selinux = disabled and will be enabled at next reboot) automatically after that.

Note: Run " touch /.autorelabel" command in order to set the SELinux context  ( to update SELinux parameters) of the files to restore properly after reboot.

Tuesday, April 21, 2015

ntp check running as cron job

$ more check_ntpd.sh
#!/bin/sh
###################################################################################
#
#  SCRIPT: check_ntpd.sh
#  Author:  Sam
#  Date:    Fri Apr 17 15:10:02 EDT 2015
#  Usage:   ./check_ntpd.sh
#  Detail:  Include hosts that you want to check ntp status on ntp.chk file and run the script
#  $ more ntp.chk
#  server01
#  server02
#  server03
#  --------------- Change Log ----------------
#
#
###################################################################################
#
for i in `cat ntp.chk`
do
        ssh -tq $i '/usr/bin/sudo tail -50 /var/log/messages | grep -i ntp | grep "slew\|synchronized" | tail -1'
        #ssh -tq $i '/usr/bin/sudo tail -50 /var/log/messages | grep -i ntp | grep "slew\synchronized" | tail -1'
        #echo $i; ssh -tq $i /usr/sbin/ntpdate -q ntp1.ecap.cciio | grep -v stratum |  awk -F] '{print $1"]"}' | tr "\n" " "
        #echo "Checking: $i:"; ssh -tq $i /usr/sbin/ntpdate -q ntp1.ecap.cciio | grep -v stratum |  awk -F] '{print $1"]"}' | tr "\n"
" "
        #ssh -tq $i /usr/sbin/ntpdate -q ntp1.ecap.cciio | grep -v stratum |  awk -F] '{print $1"]"}' | tr "\n" " \t"
        #echo "on host: $i"
        # sudo tail --lines=40 /var/log/messages | grep -i ntp | grep "slew\|synchronized" | tail --lines=1
done

Checking ntp servers

$ cat check_ntp_server.sh
#!/bin/sh
###################################################################################
#      
#  SCRIPT:  Checks Internal and external DNS query.
#  Author:  Sam
#  Date:    Wed Apr 17 07:29 EDT 2015
#  Usage:   Simply run ./check_ntp_server.sh script.
#  Detail:  There is a file ntp.servers which includes ntp servers.
#  $ more ntp.servers
#  ntpserv01
#  ntpserv02
#  ntpserv03
#  ntpserv04    
#
for i in `cat ntp.servers`
do
        echo " "
        echo "Checking $i"
        ssh -q $i /usr/sbin/ntpq -p; echo " ";  echo "Checking FS"; df -h
        #ssh -q $i /usr/sbin/ntpq -p; echo " ";  echo "Checking FS"; df -h; echo ""; echo "Top Output"; top
done

Checking DNS internal and external


$ more chk_dns_record.sh
#!/bin/sh
###################################################################################
#  
#  SCRIPT:  Checks Internal and external DNS query.
#  Author:  Sam                                                                                                            
#  Date:    Wed Apr 15 14:42:55 EDT 2015
#  Usage:   Simply run ./dns_chk_in.sh script.
#  Detail:  There is a file dns.chk for external DNS and dns_chk_in for internal.
#           Add some domain on dns.chk and some host from I-Center on dns_chk_in.
#  $ more  dns.chk      
#  abc.com        
#  yahoo.com      
#  $ more dns_chk_in                                                                                                      
#  myserv1
#  myserv2  
#  --------------- Change Log ----------------
#
#        
###################################################################################
#
echo "Checking Mail Relay"
sleep 2
echo "Checking mail delivery from `hostname`" | mailx -s "Checking Mail Relay" sam@mycompany.com
echo
##############################################
echo "Checking external DNS record"
sleep 2
for i in `cat dns.chk`
do
        nslookup $i | tail -3
done
##############################################
echo "Please wait, checking internal DNS query"
sleep 2
echo
echo "Plase wait, checking DNS query"
rm dns_chk_in.rev
for i in `cat dns_chk_in`
do
        nslookup $i-int.expanor.local | tail -3 | tr "\n"   " "
        echo
        nslookup $i-int.expanor.local | tail -2 | grep -v server | awk '{print $2}'>>dns_chk_in.rev
done
###############################################
echo "Now, checking reverse DNS lookup"
echo
echo "Checking Reverse Look up"
for i in `cat dns_chk_in.rev`
do
        nslookup $i| head -4 | tail -1
done