Friday, February 2, 2018

Setting up DNS (Domain Name server) on CentOS 7 / RHEL 7

Hello friends,

I will show you how to configure DNS in CentOS 7 Linux. Let see How to configure BIND DNS Master server on CentOS 7.
DNS is used for name resolution.
DNS configuration is very useful to recognize your server with FQDN in LAN and WAN. You can ping your server with server name with in LAN (from any workstation) and WAN.
Following steps are useful to configure DNS.
Change HostName (give proper hostname with fully qualified domain name)
Set hostname first (here my hostname is anand.linuxserver.com)
# vi /etc/hosts
127.0.0.1     localhost localhost.localdomain localhost4 localhost4.localdomain4
::1                 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.105     anand.linuxserver.com anand


# vi /etc/hostname
Here you type correct hostname (FQDN) Fully Qualified Domain Name.
Or
# nmtui    à command for change hostname (easy way)
   nmtui -Select Set HostName   
Check you IP Address is correct or not and confirm.

# ifconfig

Here in this example my IP Address is 192.168.0.105 and Host Name is anand.linuxserver.com

# ls –al /etc/sysconfig/network-scripts/

In this directory you will find ifcfg-eth0 or eno(some numbers) linux nic card details that you can view using ifconfig command.
Now bind packages installed.
What is BIND in DNS ?
BIND (Berkely Internet Name Domain) is a popular software for translating domain names into IP addresses and usually found on Linux servers.
BIND's configuration consists of multiple files,
yum install bind bind-utils
Confirm the prompt by entering  y

bind-9.9.4-51.el7_4.2.x86_64

bind-utils-9.9.4-51.el7_4.2.x86_64

bind-license-9.9.4-51.el7_4.2.noarch

bind-chroot-9.9.4-51.el7_4.2.x86_64

rpcbind-0.2.0-42.el7.x86_64

bind-libs-lite-9.9.4-51.el7_4.2.x86_64

bind-libs-9.9.4-51.el7_4.2.x86_64


Above packages are important and this will install by YUM.
YUM will resolved dependency error.
After installation of bind packages edit /etc/named.conf file.
Make few changes in the file as shown in below.
Here My IP ADDRESS is 192.168.0.105 and Hostname is anand.linuxserver.com
# Vi /etc/named.conf

        listen-on port 53 { 127.0.0.1; 192.168.0.105; };

       #listen-on-v6 port 53 { ::1; };

 

        allow-query     { localhost; 192.168.0.0/24; };

        # allow-transfer{ localhost; 192.168.0.0/24; };

 

zone "linuxserver.com" IN {

type master ;

file "anand.zone" ;

allow-update { none;};

};

 

zone "0.168.192.in-addr.arpa" IN {

type master ;

file "anand.local" ;

allow-update { none; };

};


Save the file and exit, check the permission of file .
Permission should be 775 and owner, group should be root and named.
Command is “chmod 775 /etc/named.conf “  ; chown root:named /etc/named.conf
Now nest step is very important be care full while typing.
Change the directory /var/named
# cd /var/named
List the files using command “ls –al” you will list the files and directories.
Few files already present with DNS configuration contents .
Example :- named.ca, named.empty, named.localhost, named.loopback
Easiest method for to configure DNS with your own DNS name .
Copy named.localhost to yourDNSname.zone
In my example I have given anand.zone name is /etc/named.conf file.
Make sure you are in /var/named directory
Here I am creating zone file, this would be a my forward zone file.
Command is à # cp named.localhost  anand.zone
Content of my file is as follows.

$TTL 1D

@    IN SOA    anand.linuxserver.com. root.anand.linuxserver.com. (

                    0    ; serial

                    1D    ; refresh

                    1H    ; retry

                    1W    ; expire

                    3H )    ; minimum

 

@                     IN  NS anand.linuxserver.com.

anand     IN  A   192.168.0.105


Save file and exit.

Now I creating reverse zone file
Copy file from same directory, command is à cp named.loopback anand.local
Open into editor and change with following contents .

$TTL 1D

@    IN SOA anand.linuxserver.com.  root.anand.linuxserver.com. (

                    0    ; serial

                    1D    ; refresh

                    1H    ; retry

                    1W    ; expire

                    3H )    ; minimum

 

@ IN  NS    anand.linuxserver.com.


save and exit from this file.
Change the permission of the files.
# chmod 775 anand.zone anand.local
# chown named:named  anand.zone anand.local
Edit the file /etc/resolve.conf
# vi /etc/resolve.com  à make few changes as mentioned below.

search linuxserver.com

nameserver 192.168.0.105


# named-checkzone anand.zone /var/named/anand.zone
# named-checkzone anand.local /var/named/anand.local
If the configuration is correct then you will get OK prompt

