Wednesday, July 23, 2014

Built a server on VMware but could not connect to the network


Built a server on VMware but could not connect to the network

Issue: Server was on right VLAN and it has right ip address, subnet mask, gateway but still unable to connect to the network.
Solution,
Basically, it was not recognizing the Vlan. You have to remove it from there and reassign it to the NIC will resolve the issue. Sometimes a reboot will take care of it
Steps.
1. On Vsphere Summary page, Click on Edit Settings.
2. Click on a box next to Network Adapter
3. You will see list of VLANs
3. Select any other VLAN and click ok.
4. Go back to the setting and click the right VLAN and click ok.
5. Now, Server should be connected to the network.
6. If not reboot your machine. 

Friday, July 18, 2014

ext3 filessytem extention issue .

Task: Extend the filesystem by 20GB
OS: Redhat 5.10
Issue: Unable to extend the filesystem.
Solution: Had to unmount the filesystem and fsck the filesystem. Remount worked fine.

Error message recerived,
[root@aiglxapp22 ~]# resize2fs /dev/mapper/DB2-VG-UDB--USERTEMP
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/DB2-VG-UDB--USERTEMP is mounted on /udb/usertemp; on-line resizing requir
Performing an on-line resize of /dev/mapper/DB2-VG-UDB--USERTEMP to 10485760 (4k) blocks.
resize2fs: Inappropriate ioctl for device While trying to add group #160
brief tasks performed and solution.
[root@aiglxapp22 ~]# echo "- - -">/sys/class/scsi_host/host3/scan
[root@aiglxapp22 ~]# fdisk -l
[root@aiglxapp22 ~]# fdisk /dev/sdg
[root@aiglxapp22 ~]# pvcreate /dev/sdg1
[root@aiglxapp22 ~]# vgextend UDB-MISC /dev/sdg1
[root@aiglxapp22 ~]# lvextend  -L 20G /dev/mapper/DB2-VG-UDB--USERTEMP
[root@aiglxapp22 ~]# vgs
[root@aiglxapp22 ~]# resize2fs /dev/mapper/DB2-VG-UDB--USERTEMP
[root@aiglxapp22 ~]# df -h /udb/usertemp
[root@aiglxapp22 ~]# lvs
[root@aiglxapp22 ~]# resize2fs /dev/mapper/DB2-VG-UDB--USERTEMP
[root@aiglxapp22 ~]# cat /etc/redhat-release
[root@aiglxapp22 ~]# dmesg

fstab has ext4 instead ext3, changed but got the same error.
[root@aiglxapp22 ~]# vi /etc/fstab
[root@aiglxapp22 ~]# mount -o remount /udb/usertemp
[root@aiglxapp22 ~]# df -h /udb/usertemp
[root@aiglxapp22 ~]# resize2fs /dev/mapper/DB2-VG-UDB--USERTEMP
still same error
[root@aiglxapp22 ~]# fuser /udb/usertemp
[root@aiglxapp22 ~]# umount /udb/usertemp
[root@aiglxapp22 ~]# lvscan
[root@aiglxapp22 ~]# e2fsck /dev/mapper/DB2-VG-UDB--USERTEMP
[root@aiglxapp22 ~]# e2fsck -f /dev/mapper/DB2-VG-UDB--USERTEMP
[root@aiglxapp22 ~]# mount /udb/usertemp
[root@aiglxapp22 ~]# df -h /udb/usertemp
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/DB2-VG-UDB--USERTEMP
                       40G   16G   23G  41% /udb/usertemp

====================== Detail ===================
# dmesg
............
acpiphp: Slot [228] registered
acpiphp: Slot [229] registered
acpiphp: Slot [230] registered
acpiphp: Slot [231] registered
acpiphp: Slot [257] registered
acpiphp: Slot [258] registered
acpiphp: Slot [259] registered
acpiphp: Slot [260] registered
acpiphp: Slot [261] registered
acpiphp: Slot [262] registered
acpiphp: Slot [263] registered
e1000: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None
SCSI device sdb: 65011712 512-byte hdwr sectors (33286 MB)
sdb: Write Protect is off
sdb: Mode Sense: 61 00 00 00
sdb: cache data unavailable
sdb: assuming drive cache: write through
 sdb: sdb1
SCSI device sdb: 65011712 512-byte hdwr sectors (33286 MB)
sdb: Write Protect is off
sdb: Mode Sense: 61 00 00 00
sdb: cache data unavailable
sdb: assuming drive cache: write through
 sdb: sdb1
EXT4-fs (dm-5): mounted filesystem with ordered data mode
EXT4-fs (dm-4): mounted filesystem with ordered data mode
EXT4-fs (dm-6): mounted filesystem with ordered data mode
EXT4-fs (dm-7): mounted filesystem with ordered data mode
EXT4-fs (dm-8): mounted filesystem with ordered data mode
EXT4-fs (dm-9): mounted filesystem with ordered data mode
EXT4-fs (dm-10): mounted filesystem with ordered data mode
EXT4-fs (dm-11): mounted filesystem with ordered data mode
EXT4-fs (dm-12): mounted filesystem with ordered data mode
EXT4-fs (dm-13): VFS: Can't find ext4 filesystem
EXT4-fs (dm-13): mounted filesystem with ordered data mode
JBD: barrier-based sync failed on dm-13-8 - disabling barriers
JBD: barrier-based sync failed on dm-7-8 - disabling barriers
JBD: barrier-based sync failed on dm-11-8 - disabling barriers
JBD: barrier-based sync failed on dm-9-8 - disabling barriers
JBD: barrier-based sync failed on dm-12-8 - disabling barriers
JBD: barrier-based sync failed on dm-8-8 - disabling barriers
JBD: barrier-based sync failed on dm-4-8 - disabling barriers
JBD: barrier-based sync failed on dm-6-8 - disabling barriers
JBD: barrier-based sync failed on dm-5-8 - disabling barriers
JBD: barrier-based sync failed on dm-10-8 - disabling barriers
svc: unknown version (-1 for prog 100021 lockd)
svc: unknown version (-1 for prog 100021 lockd)
  Vendor: VMware    Model: Virtual disk      Rev: 1.0
  Type:   Direct-Access                      ANSI SCSI revision: 02
 target3:0:1: Beginning Domain Validation
 target3:0:1: Domain Validation skipping write tests
 target3:0:1: Ending Domain Validation
 target3:0:1: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 127)
