DNS Server in Linux



DNS Server (reverse)
--------------------------

#vi /var/named/chroot/etc/named.conf

      options
      {
            directory "/var/named";
   
      };
      #        include "/etc/named.root.hints";

            zone "morshed.local" {
                  type master;
                  file "morshed.local.forward.db";
      };
            zone "0.168.192.in-addr.arpa" IN {
            type master;
            file "morshed.local.reverse.db";
      };
 
  2. cd /var/named/chroot/var/named
  3. cp morshed.local.forward.db morshed.local.reverse.db
  4. vi /var/named/chroot/var/named/morshed.local.reverse.db
     
 $TTL 86400
 @       IN      SOA     localhost. root.localhost.  (
                                      1997022700 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum
        IN      NS      localhost.

101               IN    PTR   morsehd.local.
20(others ip)           IN    PTR   WWW.morshed.local.
 # dig -x 192.168.0.101(test)(x is used for
Then you can get question section & answer section
 

Red Hat Linux Essential

I want to write here with some importance Command of Red Hat Linux Essential. If you follow this command you can make yourself as a Linux Essential experts. I believe that you are able to improve your knowledge in Linux.

Follow The bellow Command ...

  Red hat Essential  

#startx
#vim /etc/issue
   Welcome!
#passwd student
#su - student
#id student
#date
#date 10 21 05 42 2011
#cal 5 2010

#whatis cal
#cal --help
#man -K|k keyword
#man print
#info vim
#foo -y -abc one.txt two.txt
#pwd
#ls -l /lv1
#ls -la /tmp
#ls -ld /etc
#cd
#ls -lR /home/users
#cd ..
#cd /etc/system
#cd -
#cp /etc/passwd /tmp
#cp -r /etc/ /tmp
#cp /pearctice/* /tmp
#cp -r /practice/* /tmp
#cp -rpv /etc/sysconfig /backup/sysconfig12102011
#mv /practice /tmp
#touch /newfile
#touch {report,graph}_{jan,feb,mar}
#rm -rf /tmp/newdir (dir with file)
#rmdir /tmp/practice (empty dir)
#mkdir /test
#mkdir -p /practice/new/user
#file /etc/passwd (prints file type)
#chown root /practice/new
#chown -R root /practice/ (recursively)
#chown root:marketing /practice
#chgrp accounting /practice/new
#chgrp -R accounting /practice/
#chmod u|g|o| +|-|= r,w,x,s,t /practice
#chmod u+w /practice
#chmod o+t /practice
#chmod 764 /practice
#echo ?o*
#history
#!! (repeats last cmd)
#!ca (repeats command begins with "ca")
#!232 (repests command with history number)
#vim .bashrc
   export HISTCONTROL=ignoreboth
   alias c='clear'
#alias c=clear
#echo file {1,2,3}
#echo "this system's name is $(hostname)" (command expansion)
#echo "this system's name is `hostname`" (command expansion)
#vim /script
  #!/bin/bash
   /bin/echo hello
#chmod u+x /script
#vim /testscript
 #!/bin/bash
   cp -av /etc/sysconfig /backup/sysconfig-$(date '+%y%m%d')
  echo "back up of /etc/sysconfig completed at: $(date)"

#find /etc -name passwd
#find /etc -name passwd > /redirect
#find /etc -name passwd >> /redirect
#find /etc -name passwd &>> /redirect
#ls -l /etc | tr 'A-Z ' 'a-z'
#ls -l /etc | less
#echo "test mail" | mail -s test user1@localhost
#echo "test printer" | lpr -P printer1
#ls -lR /etc | tee stage1.out | sort | tee stage2.out | sort -r | tee stage3.out | less
#tr 'A-Z' 'a-z' < .bash_profile
    or
#cat .bash_profile | tr 'A-Z' 'a-z'
#mail -s "test" user1@localhost <<end
      hi susan
      please call me
      brad
      end

## looping#####
#vim /bin/script
   #!/bin/bash
     for n in {1..10}; do
     ping -c2 192.168.0.$n
     done

#chmod u+x /bin/script
####Test all host at a time###### 
#vim /bin/script1
   #!/bin/bash

     for n in {1..10}; do
     host = 192.168.0.$n
     ping -c2 $host > /dev/null
     if [ $? = 0 ]; then
        echo "$host is success"
    else
       echo "$host is failed"
    fi
    done

#chmod u+x /bin/script

#####shutdown all workstation from server

#vim /bin/script1
   #!/bin/bash

     for n in {1..10}; do
     host = 192.168.0.$n
     ping -c2 $host > /dev/null
     if [ $? = 0 ]; then
        ssh root@$host reboot/poweroff
    else
       echo "$host is blocked"
    fi
    done
#### conditional exicution#####

#!/bin/bash
for x in $(seq 1 10); do
echo adding testuser$x
(
echo -ne "testuser$x\t"
useradd testuser$x 2>&1 > /dev/null && passwd testuser$x
) >> /tmp/userlog
done
echo 'cat /tmp/userlog to see new paswrds'

#cat /etc/passwd 
#less /etc/paswd
 q to quit
#cat -b /proc/meminfo (with number of each line)
#cat -A /proc/meminfo (show all character,including non printing)
#head /etc/passwd
#head -n 15 /etc/passwd
#tail -n 3 /etc/passwd
#tail -f /var/log/cron
#tail -f /var/log/messages
#grep 'user1' /etc/passwd
#date --help | grep year
#grep -n user1 /etc/passwd (prints the number of matches)
#ps ax | grep init (shows all process and grep init strings)
#grep root /etc/passwd | cut d : -f 7 (cut practice)
#cut -f3 -d: /etc/passwd
#wc /etc/passwd
#wc -m /etc/passwd (bytes)
#wc -l /etc/passwd (only lines)
#wc -w /etc/passwd (only words)
#sort -r /etc/passwd
#cut -f7 -d: /etc/passwd | sort | uniq (uniq)
#diff -u /practice/file /practice/file1 > file2.patch
#patch -b /practice/file1 file2.patcch
#aspell check /newfile
#aspell list < /newfile
#look wh /practice/file (looks for word begins with wh string)
what
why
#sed 's/cat/dog/gi'
#sed '1,50s/cat/dog/gi'
#sed '/digby/,/duncan/s/cat/dog/gi'/practice/file1
#sed -e 's/cat/dog/gi'-e 's/cow/goat/gi'

#vim /practice/file
 insert mode
  I (inser at begining of line)
  A(append to end)
  O(insert a new line above)
  o(insert a new line below)
 command mode
  u,U ctrl+r
#vim .vimrc
  :set number
#/sbin/ifconfig eth0
#/sbin/ifup eth0
#/sbin/ifdown eth0
#system-config-network
#vim /etc/sysconfig/network-script/ifcfg-eth0
#system-config-printer
#   /etc/cups/printer.conf
#lpr -P printer1 -#3 /file1 (3 copy)
#lpq
#lprm 6
#lpstat -a (list configured printer)
#system-config-date
#date 10 21 05 42 2011
#ps -ax | grep init
#ps -U root
#pgrep -G accounting
#pidof cupsd
#kill 2372 (if ctrl+c or 'term' not working)
#kill -term 2372
#man 7 signal
#nice -n 5 cat
#renice 5 -p pid
#top
#jobs
#bg 4
#fg 6
#at now+5min
  cat /etc/passwd
  ping -c3 server.example,com
  ctrl+d
#at -l
#at -c 7
#crontab

    25 15 24 07 1,3,5 (0-6)
  min hour day month week
#crontab -u testuser
#crontab -r; crontab -l (remove cron)
#date > /logfile | cat /logfile
#who | wc -l >> /logfile
#ping -c2 192.168.0.12 &> /dev/null
#echo $? (0 success,1-255 failure)
#vim .bashrc
  alias c='clear'
#vim /bin/script2
  #!/bin/bash
  read -P "enter server1 values:" value1 value2
  echo "value1 is $value1"
  echo "value2 is $value2"

Network Hardware Connections

Ethernet uses star topology for the physical wiring layout. A diagram of a typical ethernet network layout is
shown below.


On a network, a hub is basically a repeater which is used to re-time and amplify the network signals. In this
diagram, please examine the hubs closely. On the left are 4 ports close to each other with an x above or below them. This means that these ports are crossover ports. This crossover is similar to the arrangement that was used for serial cables between two computers. Each serial port has a transmitter and receiver. Unless there was a null modem connection between two serial ports, or the cable was wired to cross transmit to receive and vice versa, the connection would not work. This is because the transmit port would be sending to the transmit port on the other side.

Therefore note that you cannot connect two computers together with a straight network jumper cable between their network cards. You must use a special crossover cable that you can buy at most computer stores and some office supply stores for around 10 dollars. Otherwise, you must use a hub as shown here.

The hub on the upper left is full, but it has an uplink port on the right which lets it connect to another hub. The
uplink does not have a crossover connection and is designed to fit into a crossover connection on the next hub. This way you can keep linking hubs to put computers on a network. Because each hub introduces some delay onto the network signals, there is a limit to the number of hubs you can sequentially link. Also the computers that are connected to the two hubs are on the same network and can talk to each other. All network traffic including all broadcasts is passed through the hubs.

In the diagram, machine G has two network cards, eth0 and eth1. The cards eth1 and eth0 are on two different networks or subnetworks. Unless machine G is programmed as a router or bridge, traffic will not pass between the two networks. This means that machines X and Z cannot talk to machines A through F and vice versa. Machine X can talk to Z and G, and machines A though F can talk to each other and they can talk to machine G. All machines can talk to machine G. Therefore the machines are dependent on machine G to talk between the two networks or subnets.

Each network card, called a network interface card (NIC) has a built in hardware address programmed by its manufacturer. This is a 48 bit address and should be unique for each card. This address is called a media access control (MAC) address. The media, in our specific case will be the ethernet. Therefore when you refer to ethernet, you are referring to the type of network card, the cabling, the hubs, and the data packets being sent. You are talking about the hardware that makes it work, along with the data that is physically sent on the wires.
There are three types of networks that are commonly heard about. They are ethernet, token-ring, and ARCnet. Each one is described briefly here, although this document is mainly about ethernet.



Ethernet:
The network interface cards share a common cable. This cable structure does not need to form a structure, but must be essentially common to all cards on the network. Before a card transmits, it listens for a break in traffic. The cards have collision detection, and if the card detects a collision while trying to transmit, it will retry after some random time interval.

Token Ring:
Token ring networks form a complete electrical loop, or ring. Around the ring are computers, called stations. The cards, using their built in serial numbers, negotiate to determine what card will be the master interface card. This card will create what is called a token, that will allow other cards to send data. Essentially, when a card with data to send, receives a token, it sends its data to the next station up the ring to be relayed. The master interface will then create a new token and the process begins again.

ARCnet:
ARCnet networks designate a master card. The master card keeps a table of active cards, polling each one
sequentially with transmit permission.
TDP/IP includes a wide range of protocols which are used for a variety of purposes on the network. The set of protocols that
are a part of TCP/IP is called the TCP/IP protocol stack or the TCP/IP suite of protocols.
Considering the many protocols, message types, levels, and services that TCP/IP networking supports, I believe it would be
very helpful to categorize the various protocols that support TCP/IP networking and define their respective contribution to
the operation of networking. Unfortunately I have never seen this done to any real extent, but believe it would be worthwhile
to help those learning networking understand it faster and better. I cannot guarantee that experts will agree with the
categorizations that will be provided here, but they should help the reader get the big picture on the various protocols, and
thus clarify what the reason or need is for each protocol.
As mentioned previously, there are four TCP/IP layers. They are link, network, transport, and application. The link layer is
the hardware layer that provides ability to send messages between multiple locations. In the case of this document, ethernet
provides this capability. Below I define several categories some of which fit into the 4 layer protocol levels described
earlier. I also define a relative fundamental importance to the ability of the network to function at all. Importance includes
essential, critical, important, advanced, useful.
1. Essential - Without this all other categories are irrelevant.
2. Critical - The network, as designed, is useless without this ability.
3. Important - The network could function, but would be difficult to use and manage.
4. Advanced - Includes enhancements that make the network easier to use and manage.
5. Useful - Functionality that you would like to be able to use as a network user. Applications or some functionality is
supported here. Without this, why build a network?
The categories are:
Name(layer) Importance Names of protocols What it does
Hardware(link) Essential
ethernet, SLIP, PPP, Token Ring,
ARCnet
Allows messages to be packaged and sent
between physical locations.
Package management(network) Essential IP, ICMP
Manages movement of messages and
reports errors. It uses message protocols
and software to manage this process.
(includes routing)
Inter layer communication Essential ARP
Communicates between layers to allow one
layer to get information to support another
layer. This includes broadcasting
Service control(transport) Critical TCP, UDP
Controls the management of service
between computers. Based on values in
TCP and UDP messages a server knows
what service is being requested.
Application and user support Important DNS, RPC
DNS provides address to name translation
for locations and network cards. RPC
allows remote computer to perform
functions on other computers.
Network Management Advanced
RARP, BOOTP, DHCP, IGMP,
SNMP,RIP, OSPF, BGP, CIDR
Enhances network management and
increases functionality
Network Categories
Utility(Application) Useful
FTP, TFTP, SMTP, Telnet, NFS,
ping, Rlogin
Provides direct services to the user.
There are exceptions to my categorizations that don't fit into the normal layering scheme, such as IGMP is normally part of
the link layer, but I have tried to list these categorizations according to network functions and their relative importance to the
operation of the network. Also note that ethernet, which is not really a protocol, but an IEEE standard along with PPP, SLIP,
TokenRing, and ArcNet are not TCP/IP protocols but may support TCP/IP at the hardware or link layer, depending on the
network topology.
The list below gives a brief description of each protocol
l ethernet - Provides for transport of information between physical locations on ethernet cable. Data is passed in
ethernet packets
l SLIP - Serial line IP (SLIP), a form of data encapsulation for serial lines.
l PPP - Point to point protocol (PPP). A form of serial line data encapsulation that is an improvement over SLIP.
l IP - Internet Protocol (IP). Except for ARP and RARP all protocols' data packets will be packaged into an IP data
packet. Provides the mechanism to use software to address and manage data packets being sent to computers.
l ICMP - Internet control message protocol (ICMP) provides management and error reporting to help manage the
process of sending data between computers.
l ARP - Address resolution protocol (ARP) enables the packaging of IP data into ethernet packages. It is the system
and messaging protocol that is used to find the ethernet (hardware) address from a specific IP number. Without this
protocol, the ethernet package could not be generated from the IP package, because the ethernet address could not be
determined.
l TCP - A reliable connection oriented protocol used to control the management of application level services between
computers.
l UDP - An unreliable connection less protocol used to control the management of application level services between
computers.
l DNS - Domain Name Service, allows the network to determine IP addresses from names and vice versa.
l RARP - Reverse address resolution protocol (RARP) is used to allow a computer without a local permanent data
storage media to determine its IP address from its ethernet address.
l BOOTP - Bootstrap protocol is used to assign an IP address to diskless computers and tell it what server and file to
load which will provide it with an operating system.
l DHCP - Dynamic host configuration protocol (DHCP) is a method of assigning and controlling the IP addresses of
computers on a given network. It is a server based service that automatically assigns IP numbers when a computer
boots. This way the IP address of a computer does not need to be assigned manually. This makes changing networks
easier to manage. DHCP can perform all the functions of BOOTP.
l IGMP - Internet Group Management Protocol used to support multicasting.
l SNMP - Simple Network Management Protocol (SNMP). Used to manage all types of network elements based on
various data sent and received.
l RIP - Routing Information Protocol (RIP), used to dynamically update router tables on WANs or the internet.
l OSPF - Open Shortest Path First (OSPF) dynamic routing protocol.
l BGP - Border Gateway Protocol (BGP). A dynamic router protocol to communicate between routers on different
systems.
l CIDR - Classless Interdomain Routing (CIDR).
l FTP - File Transfer Protocol (FTP). Allows file transfer between two computers with login required.
l TFTP - Trivial File Transfer Protocol (TFTP). Allows file transfer between two computers with no login required. It
is limited, and is intended for diskless stations.
l SMTP - Simple Mail Transfer Protocol (SMTP).
l NFS - Network File System (NFS). A protocol that allows UNIX and Linux systems remotely mount each other's file
systems.
Network Categories
l Telnet - A method of opening a user session on a remote host.
l Ping - A program that uses ICMP to send diagnostic messages to other computers to tell if they are reachable over the
network.
l Rlogin - Remote login between UNIX hosts. This is outdated and is replaced by Telnet.
Each protocol ultimately has it's data packets wrapped in an ethernet, SLIP, or PPP packet (at the link level) in order to be
sent over the ethernet cable. Some protocol data packets are wrapped sequentially multiple times before being sent. For
example FTP data is wrapped in a TCP packet which is wrapped in a IP packet which is wrapped in a link packet (normally
ethernet). The diagram below shows the relationship between the protocols' sequential wrapping of data packets.