Now start the service of named
# systemctl enable named.service
# systemctl restart named.service
# firewall-cmd –permanent –add-port=53/tcp
# firewall-cmd –permanent –add-port=53/udp
# firewall-cmd --reload
Last command to check DNS is properly configured .
# dig anand.linuxserver.com

; <<>> DiG 9.9.4-RedHat-9.9.4-51.el7_4.2 <<>> anand.linuxserver.com

;; global options: +cmd

;; Got answer:

;; ->>HEADER<<- 28031="" id:="" noerror="" o:p="" opcode:="" query="" status:="">

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

 

;; OPT PSEUDOSECTION:

; EDNS: version: 0, flags:; udp: 4096

;; QUESTION SECTION:

;anand.linuxserver.com.         IN      A

 

;; ANSWER SECTION:

anand.linuxserver.com.  86400   IN      A       192.168.0.105

 

;; AUTHORITY SECTION:

linuxserver.com.        86400   IN      NS      anand.linuxserver.com.

 

;; Query time: 0 msec

;; SERVER: 192.168.0.105#53(192.168.0.105)

;; WHEN: Thu Feb 01 21:29:46 IST 2018

;; MSG SIZE  rcvd: 80


You will get similar output on screen.
Please remember in above output check the ANSWER section.
I hope this will help you to configure DNS.
Leave your comments or question if any I am appreciate your feedback.

Cheers and good luck.

Saturday, March 29, 2014

CentOS / REDHAT 6.5 Linux Installation with Kickstart – NFS and DHCP.


CentOS / REDHAT 6.5 Installation with Kickstart – NFS and DHCP.

Friends .

Here today we will see CentOS Linux installation with Kickstart NFS and DHCP .

Linux Installation :- Many peoples or Linux engineers are prefer to automated OS installation on their machine / desktop. Redhat / CentOS Linux has a different types of installation methods. While reading Redhat manuals and searching on internet you will come to know different methods of Linux installation. However I will explain you the remote installation of CentOS / Redhat Linux using Kickstart method. This is very easy method. Once you understand I am sure you will enjoy.

What is kickstart ?
Kickstart is one installation method In Redhat Linux automatically perform operating system installation and configuration. Kickstart is normally used to allow easy remote installation and consistent configuration of new computer systems.

NFS:- Network file system
In my installation I am using NFS method because this is not require any firewall limitation port open / block in LAN.
For FTP or HTTP you require open ports for security reason.

DHCP:- This is require for to assigned IP address and SubNet .

Following steps are used for Kickstart installation.

In my case I have already installed CentOS 6.5 X86 32 bit on One of my server.

My server's IP address is 192.168.0.222

Packages require for kickstart. I hope you might be having yum configure at your system.

If yum is configured then simply type at root prompt .

# yum install *kiskstart* nfs* dhcp* ( this will install dependencies )

1. pykickstart-1.74.14-1.el6.noarch.rpm
2. system-config-kickstart-2.8.6.5-1.el6.noarch.rpm

Packages require for DHCP

1. dhcp-devel-4.1.1-38.P1.el6.centos.i686.rpm
2. dhcp-4.1.1-38.P1.el6.centos.i686.rpm
3. dhcp-common-4.1.1-38.P1.el6.centos.i686.rpm
4. dhcping-1.2-4.el6.i686..rpm

Packages require for NFS.

NFS packages is already installed while installing OS only thing is you have to configure NFS .

First I will configure NFS.

I have stored CD dump into /data/CentOS-6.5/ folder.

Next step is configure DHCP.

If you already having dhcp then no need to configure again.

My network range for assign IP is 192.168.0.100 192.168.0.254
subnet is 255.255.255.0

Here my /etc/dhcp/dhcpd.conf file will looklike follows.

default-lease-time 600;
max-lease-time 7200;

subnet 192.168.0.0 netmask 255.255.255.0 {
range 192.168.0.100 192.168.0.254 ;
filename "/data/CentOS-6.5/kickstart.cfg" ;
next-server 192.168.0.222 ;
}

Now type following command at root prompt.

# system-config-kickstart 

This command pop up following window.



Once each section of the configuration is complete, simply save the configuration file in /data/CentOS-6.5/kickstart.cfg .

File can readable. It is in simple text format.

Remember main thing is “Installation method” select installation source “NFS”

NFS Server = “192.168.0.222” --- my dump server IP address.
NFS Directory = “/date/CentOS-6.5” --- CD dump directory.

Now the actual test of kickstart installation.

Start and boot second server with installation media or bootable CD or DVD.
At the boot prompt, press the "Tab" key to amend the boot options



Erase the default boot parameter and Press Enter


