Thursday, October 20, 2011

Install perl modules

To install mod_perl in ubuntu :

root@ubuntu:/etc/apache2# apt-get install libapache2-mod-perl2

Add below directives in /etc/apache2/httpd.conf

root@ubuntu:/etc/apache2# cat httpd.conf
<Directory /var/www/perl>
Options +ExecCGI
AddHandler cgi-script .cgi .pl
</Directory>
root@ubuntu:/etc/apache2#

Create directory inside /var/www as perl 


cd /var/www
mkdir perl

Permission can be set as below
drwxr-xr-x  2 www-data www-data 4096 2011-10-20 15:33 perl


refer your apache.conf file what user directive is given there ,
by default it is www-data




After installing any perl module restart apache2

root@ubuntu:/etc/apache2# /etc/init.d/apache2 restart



To Check all Perl modules install :

root@ubuntu:/etc/apache2# perl -MCPAN -e 'CPAN::Shell->r'


Apache2::SizeLimit             0.05      0.95  PHRED/Apache-SizeLimit-0.95.tar.gz
B                              1.22      1.31  RJBS/perl-5.15.2.tar.bz2
CGI                            3.43      3.55  MARKSTOS/CGI.pm-3.55.tar.gz
Compress::Zlib                2.020     2.037  PMQS/IO-Compress-2.037.tar.gz
Cwd                            3.30      3.33  SMUELLER/PathTools-3.33.tar.gz
File::MimeInfo::Rox            0.15       0.2  PARDUS/File-MimeInfo/File-MimeInfo-0.14.tar.gz
Filter::Util::Call             1.08      1.39  PMQS/Filter-1.39.tar.gz
HTML::FormatPS                 2.04      2.10  NIGELM/HTML-Format-2.10.tar.gz
I18N::LangTags::Detect         1.03      1.04  LBROCARD/perl-5.12.4.tar.gz
I18N::Langinfo                 0.02      0.07  JESSE/perl-5.13.9.tar.gz
LWP                           5.837      6.03  GAAS/libwww-perl-6.03.tar.gz
List::Util                     1.21      1.23  GBARR/Scalar-List-Utils-1.23.tar.gz
Locale::Constants              2.07      3.16  SBECK/Locale-Codes-3.16.tar.gz
Locale::Country                2.07      3.18  SBECK/Locale-Codes-3.18.tar.gz
Mail::Address                  2.06      2.08  MARKOV/MailTools-2.08.tar.gz
Pod::Man                       2.22      2.25  RRA/podlators-2.4.0.tar.gz
Socket                         1.82      1.94  FLORA/perl-5.13.11.tar.gz
mod_perl2                  2.000004  2.000005  PHRED/mod_perl-2.0.5.tar.gz
233 installed modules have no parsable version number
(use 'o conf show_unparsable_versions 1' to show them)



Also try :

root@ubuntu:/etc/apache2# instmodsh
Available commands are:
   l            - List all installed modules
   m <module>   - Select a module
   q            - Quit the program
cmd? l
Installed modules are:
   Perl
cmd? 1


Place all your perl scripts in /var/www/perl

and test in browser as http://localhost/test/first.pl

Wednesday, October 19, 2011

How to configure IPv6




Once you have enabled IPV6 , it will show in ifconfig entry as inet6 :


To configure IPV6 on Linux VM :



In

/etc/sysconfig/network

Add line :

NETWORKING_IPV6=yes
IPV6_DEFAULTGW= : fe80::200:ff:fe00:0/64


In :

/etc/sysconfig/network-scripts/ifcfg-eth0


DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
HWADDR=00:16:3E:76:D6:7D
IPADDR=192.168.122.20
NETMASK=255.255.255.128
IPV6INIT=yes
IPV6ADDR=fe80::216:4eff:fe76:d67d/64      #Primary IPv6 address (Optional)



Add Ipv6
ip addr add fe80::216:4eff:fe76:d67d/64 dev eth0

Remove IPv6
ip addr del 2010:AAA:1::100/64 dev eth0

Add ipv6 gateway
ip route add 2010:BBC:1::1 dev eth0

remove ipv6 gateway
ip route del 2010:BBC:1::1 dev eth0


To display ipv6 route
ip -6 route show


To Ping IPv6 address
ping6 -I eth0  fe80::216:4eff:fe76:d67d

Port Forwarding



Masquerade :
/sbin/iptables -t nat -A POSTROUTING -o xenbr0 -j MASQUERADE

Port Forwarding :
  iptables -t nat -A PREROUTING -p tcp -s 0.0.0.0/0 -d  10.228.1.120  --dport 2221 -j DNAT --to-destination 192.168.1.1:22


Note : In this case Xenbr0 is listening externally. 

Anyone connecting to hypervisor on 10.228.1.120:2221 will be forwarded to VM 192.168.1.1:22

Default DHCP on xen

Xen has its own DHCP server which uses virbr0 bridge,

For DHCP server to be ready, you need to make sure that libvirtd service is running.

To use any VM as dhcp client on Xen :

In the vm.cfg add the below entries :
========================
dhcp = "dhcp"
vif = ['bridge=virbr0,mac=00:16:3E:76:D6:7D,type=netfront']


