Monday 13 January 2014

How to configure syslog Server and Client

 Centralized log server (syslog server)

Suppose we have a server and 5 client machines. And we want to monitor the logs of all those client machines. In situations like this, we will use centralized server as a log server. Whatever events are happening in client machines, the logs will be sent to the server. So that we can monitor all the logs from a centralized server. We make use of syslog service for this.


 Features of syslog

1. Logs the daemon information to localhost
2. Logs the daemon information to Remote host
3. Logs the daemon information to List of users
4. Logs the daemon information to console

rsyslog.i386:Enhanced system logging and kernel message trapping daemon


sysklogd.i386:System logging and kernel message trapping daemons.


[root@localhost ~]# rpm -q sysklogd
sysklogd-1.4.1-46.el5
[root@localhost ~]#
[root@localhost ~]# rpm -qf /etc/syslog.conf
sysklogd-1.4.1-46.el5


# yum install sysklogd

# service syslog status
syslogd (pid  1929) is running...
klogd (pid  1932) is running...


I. Server Configuration (Where all logs will collect from remote machines)  ---- 192.168.0.140

Service name: syslog
configuration file: # vim /etc/sysconfig/syslog  ----- Server Configuration File


Port: 514

1. Open the /etc/sysconfig/syslog file and add "-r" option to the variable SYSLOGD_OPTIONS as shown below.

[root@server ~]# vim /etc/sysconfig/syslog
# Options to syslogd
# -m 0 disables 'MARK' messages.
# -r enables logging from remote machines
# -x disables DNS lookups on messages recieved with -r
# See syslogd(8) for more details
SYSLOGD_OPTIONS="-r -m 0"
# Options to klogd
# -2 prints all kernel oops messages twice; once for klogd to decode, and
# once for processing with 'ksymoops'
# -x disables all klogd processing of oops messages entirely
# See klogd(8) for more details
KLOGD_OPTIONS="-x"
#
SYSLOG_UMASK=077
# set this to a umask value to use for all log files as in umask(1).
# By default, all permissions are removed for "group" and "other".
[root@server ~]#

2. Restart the syslog service.
# service syslog restart


Shutting down kernel logger:  [  OK  ]
Shutting down system logger:  [  OK  ]
Starting system logger:       [  OK  ]
Starting kernel logger:       [  OK  ]

# chkconfig syslog on


II. Configuration for Client Machines ---- 192.168.0.108

service name: syslog
Configuration file: /etc/syslog.conf --- Client Configuration File

# vim /etc/syslog.conf

The configuration file /etc/syslog.conf has two parts
Eg:
*.info;mail.none;authpriv.none;cron.none  /var/log/messages
[selector field(Facility.priority)]        [action field]


 They are selector field and actions field. Selector field is again divided into two. Facilities and priorities.

Facility examples are (authpriv,kern,mail,local7 etc)


The priority is one of the following in ascending order: debug(0), info, notice, warning(warn), error(err), crit, alert,emerg(panic(7))


Actions can be regular files,console,list of users,remote machine ip etc.

1. Open the configuration file /etc/syslog.conf and add an entry to redirect the logs to the remote server.

# vim /etc/syslog.conf

# Log all kernel messages to the console.
# Logging much else clutters up the screen.
#kern.*                    /dev/console
*.* @192.168.0.140

# Log anything (except mail) of level info or higher.
# Don't log private authentication messages!
*.info;mail.none;authpriv.none;cron.none /var/log/messages

# The authpriv file has restricted access.
authpriv.*                                /var/log/secure

# Log all the mail messages in one place.
mail.*                                    -/var/log/maillog

# Log cron stuff
cron.*                                   /var/log/cron

# Everybody gets emergency messages
*.emerg                                 *

# Save news errors of level crit and higher in a special file.
uucp,news.crit                         /var/log/spooler

# Save boot messages also to boot.log
local7.*                               /var/log/boot.log

# FTP Log
ftp.info                               /var/log/xferlog

# Cron log
cron.*                                /var/log/cron

# Save news errors of level crit and higher in a special file.
uucp,news.crit                       /var/log/spooler

if you want to check the cron logs from a client machine, go to the appropriate log file in server machine and watch the logs.


2. Restart the service
 

# service syslog restart

Checking:-
In server open a terminal and watch /var/log/messages and restart syslog service in client. You can see the log from clinet coming to server.