SCSI device sdg: 41943040 512-byte hdwr sectors (21475 MB)
sdg: Write Protect is off
sdg: Mode Sense: 61 00 00 00
sdg: cache data unavailable
sdg: assuming drive cache: write through
SCSI device sdg: 41943040 512-byte hdwr sectors (21475 MB)
sdg: Write Protect is off
sdg: Mode Sense: 61 00 00 00
sdg: cache data unavailable
sdg: assuming drive cache: write through
 sdg: unknown partition table
sd 3:0:1:0: Attached scsi disk sdg
sd 3:0:1:0: Attached scsi generic sg6 type 0
SCSI device sdg: 41943040 512-byte hdwr sectors (21475 MB)
sdg: Write Protect is off
sdg: Mode Sense: 61 00 00 00
sdg: cache data unavailable
sdg: assuming drive cache: write through
 sdg: sdg1
SCSI device sdg: 41943040 512-byte hdwr sectors (21475 MB)
sdg: Write Protect is off
sdg: Mode Sense: 61 00 00 00
sdg: cache data unavailable
sdg: assuming drive cache: write through
 sdg: sdg1
[root@aiglxapp22 ~]# pwd
/root
[root@aiglxapp22 ~]# cat /etc/fstab
/dev/root_VG/ROOT        /                       ext3    defaults        1 1
/dev/root_VG/VAR         /var                    ext3    defaults        1 2
/dev/root_VG/TMP         /tmp                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/root_VG/SWAP        swap                    swap    defaults        0 0
#############################################################################
#############################################################################
/dev/root_VG/OPT-IBM             /opt/ibm                ext4    defaults        1 2
/dev/UDB-MISC/UDB-XINSD         /udb/home/udbxinsd      ext4    defaults        1 2
/dev/root_VG/DBS-UDB            /dbs/udb               ext4    defaults        1 2
/dev/DATA/UDB-DATA              /udb/data               ext4    defaults        1 2
/dev/DATA2/UDB-DATA2            /udb/data2              ext4    defaults        1 2
/dev/LOG/UDB-LOG                /udb/log                ext4    defaults        1 2
/dev/UDB-MISC/UDB-USERTEMP      /udb/usertemp           ext4    defaults        1 2
/dev/UDB-MISC/UDB-SYSTEMP       /udb/systemp            ext4    defaults        1 2
/dev/UDB-MISC/UDB-DIAG          /udb/diag               ext4    defaults        1 2
/dev/UDB-MISC/UDB-SYSCAT        /udb/syscat             ext4    defaults        1 2
he3vtl106-bk:/backup/dbdump/udb /dbsdata/database_backup  nfs rw,bg,hard,nointr,rsize=32768,wsize=32768,nolock,tcp,timeo=600 0 0
[root@aiglxapp22 ~]# mkf
mkfifo       mkfs         mkfs.cramfs  mkfs.ext2    mkfs.ext3
[root@aiglxapp22 ~]# vi /etc/fstab
[root@aiglxapp22 ~]# resize2fs /dev/mapper/DB2-VG-UDB--USERTEMP
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/DB2-VG-UDB--USERTEMP is mounted on /udb/usertemp; on-line resizing requir
Performing an on-line resize of /dev/mapper/DB2-VG-UDB--USERTEMP to 10485760 (4k) blocks.
resize2fs: Inappropriate ioctl for device While trying to add group #160
[root@aiglxapp22 ~]# pwd
/root
[root@aiglxapp22 ~]# df -h /udb/usertemp
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/DB2-VG-UDB--USERTEMP
                       20G   16G  3.6G  82% /udb/usertemp
[root@aiglxapp22 ~]# mount -o remount /udb/usertemp
[root@aiglxapp22 ~]# df -h /udb/usertemp
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/DB2-VG-UDB--USERTEMP
                       20G   16G  3.6G  82% /udb/usertemp