Simple type at boot prompt.
boot:- linux ks=nfs:192.168.0.222:/data/CentOS-6.5/kickstart.cfg

This will help you lot for remote installation.




Friday, November 4, 2011

what is File links in Linux / Unix

Hi friends,

Now we will discuss about the links in Linux OS and little bit an Inode because it's part of links. Your comments and suggesstion are welcome.

Links is very usefull in Linux and Unix Operating system but it should be properly applied.
In short Links means if your file present anywhere in file systems and that file has mirror copy.
Assume that file “abcd.doc” you have created. While creating file Linux system gives a unique an INODE number to the file. All files and directories has a an Inode number.
The inode contains information about the file. (Information is file type, permission, User ID, Group ID, File size, File save date and time, location of the file on HDD).

To see an Inode number of the file command is :-

ls -il

Now coming back to link files, In Linux/Unix systems there are two types of links First symbolic or soft link and second is hard link.

Sybmbolic or Soft link :- Two inodes will create one contains the actual data of the file, the other serves as a pointer to the first file, containing only the first file's name. Symbolic links may point to any file or directory irrespective of the volumes on which the source and destination reside.
Symbolic links refer to a symbolic path indicating the abstract location of another file.

Command is for to create a symbolic link is :-

ln -s abcd.doc abcd_new.doc

If you want to link in a separate directory

ln -s /usr/abcd.doc /var/abcd_new.doc

Command for link remove is :-

unlink /var/abcd_new.doc

This command will stop the link between original file and copy of the file and also remove the copy of the file.

Hard Link : This link will not create two Inodes. Link file will share Inode of original file.
HardLink cannot links directories and also cannit cross file system.
Hard links, refer to the specific location of physical data.

Command for to create hard link :-

ln abcd.doc abcd_new.doc

Tuesday, February 16, 2010

YUM configuration and XEN virtulization in RedHat 5.

Hi friends,

Please see the step by step yum configuration and XEN virtulization configuration. I wish this will help you more.
Your comments are welcome.



1.Yum configuration in Red Hat 5.x and XEN Virtualization

Here is a step by step Yum configuration.

Either you can make a separate partition or make a separate folder in / directory
Here in my case I am making /data/redhat directory
I am coping all 5 CDs of Red Hat 5.2 OS to /data/redhat folder using following command.
1.mount CD 1 and give this command
# cd /media/RHEL-5.3\ i386\ Disc\ 1/
2.# cp -av * /data/redhat/
3.Repeat step 1 and step 2 for rest of all CDs (CD2, CD3, CD4, CD5).
4.# createrepo -v /data/redhat for to create a local Yum Repository.
5.Configure ftp server with following steps.
6.Open /etc/vsftpd/vsftpd.conf file and make necessary changes.
anonymous_enable=YES
local_enable=YES
anon_root=/data/redhat/Server
7.Open /etc/yum.repos.d/base.repo
[Server--RHEL5]

name = RHEL 5.3

baseurl=file:///data/redhat/
#ftp service not require.
Or
baseurl=ftp://SERVER-IP/ # ftp service require to install client side.
enabled=1

gpgcheck=0

8.service vsftpd restart
9.service yum-updatesd restart
10.If you are trying to install and configure yum on same server ftp server will not require even if you configure ftp service on same server this will work, it is optional .
11.Now you can install rpms and dependency using yum.
12.yum clean all
13.yum update
14.yum install
15.Here I am doing xen virtulization .
16.yum install xen virt-manager kernel-xen
17.restart your server
18.make sure your system in booting form kernel /xen.gz-2.6.18-128.el5
19.To check your system boot in new kernel use command uname -a
20.use command to '#virt-manager & ' for Create new domains.
21.On command prompt type following command.
22.# virt-install --paravirt --name OSNAME --ram 512 --file /data/vm/OS.img --file-size 9 --network network:default --vnc --cdrom /dev/cdrom-sr0
23.In my system I used following example..
]# virt-install

What is the name of your virtual machine? RedHat5.3

How much RAM should be allocated (in megabytes)? 512

What would you like to use as the disk (file path)? /data/vm/rhel.img

How large would you like the disk (/data/vm/rhel.img) to be (in gigabytes)? 9

Would you like to enable graphics support? (yes or no) yes

What is the install location? /dev/cdrom-sr0

24.You view all system using xm list command.


Good Luck

Anand.

Saturday, January 9, 2010

Configure DNS in REDHAT Enterprise Linux 5 / CENTOS 5

Hi,

Here I have given easy step by step DNS configuration methods in Linux, I hope this will useful for you also.

1. First change or assign a host Name to your server; in this example my host Name is server.anand.com and my IP address is 192.168.50.196.