# tailf /var/log/messages  -----> In Server

now restart syslod service in client machine

Dec 11 07:59:51 192.168.0.108 kernel: Kernel logging (proc) stopped.
Dec 11 07:59:51 192.168.0.108 kernel: Kernel log daemon terminating.
Dec 11 07:59:51 192.168.0.108 exiting on signal 15
Dec 11 07:59:52 192.168.0.108 syslogd 1.4.1: restart.
Dec 11 07:59:52 192.168.0.108 kernel: klogd 1.4.1, log source = /proc/kmsg started.


Here 192.168.0.108 show the response coming from the client machine.

"Date Hostname Name_of_the_application: Actual_log_message"
 

Dec 11 07:59:51 192.168.0.108 kernel:KernelLogging(proc)stopped.
  Date           Hostname   Name_of_the_application:

                                Actual_log_message
  
Allow the port 514 and UDP connection in IPtables if you are using any.


# The Default rule i used is DROP, so you can use the rule as your own

# Allow incoming and outgoing syslogd services
# INCOMING

-A INPUT -i eth0 -p udp --dport 514 -m state --state NEW,ESTABLISHED -j ACCEPT

-A OUTPUT -o eth0 -p udp --sport 514 -m state --state ESTABLISHED -j ACCEPT


# OUTGOING
-A OUTPUT -o eth0 -p udp --dport 514 -m state --state NEW,ESTABLISHED -j ACCEPT

-A INPUT -i eth0 -p udp --sport 514 -m state --state ESTABLISHED -j ACCEPT

Wednesday 1 January 2014

How to install VMWare VSphere Client

Installing Active Directory on Windows Server2008

Installing Active Directory on Windows Server 2008    

Microsoft Active Directory provides the structure to centralize the network management and store information about network resources across the entire domain. 


Active Directory uses Domain Controllers to keep this centralized storage available to network users.

In order to configure a Windows Server 2008 machine to act as Domain Controller, several several steps should be performed.

Installing Active Directory Domain Services (AD-DS)

1. installation of Active Directory Domain Services (AD-DS) role on the server. In fact, the AD-DS role is what enables the server to act as a Domain Controller.
2. After that run DCPROMO to promote the server as Domain Controller.

AD-DS can be installed in one of 3 methods:

It's better always setting a hostname for the machine before installation mycomputer-------->Properties------->

1.1 Open Server Manager by clicking the icon in the Quick Launch toolbar, or from the Administrative Tools folder.


1.2 Wait till it finishes loading, then click on Roles > Add Roles link.


1.2.1 In the Before you begin window, click Next.


1.2.2 In the Select Server Roles window, click to select Active Directory Domain Services, and then click Next.


1.2.3 In the Active Directory Domain Services window read the provided information if you want to, and then click Next.


1.2.4 In the Confirm Installation Selections, read the provided information if you want to, and then click Next.


1.2.5 When it ends, click Close.


1.2.6 Going back to Server Manager, click on the Active Directory Domain Services link, and note that there's no information linked to it, because the DCPROMO command has not been run yet.

2. Now you can click on the DCPROMO link, or read on.

To run DCPROMO, enter the command in the Run command, or click on the DCPROMO link from Server Manager > Roles > Active Directory Domain Services
                                                              (dcpromo.exe)   

2.1  Depending upon the question if AD-DS was previously installed or not, the Active Directory Domain Services Installation Wizard will appear immediately or after a short while.
 

     Click Next.                       

2.2 In the Operating System Compatibility window, read the provided information and click Next.


2.3 In the Choosing Deployment Configuration window, click on "Create a new domain in a new forest" and click Next.


2.4 Enter an appropriate name for the new domain. Make sure you pick the right domain name, as renaming domains is a task you will not wish to perform on a daily basis. Click Next.
     ctechz.blogspot.com
 

Note: Do NOT use single label domain names such as "mydomain" or similar. You MUST pick a full domain name such as "mydomain.local" or "mydomain.com" and so on.
 

The wizard will perform checks to see if the domain name is not already in use on the local network

2.5 Pick the right forest function level. Windows 2000 mode is the default, and it allows the addition of Windows 2000, Windows Server 2003 and Windows Server 2008 Domain Controllers to the forest you're creating.

