Saturday 31 March 2012

Configure DNS server RedHat 6

## Configuring DNS server on REDHAT 6.

Step # 1a: Configure the network Interface like this:



[root@server ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:1D:09:10:49:DC
          inet addr:192.168.0.254  Bcast:192.168.0.255  Mask:255.255.255.0 ## DNS server machine Ethernet
          inet6 addr: fe80::21d:9ff:fe10:49dc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:578841 errors:0 dropped:0 overruns:0 frame:0
          TX packets:31217 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:59073403 (56.3 MiB)  TX bytes:5895624 (5.6 MiB)
          Interrupt:16

[root@server ~]#

Step # 1b: Set Host Configuration as follows:

[root@server named]# cat /etc/hosts
127.0.0.1       localhost.localdomain  
::1     localhost.localdomain  
192.168.0.254   server.example.com server

[root@server named]# cat /etc/resolv.conf

nameserver 192.168.0.254
search example.com

[root@server named]#

Step # 2: Install Bind.


[root@server ~]# yum install bind*

Step # 3: Edit named.conf: we need to change only three lines in this file:

[root@server ~]# vi /etc/named.conf
options {
        listen-on port 53 { 192.168.0.254; };   ## Enter Your IP Here by !!
        #listen-on-v6 port 53 { ::1; };        ## Comment this line
        directory       "/var/named";
        dump-file       "/var/named/data/cache_dump.db";
        statistics-file "/var/named/data/named_stats.txt";
        memstatistics-file "/var/named/data/named_mem_stats.txt";
        allow-query     { any; };        ## Allow Query to DNS from outside world
        recursion yes;

        .
    .
    .                    ## Keep other configuration as it is
    .

zone "." IN {
        type hint;
        file "named.ca";
};

include "/etc/named.rfc1912.zones";

Step # 4: We need to define our Zone file which is done in /etc/named.rfc1912.zones as follows:


[root@server named]# cat /etc/named.rfc1912.zones

zone "example.com" IN {
        type master;
        file "forward.zone";            ; Forward Zone will be defined in forward.zone
        allow-update { none; };
};

zone "0.168.192.in-addr.arpa" IN {
        type master;
        file "reverse.zone";            ; Reverse Zone will be defined in reverse.zone
        allow-update { none; };
};

[root@server named]#

Step # 5: Now we configure Forward Zone and Reverse Zone:

[root@server named]# cat /var/named/forward.zone
$TTL 1D
@       IN SOA  server.example.com. root.server.example.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN NS   server.example.com.
server  IN A    192.168.0.254
test    IN A    192.168.0.100            ; Like this we can any number of domains
[root@server named]#


[root@server named]# cat /var/named/reverse.zone
$TTL 1D
@       IN SOA server.example.com. root.example.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN NS   server.example.com.
254     IN PTR  server.example.com.
100     IN PTR  test.example.com.           ; Like this we can any number of domains
[root@server named]#

Step # 6: Start Bind.

[root@server named]# /etc/init.d/named start
Starting named:                                            [  OK  ]
[root@server named]#

[root@server named]# chkconfig named on

Step # 7: Check DNS functionality:

## DIG :-

[root@server named]# dig server.example.com

; <<>> DiG 9.7.0-P2-RedHat-9.7.0-5.P2.el6 <<>> server.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30604
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;server.example.com.            IN      A

;; ANSWER SECTION:
server.example.com.     86400   IN      A       192.168.0.254

;; AUTHORITY SECTION:
example.com.            86400   IN      NS      server.example.com.

;; Query time: 0 msec
;; SERVER: 192.168.0.254#53(192.168.0.254)
;; WHEN: Thu Mar  1 10:17:20 2012
;; MSG SIZE  rcvd: 66

[root@server named]#

Let me know if you face any issues... :)

FFMPEG Complete Install on RedHat 6.0

FFMPEG installation:


first check if subversion is installed on server:

which svn

to install:

yum install subversion

then ==>>

Following are the steps to install FFmpeg + FFmpeg-PHP + Mplayer + Mencoder + flv2tool + LAME MP3 Encoder + Libog on a Linux

server or VPS Hosting Manually. There are many automated scripts available which install these but its better to do it

manually as in case of an error occuring during the installation process, we can stop the installation and fix them. These

steps also include the common fixes for such errors.


mkdir /usr/local/src/ffmpeg_mods


cd /usr/local/src/ffmpeg_mods

DOWNLOAD MODULES

wget http://www.mplayerhq.hu/MPlayer/releases/codecs/essential-amd64-20071007.tar.bz2
wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
wget http://sourceforge.net/projects/lame/files/lame/3.99/lame-3.99.tar.gz/download
wget http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/0.6.0/ffmpeg-php-0.6.0.tbz2/download
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz

EXTRACT MODULES

tar zxvf lame-3.99.tar.gz
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.1.2.tar.gz
tar zxvf flvtool2_1.0.5_rc6.tgz
tar jxvf essential-amd64-20071007.tar.bz2
tar jxvf ffmpeg-php-0.6.0.tbz2

CREATING A FOLDER TO SAVE Linux DLLs

mkdir /usr/local/lib/codecs

CHECK IF ALL PRE_REQUIREMENTS ARE MET

rpm -qa gcc   
rpm -qa |grep gcc   
rpm -qa |grep lib   
rpm -qa |grep libcpp   
rpm -qa |grep libgcc   
rpm -qa |grep ruby   
rpm -qa |grep ncurses-devel
rpm -qa |grep gcc-c++

DOWNLOAD Mplayer & FFMPEG

svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer

cd /usr/local/src/ffmpeg_mods/mplayer/
svn update   

cd ..   

mv essential-amd64-20071007/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/   

## INSTALLING MODULES:

1] LAME