mac is the mac address of eth0 configured in Virtual Machine.

Always hardcode the mac address by defining it in the
/etc/sysconfig/network/ifcfg-eth0 script in the VM machine

The line would be :

HWADDR=00:16:3E:76:D6:7D
BOOTPROTO=dhcp













Tuesday, October 18, 2011

Allowing DHCP for a particular client

Allowing only a particular dhcp client :
 ===========================
               
#  /sbin/modprobe ipt_mac
                
#iptables -A INPUT -p UDP --dport 67 --sport 68 -m mac --mac-source xx:xx:xx:xx:xx:xx -j ACCEPT



DHCP server runs on UDP port 67
DHCP client runs on UDP port 68

Here mac-source is dhcp client mac address.               

Monday, October 17, 2011

How To DHCP on a Private Network with VM's :

How To DHCP on a Private Network with VM's :
====================================

Hypervisor : - Hypervisor-Host

DHCP Client : - Host-DHCP-Client

DHCP Server : Host-DHCP-Server

DHCP server:(Imp files/command)
Config file : /etc/dhcpd.conf
Pid file :  : /var/run/dhcpd.pid

The DHCP daemon can be configured with command line options by using the /etc/sysconfig/dhcpd file.
For security, DHCP can be bound to an interface so the allocation of addresses are only available to the private internal network
# cat /etc/sysconfig/dhcpd
# Command line options here
DHCPDARGS=eth0




DHCP client :(Imp files/commands)
/var/lib/dhclient/dhclient-eth0.leases ( To check lease obtained)

[root@Host-DHCP-Client ~]# ps -elf |grep dhclient
1 S root      1509     1  0  75   0 -  1692 -      19:45 ?        00:00:00 /sbin/dhclient -1 -q -lf /var/lib/dhclient/dhclient-eth0.leases -pf /var/run/dhclient-eth0.pid eth0



For Dhcp Client vm.cfg under Hypervisor:

/var/ovs/mount/70B7E79628294FF8A7C92D6EFCD506FA/running_pool/2374_Host-DHCP-Client

Add the below line :
--------------------------------------------------------------
dhcp = "dhcp"
vif = ['bridge=xenbr0,mac=00:16:3E:48:E1:3E,type=netfront']
--------------------------------------------------------------


mac addres is the address of eth0 in dhcp client Host-DHCP-Client

Started vm again
bash$xm create ./vm.cfg




Configuration in DHCP server :
=============================

1) Edit /etc/dhcpd.conf

[aime1@crm-ohs dhcpd]$ cat /etc/dhcpd.conf
ddns-update-style none;
#local7.* /var/log/dhcpd.log;
option domain-name-servers 144.20.190.70, 138.2.202.15, 130.35.249.41;

default-lease-time 86400;
max-lease-time 604800;

authoritative;

subnet 192.168.1.0 netmask 255.255.255.0 {
#        interface eth0:1;
        range 192.168.1.128 192.168.1.254;
         option subnet-mask  255.255.255.0;
        option broadcast-address 192.168.1.255;
#        option routers 192.168.1.10;

}
[aime1@crm-ohs dhcpd]$



2) start dhcp server

dhcpd eth0

Please Note dhcp runs only on eth0 or eth1 and it wont run on aliases like eth0:1

3) Check the status :

[root@crm-ohs ~]# /etc/rc.d/init.d/dhcpd status
dhcpd (pid  17607) is running...
[root@crm-ohs ~]#

4)  Added a (Virtual IP just to check )

$ifconfig eth0:1 192.168.1.10 netmask 255.255.255.0 up


eth0:1    Link encap:Ethernet  HWaddr 00:16:3E:41:46:00 
          inet addr:192.168.1.10  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1



Configuration in DHCP Client :
==============================

1)

[root@Host-DHCP-Client ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
# Xen Virtual Ethernet
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
[root@Host-DHCP-Client ~]#


2) restart network (or better reboot host)

/etc/rc.d/int.d/network restart

3) Now chekc the Ip obtained is in 192 series :

[root@Host-DHCP-Client ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:16:3E:48:E1:3E 
          inet addr:192.168.1.254  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::216:3eff:fe48:e13e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:377865 errors:0 dropped:0 overruns:0 frame:0
          TX packets:12622 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:91226762 (87.0 MiB)  TX bytes:8154809 (7.7 MiB)
         
         
         
         
         

Tuesday, October 4, 2011

Find files more than 10 MB

$ find . -type f -size +10000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

 Output will be like :


./soa/bam/applications/oracle-bam.ear: 63M
./soa/bam/applications/oracle-bam-was.ear: 63M
./soa/rcu/integration/bam/sql/sqlserver/icommand2.sql: 22M
./soa/rcu/integration/bam/sql/db2/icommand2.sql: 22M
./soa/rcu/integration/bam/sql/oracle/icommand2.sql: 22M
./soa/jdk/jre/lib/fonts/ALBANWTT.ttf: 25M
./soa/jdk/jre/lib/fonts/ALBANWTJ.ttf: 26M
./soa/jdk/jre/lib/fonts/ALBANWTS.ttf: 25M
./soa/jdk/jre/lib/fonts/ALBANWTK.ttf: 26M