Pick the right domain function level. Windows 2000 Native mode is the default, and it allows the addition of Windows 2000, Windows Server 2003 and Windows Server 2008 Domain Controllers to the 
domain you're creating.

If you select "Windows Server 2008" for the forest function level, you will Not be prompted to pick a domain function level.

2.6 The wizard will perform checks to see if DNS is properly configured on the local network.
 

In this case, no DNS server has been configured, therefore, the wizard will offer to automatically install DNS on this server.

Note: The first DCs must also be a Global Catalog. Also, the first DCs in a forest cannot be a Read Only Domain controller.

2.7 It's most likely that you'll get a warning telling you that the server has one or more dynamic IP Addresses.
 

Running IPCONFIG /all will show that this is not the case, because as you can clearly see, I have given the server a static IP Address.
So, where did this come from? The answer is IPv6. I did not manually configure the IPv6 Address, hence the warning. In a network where IPv6 is not used, you can safely ignore this warning.
 [ if u are not given the ip before ]

2.8 You'll probably get a warning about DNS delegation. Since no DNS has been configured yet, you can ignore the message and click Yes.
  
2.9 Next, change the paths for the AD database, log files and SYSVOL folder.
 

For large deployments, carefully plan your DC configuration to get the maximum performance. When satisfied, click Next.

2.10 Enter the password for the Active Directory Recovery Mode.
This password must be kept confidential, and because it stays constant while regular domain user passwords expire
based upon the password policy configured for the domain, the default is 42 days), it does not.
 

This password should be complex and at least 7 characters long.
 

I strongly suggest that you do NOT use the regular administrator's password, and that you write it down and securely store it. Click Next.

2.11 In the Summary window review your selections, and if required, save them to an unattended answer file. When satisfied, click Next.
   
2.12 The wizard will begin creating the Active Directory domain, and when finished, you will need to press Finish and reboot your computer.
   You can automate the rebooting process by checking the Reboot on Completion check box.

Note:-  configuring a Windows Server 2008 Server Core machine REQUIRES you to perform an automated installation of Active Directory on that server, as there is NOT DCPROMO GUI on Server Core.
       Your server now acts as a Domain Controller.
       Make sure you properly back it up.
     You can test functionality by using AD management tools such as Active Directory Users and Computers, examine the Event Logs, services and folders and shares that have been created.

After installing the AD-DS role, we need to run DCPROMO to perform the actual Active Directory database and function installation.

Note: This guide assumes this is the first Domain controller in the forest, thus creating a new domain in a new forest. For a guide on how to add additional Domain Controllers to existing domains, please read my upcoming "Installing Additional Windows Server 2008 Domain Controllers in your Existing Active Directory Domain" article.

Method 2 – Servermanagercmd.exe


Servermanagercmd.exe is the command prompt equivalent of the Add Roles and Add Features wizards in Server Manager.
Through the use of various command line options, you can quickly and easily add or remove features and roles to or from your server, including the AD-DS role.

To install AD-DS by using Servermanagercmd.exe, simply enter the following command in the Command Prompt window:

Servermanagercmd.exe –I ADDS-Domain-Controller

Let the command run and when it finishes, AD-DS will be installed on the server.

Method 3 – Letting DCPROMO do the job

Oh yes. If you forget to install AD-DS or simply want to skip clicking on some windows, you can run DCPROMO from the Run command and before it is executed, the server will check to see if the AD-DS binaries are installed. Since they are not, they will auto-install.

After you complete the Add Roles Wizard, either click the link to start the Active Directory Domain Services Installation Wizard, or close Server Manager and manually run DCPROMO from the Run command.

Running DCPROMO

After installing the AD-DS role, we need to run DCPROMO to perform the actual Active Directory database and function installation.

Note: This guide assumes this is the first Domain controller in the forest, thus creating a new domain in a new forest. For a guide on how to add additional Domain Controllers to existing domains, please read my upcoming "Installing Additional Windows Server 2008 Domain Controllers in your Existing Active Directory Domain" article.


Adding Client To Host

For WindowsXP

In Host --- Adding the Client to Domain/Creating a user

Don't want to create the user in client machine.

1. go to Server manager--------------->Roles--------->Active Directory Domain Services--------->Active Directory users and Computers------->ctechz.blogspot.com---->users
     RightClick--------->New------>User.

Adding Client(Other Machines) To Domain(AD Server--Host)