cd lame-3.99   
./configure   
make   
make install

2] LIBOGG

cd ../libogg-1.1.3
./configure --enable-shared && make && make install

rpm -qa |grep gcc*            ; If you don't have gcc-c++ you must install it here
                    ; Install gcc-c++ and try again.

./configure --enable-shared && make && make install
PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH

3] LIBVORBIS

cd ../libvorbis-1.1.2   
./configure && make && make install   

cd ../flvtool2_1.0.5_rc6   
ruby setup.rb config   
ruby setup.rb setup   
ruby setup.rb install   

4] MPLAYER

cd ../mplayer/   
./configure && make && make install   

5] FFMPEG

cd ../ffmpeg/   
./configure --enable-libmp3lame --enable-libvorbis --disable-mmx --enable-shared
make   
make install   
export LD_LIBRARY_PATH=/usr/local/lib/
ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
ln -s /usr/local/lib/libavformat.so.52 /usr/lib/libavformat.so.52
ln -s /usr/local/lib/libavcodec.so.52 /usr/lib/libavcodec.so.52
ln -s /usr/local/lib/libavutil.so.50 /usr/lib/libavutil.so.50
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0

6] FFMPEG-PHP

cd ../ffmpeg-php-0.6.0
phpize                    ; Since I was installing this on custom RedHat, I had to install php-devel ...
                    ; ... and in order to install that I had to install autoconf and automake
                    ; If you are in same situation then you can try a) & b) else, skip it !!

    a) INSTALL AUTOCONF
        wget http://mirror.centos.org/centos/6/os/i386/Packages/autoconf-2.63-5.1.el6.noarch.rpm
        rpm -ivh autoconf-2.63-5.1.el6.noarch.rpm

    b) INSTALL AUTOMAKE
        wget ftp://mirror.switch.ch/pool/1/mirror/scientificlinux/6.1/x86_64/os/Packages/automake-1.11.1-

