06 June 2012

howto configure DNS on redhat 7

yum install bind 
yum install bind-utils
yum install caching-nameserver
service named restart
chkconfig named on

vi /etc/named.caching-nameserver.conf
options {
  listen-on port 53 { 127.0.0.1; machine-IP; };
  allow-query     { any; };
  forwarders { 8.8.8.8; 8.8.4.4; };
...
};

service named restart
dig www.google.com @machine-IP
;; ANSWER SECTION:
www.google.com.         101137  IN      CNAME   www.l.google.com.
www.l.google.com.       262     IN      A       74.125.225.177
www.l.google.com.       262     IN      A       74.125.225.178
www.l.google.com.       262     IN      A       74.125.225.179
www.l.google.com.       262     IN      A       74.125.225.180
www.l.google.com.       262     IN      A       74.125.225.176
...
vi /etc/named.caching-nameserver.conf
#view localhost_resolver {
#   match-clients      { localhost; };
#   match-destinations { localhost; };
#   recursion yes;
#   include "/etc/named.rfc1912.zones";
#};
include "/etc/named.humblesimple.com.zones";

cat > /etc/named.humblesimple.com.zones << EOF
zone "humblesimple.com" IN {
        type master;
        file "named.humblesimple.com-forward";
        allow-update { none; };
};

zone "10.21.168.198.in-addr.arpa" IN {
        type master;
        file "named.humblesimple.com-reverse";
        allow-update { none; };
};
EOF

cat > /var/named/named.humblesimple.com-forward << EOF
$TTL 1D
@       IN SOA  humblesimple.com.     root (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        IN      A       192.168.21.10
        IN      NS      192.168.21.10
server1 IN      A       192.168.21.11
EOF

cat > /var/named/named.humblesimple.com-reverse<< EOF
$TTL 1D
@       IN SOA  @ humblesimple.com. (
                                        0       ; serial
                                        1D      ; refresh
                                        1H      ; retry
                                        1W      ; expire
                                        3H )    ; minimum
        NS      @
        PTR     192.168.21.10.
EOF

service named restart
dig server1.humblesimple.com @machine-IP
;; ANSWER SECTION:
server1.humblesimple.com. 86400 IN      A       192.168.21.11
...
Reference:
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch18_:_Configuring_DNS

23 April 2012

Combine multiple PDFs into one file

we will see one example how to combine pdf files let us assume we have 001.pdf, 002.pdf files and now we need to combine this files using the following command

gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH 001.pdf 002.pdf

gswin32c.exe -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=combinedpdf.pdf -dBATCH 001.pdf 002.pdf

In the above command after “-sOUTPUTFILE=” type whatever name you want for the merged file (don’t forget to append .pdf to the end of the file name).

After you run the above command, a new PDF file called combinedpdf.pdf will be created with your individual files merged according to the order you list.

Reference:
http://www.debianadmin.com/combine-multiple-pdfs-into-one-file-in-ubuntu-linux.html
http://www.rizauddin.com/2009/04/how-to-merge-or-combine-pdf-files-with-ghostscript

29 December 2011

Disable Control-C [ CTRL+C ] in linux

Signals are the notification send to a process on the occurrence of an event.

#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <unistd.h>

struct sigaction act;

void sighandler(int signum, siginfo_t *info, void *ptr)
{
    printf("Received signal %d\n", signum);
    printf("Signal originates from process %lu\n",
        (unsigned long)info->si_pid);
}

int main()
{
    printf("I am %lu\n", (unsigned long)getpid());

    memset(&act, 0, sizeof(act));
#if 0
    act.sa_sigaction = sighandler;
    act.sa_flags = SA_SIGINFO;
    sigaction(SIGINT, &act, NULL);
#endif
#if 0
    act.sa_handler = SIG_IGN;
    sigaction(SIGINT, &act, NULL);
#endif

    signal(SIGINT, SIG_IGN);

    // Waiting for CTRL+C...
    sleep(100);

    return 0;
}

Reference:
http://nixcraft.com/shell-scripting/12605-shell-script-disable-ctrl-c-ctrl-z.html