1. First go to Client Machine 

    MyComputer----------->Properties---------->Computer Name---------->Change--------->Memberof Domain( add our domain name here------>ctechz.blogspot.com)
   
    To be part of that domain it will ask for username and password
     Give the Admin username and admin password

      Administrator
      redhat@123#

  Then to log into the machine with normal username and password, that we created in AD

      ctechz
      redhat@123#


 Adding a Linux Client to Domain AD

http://blog.scottlowe.org/2007/07/09/linux-ad-integration-with-windows-server-2008/

1. Go to server manager in AD

     Roles------>Active directory domain services---------->AddRoleServices------>identity management for unix(select all options)
 Install those services and restart the server.

Once that role service has been installed, then the AD schema now includes a partially RFC 2307-compliant set of UNIX attributes, such as UID, UID number, GID number, login shell, etc
At this point a new tab labeled “UNIX Attributes” will appear in the properties dialog box for users and groups in Active Directory. You’ll use this tab to edit the UNIX-specific attributes that are required for logins to Linux-based systems.

we'll describe how to unify your Linux and Active Directory environments. With minor changes, this same procedure can be used to authenticate your Linux hosts against eDirectory or any other LDAP compliant directory service.

2. Prepare Active Directory (Each User)

Each Active Directory account that will authenticate via Linux must be configured with a UID and other UNIX attributes. This is accomplished via the new “UNIX Attributes” tab on the properties dialog box of a user account.

After all the user accounts have been configured, then we are ready to configure Active Directory objects for each of the Linux server(s) that we’ll be integrating with AD.

Add the user in AD with all the unix attributes specified:-
RightClick --------> New ----------> User

After adding the user add a group also  -------> RightClick --------> New ----------> Group-----> group name
Take Group Properties RightClick on groupname------> Properties--------> UNIX Attributes -------> give the domain name(ctechz)gid also it will show---->Apply---->ok

Then take the user we created,take the user properties --------> Unix Attributes --------> select Domain(ctechz) --------> [ fill the UID, Shell, Home Directory & Primary group ]
 The user will be added to the primary group automatically

3. Prepare Active Directory (Each Server)
 

Prior to using Samba to join Linux computers to Active Directory and generate a keytab automatically, we had to use the ktpass.exe utility on Windows to generate a keytab.
Due to some current Samba-Windows Server 2008 interoperability issues, we can’t use Samba. That means we’ll be back to using ktpass.exe to map service principals onto accounts in Active Directory. Unfortunately, you’ll need to first disable User Account Control (UAC) on your server, since UAC interferes with ktpass.exe

Note:- User Account Control (UAC) ask for yes/no while we install a s/w ( as in vista before instalation it ask for confirmation )

Once you’ve disabled UAC (and rebooted your server), then you can map the service principal names (SPNs) using the following steps:

To disable UAC go to controlpanel ------> UserAccounts -------> Turn User Account Control on or off  ------> Clear the Use User Account Control (UAC) to help protect your computer check box, and then click OK. ------> Restart

3A. Create a computer account (or a user account; either will work) with the name of the Linux server. ( the account that we created already with unix attributes will work )

[By default when key tables are created, they are owned by root and readable only by root. If a key table is created on Windows using ktpass and copied to the UNIX computer]
3B. Use the following command to map the needed SPN onto this account (backslashes indicate line continuation):
   ktpass.exe -princ HOST/server.fqdn@REALM.COM -mapuser DOMAIN\AccountName$ -crypto all -pass Password123 -ptype KRB5_NT_PRINCIPAL -out filename.keytab

examplae:- ktpass.exe -princ HOST/cloudcc.ctechz.blogspot.com@ctechz.blogspot.com -mapuser ctechz.blogspot.com\sujith$ -crypto all -pass redhat@123# -ptype KRB5_NT_PRINCIPAL -out sujith.keytab

Edit the /etc/hosts file of both linux(client) machine and windows(AD server) machine

For Linux
vim /etc/hosts
192.168.1.67  cloudcc.perfomixint.com cloudcc
192.168.1.222 AD.ctechz.blogspot.com AD

For Windows
C:\Windows\System32\drivers\etc\hosts
192.168.1.222 AD.ctechz.blogspot.com AD
192.168.1.67 cloudcc.perfomixint.com cloudcc

cloudcc.ctechz.blogspot.com



Please find the screen shoots below