1.2.el6.noarch.rpm
        rpm -ivh automake-1.11.1-1.2.el6.noarch.rpm

    c) Now, you can install php-devel

        wget ftp://ftp.ntua.gr/pub/linux/scientificlinux/6.0/x86_64/os/Packages/php-devel-5.3.2-6.el6.x86_64.rpm
        rpm -Uvh php-devel-5.3.2-6.el6.x86_64.rpm --nodeps

cd ../ffmpeg-php-0.6.0
phpize   

./configure
make                    ; If you get any errors regarding undeclared functions in ffmpeg_frame.c or any .c    

                    ; file just do this

cp /usr/local/include/libavcodec/* /usr/local/include/ffmpeg/
cp /usr/local/include/libavcore/* /usr/local/include/ffmpeg/
cp /usr/local/include/libavdevice/* /usr/local/include/ffmpeg/
cp /usr/local/include/libavfilter/* /usr/local/include/ffmpeg/
cp /usr/local/include/libavformat/* /usr/local/include/ffmpeg/
cp /usr/local/include/libavutil/* /usr/local/include/ffmpeg/
cp /usr/local/include/libswscale/* /usr/local/include/ffmpeg/

Although, you might have to replace "PIX_FMT_RGBA32" with "PIX_FMT_RGBA" everywhere in file ffmepg_frame.c

make
make install

echo 'extension=ffmpeg.so' >> /etc/php.ini

NOTICE: Make sure this is the correct php.ini for the box!!

RESTART APACHE

service httpd restart
       
php -m |grep ffmpeg            ; Just confirm if it is there ;)

CHECK BINARY PATHS FOR THE MODULES

[root@server ffmpeg-php-0.6.0]# which ffmpeg
/usr/local/bin/ffmpeg
[root@server ffmpeg-php-0.6.0]# which mplayer
/usr/local/bin/mplayer
[root@server ffmpeg-php-0.6.0]# php -m |grep ffmpeg
ffmpeg
[root@server ffmpeg-php-0.6.0]# which lame
/usr/local/bin/lame
[root@server ffmpeg-php-0.6.0]# which flvtool2
/usr/bin/flvtool2


Now, before you check the version for ffmpeg you need to do this.

Check to see if /usr/local/lib exists on this file
cat /etc/ld.so.conf

If not
echo /usr/local/lib >>/etc/ld.so.conf

cat/etc/ld.so.conf Now check to see if (/usr/local/lib exist)
save file
ldconfig

Now,

ffmpeg -V

Done...!!!

Thursday 1 March 2012

Configuring DHCP server on Redhat 6 with Static and Dynamic IP

## Configuring DHCP server on Redhat 6

Before we begin, I assume that you have FQDN and Static IP for server machine. In this case, they are example.com and 192.168.0.254 respectively. Now, lets start with configuring our own DHCP server.



Step # 1: Install DHCP.

[root@server named]# yum install dhcp*

Step # 2: Configure DHCP.

[root@server ]# vi /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#
ddns-update-style none;
option domain-name "example.com";            --> Domain name for DHCP server
option domain-name-servers 192.168.0.254;  --> IP address of DHCP server
default-lease-time 21600;
max-lease-time 43200;

subnet 192.168.0.0 netmask 255.255.255.0
{
        option routers 192.168.0.4;                  --> Defining Gateway
        option subnet-mask 255.255.255.0;
        range 192.168.0.10 192.168.0.200;       --> IP Addresses Pool [Dynamic]
}

host test
{
hardware ethernet 00:12:3F:7F:2E:65;        --> this provides Static IP address to the client machine
fixed-address 192.168.0.14;                              with given Hardware Address (MAC) [Static]
}
[root@server ]#

Step # 3: Start DHCP.

[root@server ]# /etc/init.d/dhcpd start
Starting dhcpd:                                            [  OK  ]
[root@server ]#

That's it, you have now configured your own DHCP server. You can now go to your client machine and enter gateway whichever you have mentioned in DHCP configuration (in above case "192.168.0.4") and reload network service.