[root@aiglxapp22 ~]# resize2fs /dev/mapper/DB2-VG-UDB--USERTEMP
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/DB2-VG-UDB--USERTEMP is mounted on /udb/usertemp; on-line resizing requir
Performing an on-line resize of /dev/mapper/DB2-VG-UDB--USERTEMP to 10485760 (4k) blocks.
resize2fs: Inappropriate ioctl for device While trying to add group #160
[root@aiglxapp22 ~]# lvscan
  ACTIVE            '/dev/UDB-MISC/UDB-USERTEMP' [40.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-SYSTEMP' [40.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-DIAG' [10.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-SYSCAT' [10.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-XINSD' [2.00 GB] inherit
  ACTIVE            '/dev/LOG/UDB-LOG' [20.00 GB] inherit
  ACTIVE            '/dev/DATA2/UDB-DATA2' [60.00 GB] inherit
  ACTIVE            '/dev/DATA/UDB-DATA' [60.00 GB] inherit
  ACTIVE            '/dev/root_VG/ROOT' [24.00 GB] inherit
  ACTIVE            '/dev/root_VG/VAR' [23.78 GB] inherit
  ACTIVE            '/dev/root_VG/TMP' [8.00 GB] inherit
  ACTIVE            '/dev/root_VG/SWAP' [8.00 GB] inherit
  ACTIVE            '/dev/root_VG/DBS-UDB' [25.00 GB] inherit
  ACTIVE            '/dev/root_VG/OPT-IBM' [5.00 GB] inherit
[root@aiglxapp22 ~]# pwd
/root
[root@aiglxapp22 ~]# fuser /udb/usertemp
[root@aiglxapp22 ~]# umount /udb/usertemp
[root@aiglxapp22 ~]# df -h /udb/usertemp
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/root_VG-ROOT
                       24G  3.0G   20G  14% /
[root@aiglxapp22 ~]# e2fsck /dev/mapper/DB2-VG-UDB--USERTEMP
e2fsck 1.39 (29-May-2006)
/dev/mapper/DB2-VG-UDB--USERTEMP: clean, 16/2621440 files, 4062330/5242880 blocks
[root@aiglxapp22 ~]# e2fsck /dev/mapper/DB2-VG-UDB--USERTEMP
e2fsck 1.39 (29-May-2006)
/dev/mapper/DB2-VG-UDB--USERTEMP: clean, 16/2621440 files, 4062330/5242880 blocks
[root@aiglxapp22 ~]# resize2fs /dev/mapper/DB2-VG-UDB--USERTEMP
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f /dev/mapper/DB2-VG-UDB--USERTEMP' first.
[root@aiglxapp22 ~]# lvscan
  ACTIVE            '/dev/UDB-MISC/UDB-USERTEMP' [40.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-SYSTEMP' [40.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-DIAG' [10.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-SYSCAT' [10.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-XINSD' [2.00 GB] inherit
  ACTIVE            '/dev/LOG/UDB-LOG' [20.00 GB] inherit
  ACTIVE            '/dev/DATA2/UDB-DATA2' [60.00 GB] inherit
  ACTIVE            '/dev/DATA/UDB-DATA' [60.00 GB] inherit
  ACTIVE            '/dev/root_VG/ROOT' [24.00 GB] inherit
  ACTIVE            '/dev/root_VG/VAR' [23.78 GB] inherit
  ACTIVE            '/dev/root_VG/TMP' [8.00 GB] inherit
  ACTIVE            '/dev/root_VG/SWAP' [8.00 GB] inherit
  ACTIVE            '/dev/root_VG/DBS-UDB' [25.00 GB] inherit
  ACTIVE            '/dev/root_VG/OPT-IBM' [5.00 GB] inherit
[root@aiglxapp22 ~]# e2fsck -f /dev/mapper/DB2-VG-UDB--USERTEMP
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/DB2-VG-UDB--USERTEMP: 16/2621440 files (6.3% non-contiguous), 4062330/5242880 blocks
[root@aiglxapp22 ~]# e2fsck -f /dev/mapper/DB2-VG-UDB--USERTEMP
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/DB2-VG-UDB--USERTEMP: 16/2621440 files (6.3% non-contiguous), 4062330/5242880 blocks
[root@aiglxapp22 ~]# resize2fs /dev/mapper/DB2-VG-UDB--USERTEMP
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/mapper/DB2-VG-UDB--USERTEMP to 10485760 (4k) blocks.
The filesystem on /dev/mapper/DB2-VG-UDB--USERTEMP is now 10485760 blocks long.
[root@aiglxapp22 ~]# lvscan
  ACTIVE            '/dev/UDB-MISC/UDB-USERTEMP' [40.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-SYSTEMP' [40.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-DIAG' [10.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-SYSCAT' [10.00 GB] inherit
  ACTIVE            '/dev/UDB-MISC/UDB-XINSD' [2.00 GB] inherit
  ACTIVE            '/dev/LOG/UDB-LOG' [20.00 GB] inherit
  ACTIVE            '/dev/DATA2/UDB-DATA2' [60.00 GB] inherit
  ACTIVE            '/dev/DATA/UDB-DATA' [60.00 GB] inherit
  ACTIVE            '/dev/root_VG/ROOT' [24.00 GB] inherit
  ACTIVE            '/dev/root_VG/VAR' [23.78 GB] inherit
  ACTIVE            '/dev/root_VG/TMP' [8.00 GB] inherit
  ACTIVE            '/dev/root_VG/SWAP' [8.00 GB] inherit
  ACTIVE            '/dev/root_VG/DBS-UDB' [25.00 GB] inherit
  ACTIVE            '/dev/root_VG/OPT-IBM' [5.00 GB] inherit
[root@aiglxapp22 ~]# mount /udb/usertemp
[root@aiglxapp22 ~]# df -h /udb/usertemp
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/DB2-VG-UDB--USERTEMP
                       40G   16G   23G  41% /udb/usertemp
[root@aiglxapp22 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/root_VG-ROOT
                       24G  3.0G   20G  14% /
/dev/mapper/root_VG-VAR
                       24G  724M   22G   4% /var
/dev/mapper/root_VG-TMP
                      7.8G  211M  7.2G   3% /tmp
/dev/sda1             190M   30M  151M  17% /boot
tmpfs                  16G  4.0K   16G   1% /dev/shm
df: `/dbsdata/database_backup': Stale NFS file handle
/dev/mapper/root_VG-OPT--IBM
                      5.0G  1.1G  3.6G  24% /opt/ibm
/dev/mapper/root_VG-DBS--UDB
                       25G  173M   24G   1% /dbs/udb
/dev/mapper/DATA-UDB--DATA
                       60G  7.7G   49G  14% /udb/data
/dev/mapper/DATA2-UDB--DATA2
                       60G  7.7G   49G  14% /udb/data2
/dev/mapper/LOG-UDB--LOG
                       20G  4.4G   15G  24% /udb/log
/dev/mapper/DB2-VG-UDB--SYSTEMP
                       40G   21G   18G  55% /udb/systemp
/dev/mapper/DB2-VG-UDB--DIAG
                      9.9G  151M  9.2G   2% /udb/diag
/dev/mapper/DB2-VG-UDB--SYSCAT
                      9.9G  497M  8.9G   6% /udb/syscat
/dev/mapper/DB2-VG-UDB--XINSD
                      2.0G  1.5G  391M  80% /udb/home/udbxinsd
re2aixut1:/software   186G  146G   40G  79% /mnt
re2unxpv013:/usapool/export/VAS
                      186G  146G   40G  79% /mnt
/dev/mapper/DB2-VG-UDB--USERTEMP
                       40G   31G  7.2G  81% /udb/usertemp
aignas225:/vol/aignas225v12dump/dbdump1
                      4.0T  3.7T  346G  92% /auto/dbdump1
[root@aiglxapp22 ~]# umount /mnt
[root@aiglxapp22 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/root_VG-ROOT
                       24G  3.0G   20G  14% /
/dev/mapper/root_VG-VAR
                       24G  724M   22G   4% /var
/dev/mapper/root_VG-TMP
                      7.8G  211M  7.2G   3% /tmp
/dev/sda1             190M   30M  151M  17% /boot
tmpfs                  16G  4.0K   16G   1% /dev/shm
df: `/dbsdata/database_backup': Stale NFS file handle
/dev/mapper/root_VG-OPT--IBM
                      5.0G  1.1G  3.6G  24% /opt/ibm
/dev/mapper/root_VG-DBS--UDB
                       25G  173M   24G   1% /dbs/udb
/dev/mapper/DATA-UDB--DATA
                       60G  7.7G   49G  14% /udb/data
/dev/mapper/DATA2-UDB--DATA2
                       60G  7.7G   49G  14% /udb/data2
/dev/mapper/LOG-UDB--LOG
                       20G  4.4G   15G  24% /udb/log
/dev/mapper/DB2-VG-UDB--SYSTEMP
                       40G   21G   18G  55% /udb/systemp
/dev/mapper/DB2-VG-UDB--DIAG
                      9.9G  151M  9.2G   2% /udb/diag
/dev/mapper/DB2-VG-UDB--SYSCAT
                      9.9G  497M  8.9G   6% /udb/syscat
/dev/mapper/DB2-VG-UDB--XINSD
                      2.0G  1.5G  391M  80% /udb/home/udbxinsd
re2aixut1:/software   375G  327G   49G  87% /mnt
/dev/mapper/DB2-VG-UDB--USERTEMP
                       40G   31G  7.2G  81% /udb/usertemp
aignas225:/vol/aignas225v12dump/dbdump1
                      4.0T  3.7T  346G  92% /auto/dbdump1
[root@aiglxapp22 ~]# umount /mnt
[root@aiglxapp22 ~]# df -h /auto/dbdump1
Filesystem            Size  Used Avail Use% Mounted on
aignas225:/vol/aignas225v12dump/dbdump1
                      4.0T  3.7T  346G  92% /auto/dbdump1
[root@aiglxapp22 ~]# df -hP /auto/dbdump1
Filesystem            Size  Used Avail Use% Mounted on
aignas225:/vol/aignas225v12dump/dbdump1  4.0T  3.7T  346G  92% /auto/dbdump1
[root@aiglxapp22 ~]# man df
[root@aiglxapp22 ~]# fdisk -l

Wednesday, July 16, 2014

Adding multiple route on Linux




Adding default route manually.
# route add default gw 192.168.20.20

# route add -host 192.168.20.20 gw 192.168.10.20
# route add default gw 192.168.10.20 eth0 # specify the interface if you have multiple.
# ip route add 192.168.20.0/24 dev eth0
# route add -net 192.168.20.0 netmask 255.255.255.0 gw 192.168.20.20 dev eth0

# service network restart

lxbl55% nexec lxapp23 cat etc/sysconfig/network-scripts/route-eth0
#default via 192.168.20.25 -- the original entry.
# Sample
GATEWAY0=Your gateway/router
NETMASK0=Your subnet Mask
ADDRESS0=Your network
#
# 172.16.0.0
GATEWAY0=192.168.20.25
NETMASK0=255.240.0.0
ADDRESS0=172.16.0.0
#
# 10.0.0.0
GATEWAY1=192.168.20.25
NETMASK1=255.0.0.0
ADDRESS1=10.0.0.0
#
# 192.168.0.0
GATEWAY2=192.168.20.25
NETMASK2=255.255.0.0
ADDRESS2=192.168.0.0
#
#192.168.20.0
GATEWAY3=0.0.0.0
NETMASK3=255.255.255.0
ADDRESS3=192.168.20.0
#
#192.168.16.0
GATEWAY4=192.168.20.20
NETMASK4=255.255.255.0
ADDRESS4=192.168.16.0
#
#0.0.0.0
GATEWAY5=192.168.20.20
NETMASK5=0.0.0.0
ADDRESS5=0.0.0.0
lxbl55%

lxbl55% nexec lxapp23 netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.16.0    192.168.20.20    255.255.255.0   UG        0 0          0 eth2
192.168.20.0     0.0.0.0         255.255.255.0   U         0 0          0 eth2
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth2
192.168.0.0     192.168.20.25    255.255.0.0     UG        0 0          0 eth2
172.16.0.0      192.168.20.25    255.240.0.0     UG        0 0          0 eth2
10.0.0.0        192.168.20.25    255.0.0.0       UG        0 0          0 eth2
0.0.0.0         192.168.20.20    0.0.0.0         UG        0 0          0 eth2

lxbl55% nexec lxapp23 cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
USERCTL=no
BOOTPROTO=static
NETMASK=255.255.255.0
IPADDR=192.168.20.30
PEERDNS=no
check_link_down() {
 return 1;
}

lxbl55% nexec lxapp23 cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=lxapp23
lxbl55%

Reboot the confirm the change and run netstat -rn

Monday, July 14, 2014

How to upgrade the server from 6.3 to 6.5


How to upgrade the server from 6.3 to 6.5

if your environment is not able to communicate with your satellite server, then copy the image and install it locally to upgrade your system.

1. Upload and mount the iso image or copy the content of the file to the directory of your choice.
# mount image.iso /opt/RH6.5

2. Run the update.
# yum -y localinstall *.rpm --nogpgcheck

3. Verify OS is at 6.5
# cat /etc/*release

4. Reboot server
# reboot

5. Verify the new kernel. kernel level should be 2.6.32-431.11.2.el6.x86_64
# uname -a

Monday, June 30, 2014

DNS installation

http://www.garron.me/en/go2linux/how-setup-dns-server-master-slave-bind.html
http://tecadmin.net/step-by-step-installation-and-configuration-openldap-server-and-freeradius/#
http://www.zytrax.com/books/ldap/ch5/
http://computernetworkingnotes.com/network-administrations/dns-server.html

http://www.unixmen.com/dns-server-installation-step-by-step-using-centos-6-3/

/etc/named.conf

//
// /etc/named.conf
//

options {
    directory "/var/named";
    pid-file "/var/run/named/named.pid";
    auth-nxdomain yes;
    datasize default;
// Uncomment these to enable IPv6 connections support
// IPv4 will still work:
//  listen-on-v6 { any; };
// Add this for no IPv4:
//  listen-on { none; };

    // Default security settings.
    allow-recursion { 127.0.0.1; };
    allow-transfer { none; };
    allow-update { none; };
    version none;
    hostname none;
    server-id none;
};

zone "localhost" IN {
    type master;
    file "localhost.zone";
    allow-transfer { any; };
};

zone "0.0.127.in-addr.arpa" IN {
    type master;
    file "127.0.0.zone";
    allow-transfer { any; };
};

zone "." IN {
    type hint;
    file "root.hint";
};

//zone "example.org" IN {
//  type slave;
//  file "example.zone";
//  masters {
//      192.168.1.100;
//  };
//  allow-query { any; };
//  allow-transfer { any; };
//};

logging {
        channel xfer-log {
                file "/var/log/named.log";
                print-category yes;
                print-severity yes;
                print-time yes;
                severity info;
        };
        category xfer-in { xfer-log; };
        category xfer-out { xfer-log; };
        category notify { xfer-log; };
};




Create a Master Zone




To create a master zone, edit the file named.conf and add the following, in this example, I will create a zone for the domain linux10.com

zone "linux10.com" IN {
    type master;
    file "linux10.com.zone";
    allow-update { none; };
    allow-transfer { none; };
};

Then create the file linux10.com.zone in the folder stated in your options section of named.conf file.

The file should look at least like this:

$ORIGIN .
$TTL 86400      ; 1 day
linux10.com            IN SOA  primary.server.com. your.email.address. (
                            2010122801 ; serial
                            7200       ; refresh (2 hous)
                            7200       ; retry (2 hours)
                            2419200    ; expire (5 weeks 6 days 16 hours)
                            86400      ; minimum (1 day)
                            )
$TTL 14400      ; 4 hours
                    NS      scz.alketech.com.
                    NS      ns1.alketech.com.
                    A       10.1.1.1 ; If you want to assign a server to your domain
                   MX      10      mx1 ; Your email server if you have any
                   MX      20      mx2 ; Your secondary email server if you have one

$ORIGIN linux10.com.
www                     A       1.2.3.4 ; The IP of your web server if you want to have one.
mx1         A   1.2.3.5 ; The IP of your mx1 server
mx2         A   1.2.3.6 ; The IP of your mx2 server

Of course yours may have more or less lines and servers according to your needs.

Configure a DNS slave server with BIND

It is a good idea, to have slave server in case your master server is not reachable at any time.

Both master and slave need to defined as your DNS servers in your domain registrar, you may define more than just two server, and that is a good idea, it is also a good idea, to have your DNS server on different networks, I mean, if you have them on the same office/Data center, and that place loose Internet connectivity all your server will be out of reach, and you will loose traffic or emails or both.

For the visitors of your servers, any DNS server is the same and there is no difference between masters or slaves, so you should define one master and as many slaves as you want (anything between 2 to 4 slaves is OK).

Enable AXFR transfers

Your master DNS server should allow AXFR transfers to the slave servers for this to work, so the first step is to configure your master server to do so.

zone "linux10.com" IN {
    type master;
    file "linux10.com.zone";
    allow-update { none; };
    allow-transfer { ip.of.slave.server; ip.of.slave.server2; ip.of.slave.server3;};
};

Now create the slave zone in your slave servers.

On the slave server named.conf file you need to configure the slave zone, like this:

zone "linux10.com" {
    type slave;
    file "linux10.com.zon";
    masters { 1.2.3.4; };
    allow-transfer { none; };
};

Testing the configuration

dig @your.master.server your.domain.com ns

Example:

dig @scz.alketech.com linux10.com ns

You should get something like this:

; <<>> DiG 9.2.4 <<>> @scz.alketech.com linux10.com ns
; (1 server found)
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23659
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 2

;; QUESTION SECTION:
;linux10.com.                   IN      NS

;; ANSWER SECTION:
linux10.com.            14400   IN      NS      scz.alketech.com.
linux10.com.            14400   IN      NS      ns1.alketech.com.

;; ADDITIONAL SECTION:
ns1.alketech.com.       14400   IN      A       200.87.59.3
scz.alketech.com.       14400   IN      A       200.87.61.83

;; Query time: 2 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Wed Dec 29 15:35:20 2010
;; MSG SIZE  rcvd: 106

Final tunings

It is a good idea to disable recursion in your authoritative servers, either master or slave.

To do this, in your options section insert these lines

acl recurseallow { 1.2.3.4; 127.0.0.1; };
allow-recursion { recurseallow; };recursion yes;

Be sure to include this in the options section of the file /etc/named.conf for Arch Linux and Slackware and /etc/bind/named.conf.options for Debian.

Only for Slackware and Arch Linux

For Arch Linux and Slackware you need to enable the named daemon to start on each boot, to do this

On Arch Linux, edit the /etc/rc.conf file, and add it, to the daemons list

On Slackware, make the file /etc/rc.bind executable
permalink

If you enj








============================================================

The Domain Name System FAQs

The DNS is the addressing system for the Internet. Almost anything that interfaces with the Internet (e.g., computers, mobile devices, laptops, ATMs, and POS terminals) relies on DNS services to exchange information. DNS uses specialized servers to translate (or resolve) names such as www.verisigninc.com into numeric addresses that allow data and information to reach its destination. All Internet applications—ranging from websites, email, social networking, and online banking to Voice over Internet Protocol (VoIP), file sharing, and video on demand—depend on the accuracy and integrity of this translation. Without the DNS, the Internet cannot function. The DNS is integral to a nation's critical infrastructure, online business operations and financial transactions, and all Internet-based communications.



What is the DNS?

How does the DNS work?


The domain name space consists of a tree of domain names, subdivided into zones. The top-level or root zone is administered by the U.S. Department of Commerce (DoC) and jointly managed by Verisign and the Internet Assigned Numbers Authority (IANA) functions operator, who maintain the data in the root name servers.

A DNS zone consists of a collection of connected nodes served by an authoritative name server. Authoritative name servers for different zones are responsible for publishing the mappings of domain names to IP addresses. Each node or leaf in the tree has zero or more resource records that hold information associated with the domain name. Every domain name ends with a top-level domain (TLD) such as .com or .tv.

For the Internet to function and to prevent duplication of domain names, there must be one authoritative place to register a domain name. Each TLD has an authoritative registry, which manages a centralized database. The registry propagates the information about domain names and IP addresses in TLD zone files. TLD zone files map active second-level domain names (the portion of the domain name that appears immediately to the left of ".") to the unique IP addresses of the name servers.


Why is DNS vulnerable?


The process of translating a domain name into an IP address is called DNS resolution. When someone types a domain name, such as www.verisigninc.com, into a web browser, the browser contacts a name server to obtain the corresponding IP address. There are two types of name servers: authoritative name servers, which store complete information about a zone, and recursive name servers, which answer DNS queries for Internet users and store DNS response results for a period of time. When a recursive name server receives a response, it caches (stores) it to speed up subsequent queries. Caching helps reduce the number of information requests required, but it is susceptible to man-in-the-middle attacks.

As a result of these attacks, cyber criminals can:

    Hijack emails
    Tap Voice over IP (VoIP)
    Impersonate websites
    Steal passwords and login information
    Extract credit card data and other confidential information

Learn more about threats to the DNS system.


What is cache poisoning?
Cache poisoning occurs when fraudulent DNS data is inserted into the cache of a recursive name server. Recursive name servers temporarily store, or cache, information learned during the name resolution process, but without DNSSEC they have no way to ensure the validity and accuracy of this information. When malicious information is cached on the recursive name server, the server is considered "poisoned." Cache poisoning allows an attacker to redirect traffic to fraudulent sites.


What are man-in-the-middle (MITM) attacks?
A man-in-the-middle (MITM) attack surreptitiously intercepts and modifies communications between two systems. The attacker can potentially modify the communication to redirect traffic to an illegitimate address or website. End users do not detect the "man in the middle" and assume that they are communicating directly with their intended destination.




DNS - How the Domain Name System Works


How the Domain Name System Works

The Domain Name System (DNS) is a central part of the Internet, providing a way to match names (a website you’re seeking) to numbers (the address for the website). Anything connected to the Internet - laptops, tablets, mobile phones, websites - has an Internet Protocol (IP) address made up of numbers. Your favorite website might have an IP address like 64.202.189.170, but this is obviously not easy to remember. However a domain name such as bestdomainnameever.com is something people can recognize and remember. DNS syncs up domain names with IP addresses enabling humans to use memorable domain names while computers on the Internet can use IP addresses.
Let’s explore what keeps more than 2.5 billion Internet users and 271 million domain names* connecting—and how Verisign helps to make it happen.
* Verisign Domain Name Industry Brief, April 2014

http://www.verisigninc.com/en_US/domain-names/online/how-dns-works/index.xhtml





http://www.verisigninc.com/en_US/domain-names/online/how-dns-works/index.xhtml

http://www.verisigninc.com/assets/DNS101.pdf



============================================================

The Domain Name System FAQs

The DNS is the addressing system for the Internet. Almost anything that interfaces with the Internet (e.g., computers, mobile devices, laptops, ATMs, and POS terminals) relies on DNS services to exchange information. DNS uses specialized servers to translate (or resolve) names such as www.verisigninc.com into numeric addresses that allow data and information to reach its destination. All Internet applications—ranging from websites, email, social networking, and online banking to Voice over Internet Protocol (VoIP), file sharing, and video on demand—depend on the accuracy and integrity of this translation. Without the DNS, the Internet cannot function. The DNS is integral to a nation's critical infrastructure, online business operations and financial transactions, and all Internet-based communications.



What is the DNS?

How does the DNS work?


The domain name space consists of a tree of domain names, subdivided into zones. The top-level or root zone is administered by the U.S. Department of Commerce (DoC) and jointly managed by Verisign and the Internet Assigned Numbers Authority (IANA) functions operator, who maintain the data in the root name servers.

A DNS zone consists of a collection of connected nodes served by an authoritative name server. Authoritative name servers for different zones are responsible for publishing the mappings of domain names to IP addresses. Each node or leaf in the tree has zero or more resource records that hold information associated with the domain name. Every domain name ends with a top-level domain (TLD) such as .com or .tv.

For the Internet to function and to prevent duplication of domain names, there must be one authoritative place to register a domain name. Each TLD has an authoritative registry, which manages a centralized database. The registry propagates the information about domain names and IP addresses in TLD zone files. TLD zone files map active second-level domain names (the portion of the domain name that appears immediately to the left of ".") to the unique IP addresses of the name servers.


Why is DNS vulnerable?


The process of translating a domain name into an IP address is called DNS resolution. When someone types a domain name, such as www.verisigninc.com, into a web browser, the browser contacts a name server to obtain the corresponding IP address. There are two types of name servers: authoritative name servers, which store complete information about a zone, and recursive name servers, which answer DNS queries for Internet users and store DNS response results for a period of time. When a recursive name server receives a response, it caches (stores) it to speed up subsequent queries. Caching helps reduce the number of information requests required, but it is susceptible to man-in-the-middle attacks.

As a result of these attacks, cyber criminals can:

    Hijack emails
    Tap Voice over IP (VoIP)
    Impersonate websites
    Steal passwords and login information
    Extract credit card data and other confidential information

Learn more about threats to the DNS system.


What is cache poisoning?
Cache poisoning occurs when fraudulent DNS data is inserted into the cache of a recursive name server. Recursive name servers temporarily store, or cache, information learned during the name resolution process, but without DNSSEC they have no way to ensure the validity and accuracy of this information. When malicious information is cached on the recursive name server, the server is considered "poisoned." Cache poisoning allows an attacker to redirect traffic to fraudulent sites.


What are man-in-the-middle (MITM) attacks?
A man-in-the-middle (MITM) attack surreptitiously intercepts and modifies communications between two systems. The attacker can potentially modify the communication to redirect traffic to an illegitimate address or website. End users do not detect the "man in the middle" and assume that they are communicating directly with their intended destination.


http://www.verisigninc.com/assets/DNS101.pdf



How DNS works for domain.com

1. A client PC requests for an IP address of a domain say google.com
2. The client request is forwarded to the local DNS server first. If it has an entry to its database or on cache, it will return the value. If it does not find it, it will forward the request to another DNS server. If there is not another DNS server and there is no record, then it will send no record to the client query.
3. Once the request is forwarded from DNS server to another DNS server, it might have entry for the domain on its cache, and it may return with an IP address of 192.168.10.120 (example only).
4. This query will be returned back to the DNS server. The DNS server may cache this information for future request for the same domain.

5. Now, client PC gets the IP address of the domain. Now, it makes connection to the server google.com.



some interview tips

What is load average and why does it matter?
     Candidate should be able to identify that load average is a good indication of how busy a server is. A load average of less than 1 per cpu core is alright and as it becomes closer to equal to the number of cpu cores it indicates the server has more processes waiting than resources available. They should also identify that load average can be influenced by other factors than just CPU (I.E. iowait).

What is the difference between LVM and a partition. How do you add a more storage to the existing logical volume?
     LVM is logical volume manager, logical volumes sit on top of logical extents which are  mapped to physical extents which sit on a physical hard drive. LVM's logical extents can also span multiple hard drives. 
     Traditional partitions are sequential blocks on a physical disks
     You can add more storage space to an LVM by using the extend commands, (vgextend to extend your volume group, and then lvextend to extend your logical volume, if you do not have any extra extents to add to your logical volume then you'll need to run pvcreate and then add the new extents to the volume group first).

When extending LVM, when will you add new disk vs adding more space to the existing disk(Assume that it is VM on hypervisor)
  
The main problem with adding new disks is that your configurations can become messy over time and you start to get a lot of virtual controllers if people keep adding small hard drives instead of extending existing drives. If you have a bunch of small disks on the same storage volume then you should create one larger disk and then pvmove (move the physical extents) from the smaller disks to the larger disk. Once the move is complete then you can remove the other smaller hdds. Sometimes (for example heavily utilized disk IO) you might need create a new disk on another storage volume to help spread the load, in which case you should add a new disk.

In Linux how does OOM killer work?
     I usually try to use this question to gauge how familiar the candidate is with scenarios where the box runs out of memory. I will usually first ask if they know what "OOM" killer is, and if they've never heard of it then explain OOM means "Out Of Memory". It is pretty easy to guess that OOM killer will look for high memory consumption.
     OOM killer will look for the highest memory consumption applications and give it score, it will then look at the time the process has been running for and reduce score for longer running processes. It also takes into consideration niceness (higher nice number is safer to kill where lower nice number is in theory more important). It takes all of these factors into consideration and kills the highest scoring application. There is also a flag that can be defined in /proc/<pid>/ to prevent OOM killer from terminating a specific process.
     Most candidates will not know all of the factors of OOM killer, but the more the better

Describe a linux package management system and why it is useful.
     Hopefully they can describe rpm or debian package manager and explain that it's useful for version control and consistency.

What is difference between hard and soft link, from inode and filesystem perspective?
      Soft link is basically a file string pointer that can point to another directory or file (spanning partitions), a soft link is it's own file and has it's own inode number. 
      Hard link is basically another name for the same file existing on the same partition. It points to the same inode number. If you have two hard links and delete either one of them, the file is still there. If you have a soft link pointing to a file and you delete the file that the soft link is pointing to, the soft link breaks and the file is gone.
      (Note: hard links cannot span multiple partitions, if they say they can both point to directories or across multiple partitions; mark it as wrong)

Difference between ctrl+Z and ctrl+D
     CTRL + Z pauses the running application and you can choose to throw it in the background with the bg command or bring it back to foreground with fg
     CTRL + D sends a signal to indicate that you're done without a harsh kill signal like CTRL + C

What does iowait mean when your looking at your system stats and why does it matter?
     Iowait is the time a process is waiting and unable to preform any actions due to a IO block, usually caused by resource contention or because the resource is too slow. This is one of the biggest reason why load averages spike (so they might have touched upon this in the first question)

When is swapping ok and when is it bad?
      Swapping is ok when it's high niced applications or when the memory swapped is applications that do not need access to that memory very often. If swap usage is not growing at all and not occurring very often then a little usage of swap is not very concerning.
      Swapping is usually bad as it indicates there is not enough available memory for all of the applications and as a system begins swapping it drastically slows down as it starts placing memory that should be stored in RAM onto a hard drive / storage volume.

What is ulimit and why does it matter?
     Ulimit allows you to control system settings, for example core file size (if an application crashes and should generate a core dump; what is the maximum file size this should be), max memory allowance, open files… etc (uname –a would show you configurable options and current limitations).

How do you look at open file descriptors?
     lsof

How do you check for version of a package? How do you update to new version, if one is available on lets say on CentOS?
Yum search / yum check-update / yum update

If a daemon process is not starting, where would you look to figure out why it isn’t starting?
     Good starting location would be to check the logs for the process

Describe how DNS works?
      They should be able to touch upon DNS is the resolution of a name to IP address and works like a tree. If their local dns server does not have the answer it has to goto the "root" of the tree, and start going down the name servers until it finds a response
I will also usually ask about the protocol as well, like does it use tcp or udp (it actually uses both, tcp is the only way you can get large dns responses though, udp is by far more commonly used though)    

Describe how tcptraceroute is different from traceroute and why it might be helpful (Note: if they've never worked with tcptraceroute, then ask how trace route works from a technical level).
      Common misconception / miscommunication:  tcpdump is not the same as tcptraceroute, if they say tcpdump in their response try clarifying it's tcptraceroute
        Traceroute functions by increasing the TTL value on packets sent, regular trace route usually utilizes ICMP or UDP packets to check the path; but this can be denied on a lot of firewalls.
      Tcptraceroute allows you to specify port numbers and will send TCP SYN packets. When troubleshooting connectivity issues to a location where you suspect a firewall might be restricting traffic sending tcptraceroutes with an expected port will usually allow you through the firewall and usually allows you to get a clearer picture of whats going on

How to discard output from a script and print only errors from a script? How do you close a file descriptor?
     Discarding output from a script:  >/dev/null    (they might call > a redirect (correct) or "pipe" (technically not correct, but acceptable))
     note: if they do 2>&1 (they might say redirect standard error (or 2) to standard out) ) then they will just put the output to stdout and that would not accomplish the goal, especially if they said the above line in combination with this, that will get rid of all output leaving nothing.
     Closing file descriptors:  1>&-  or  2>&-  or  3>&-  (they might say standard out, standard error instead of 1 or 2, that’s fine) 

How do you do a simple infinite loop, which finds files created in last hr and have more than 1 hard link, sleep for 1 minute?
     while [ true ]; do
              find . -type f -mmin -60 -printf "%p %n\n" 2>/dev/null | grep -v ' 1$'
              sleep 60 #or sleep 1m
     Done
 
        Notes:
      they shouldn't use a "For" loop, if they say "while true", or "while 1" or "until false" then that should be good for the infinite loop aspect
        a lot of candidates don't know exactly the find parameters off hand, They should at least know "find" "type f" and either "m min" or "m time".  And if they don't know the rest I would usually ask them if they were in front of a terminal without internet access what they would do. The answer I'm looking for is "man find" in that case.

How do you preform a search and replace on a file (specifically related to scripting, so what commands opposed to using vi or nano or something else)?
     sed -e s/<string>/<replace>/g    

What is the purpose of “#!/bin/bash” in a shell script?
     The first two bytes of the executable file tells the system what interpreter (or application) and optionally default arguments to run, in this case it tells the system to run bash when it is executed