files /etc/hosts , /etc/sysconfig/network.
2. Download or Install following RPMS from CD/DVD of Linux OS.
RPMS :-
bind-utils-9.3.4-10.P1.el5

bind-sdb-9.3.4-10.P1.el5

bind-libs-9.3.4-10.P1.el5

bind-9.3.4-10.P1.el5

system-config-bind-4.0.3-4.el5.centos

bind-chroot-9.3.4-10.P1.el5

bind-libbind-devel-9.3.4-10.P1.el5

bind-devel-9.3.4-10.P1.el5

caching-nameserver-9.3.4-10.P1.el5


3. My DNS server IP address is 192.168.50.196

# cd /var/named/chroot/etc

copy file named.caching-nameserver.conf to named.conf

# cp named.caching-nameserver.conf named.conf

Make the following changes (It's require).

options {

listen-on port 53 { 127.0.0.1; 192.168.50.196; };

listen-on-v6 port 53 { ::1; };

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";

query-source port 53;

query-source-v6 port 53;

allow-query { 127.0.0.1; 192.168.50.0/24; };

allow-transfer { 127.0.0.1; 192.168.50.196; };

forwarders { 127.0.0.1; 192.168.50.196; };

forward only;

};

logging {

channel default_debug {

file "data/named.run";

severity dynamic;

};

};

view localhost_resolver {

match-clients { localhost; 192.168.50.0/24; };

match-destinations { localhost; 192.168.50.0/24; };

recursion yes;

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

};

Save this file and exit

4. Save this file and exit

copy named.conf file to /etc directory.

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

5. # cd /etc

6. Open /etc/named.rfc1912.zones

zone "anand.com" IN {

type master;

file "anand.zone";

allow-update { none; };

allow-query { any; };

};


zone "50.168.192.in-addr.arpa" IN {

type master;

file "anand.local";

allow-update { none; };

allow-query { any; };

};

7. cd /var/named/chroot/var/named

8. cp localhost.zone anand.zone
9. cp named.local anand.local
10. Edit anand.zone and make the following changes.


$TTL 86400

@ IN SOA server.anand.com. root.server.anand.com. (

42 ; serial (d. adams)

3H ; refresh

15M ; retry

1W ; expiry

1D ) ; minimum

@ IN NS server.anand.com.

server.anand.com. IN A 192.168.50.196

ldaplinux.anand.com. IN A 192.168.50.115 # Client

myclient-no1 IN A 192.168.50.141 # Client

www IN CNAME server.anand.com.

ftp IN CNAME server.anand.com.

Save this file and exit


11. Edit anand.local and make the following changes

$TTL 86400

@ IN SOA server.anand.com. root.server.anand.com. (

1997022700 ; Serial

28800 ; Refresh

14400 ; Retry

3600000 ; Expire

86400 ) ; Minimum

@ IN NS server.anand.com.

196 IN PTR server.anand.com.

115 IN PTR ldaplinux.anand.com. # Client

141 IN PTR myclient-no1. # Client


Save this file and exit.

12. chown root:named anand.zone Permission 775
13. chown root:named anand.local Permission 775
14. chown root:named /var/named/chroot/etc/named.conf permission 775
15. chown root:named /etc/named.conf permission 775
16. chown root:named /etc/named.rfc1912.zones permission 775 This file link with /var/named/chroot/etc/named.rfc1912.zones

On Final DNS server.

# service named start
# chkconfig named on

To check DNS configuration is correct or wrong use following command.

# dig anand.com or dig -x 192.168.50.196

Here I am using dig -x 192.168.50.196

dig -x 192.168.50.196

; <<>> DiG 9.3.4-P1 <<>> -x 192.168.50.196

;; global options: printcmd

;; Got answer:

;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29928

;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:

;196.50.168.192.in-addr.arpa. IN PTR

;; ANSWER SECTION:

196.50.168.192.in-addr.arpa. 86400 IN PTR server.anand.com.

;; AUTHORITY SECTION:

50.168.192.in-addr.arpa. 86400 IN NS server.anand.com.

;; ADDITIONAL SECTION:

server.anand.com. 86400 IN A 192.168.50.196

;; Query time: 11 msec

;; SERVER: 192.168.50.196#53(192.168.50.196)

;; WHEN: Sat Jan 9 20:29:30 2010

;; MSG SIZE rcvd: 105


QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

All the four sections means Query: 1, Answer: 1, Authority: 1, Additional: 1 .

If it is 0 then you have to check all steps again properly.

Client Configuration:-

1.

Edit file /etc/resolv.conf
2.

make the following changes

search anand.com

nameserver 192.168.50.196 # DNS server IP Address



I hope these all steps will help you to configure DNS.

Anand Mane.