Friday, January 13, 2012

chrony


 chrony uses ntp protocol. It designed to get even more accurate time in linux environment. Chrony can also run in any machines that do not have any internet connections or internet connection is very slow such as dial up connections. So, the reference of accurate time can be any clock with high accuracy, but we should able to read the clock and give it to program. In addition and most importantly, it is also capable of calculating the inaccuracy of the hardware clock, and based on that, adjust the hardware clock at boot time. chrony consists of two parts: chronyd daemon and a user interface chronyc.

The following shows that how I installed and configured chrony in my host machine:

yum install chrony      #To install chrony daemon in my host machine
service ntpd stop  
#I should stop ntpd daemon because they don't work together. I figured out this in /var/log/messages.

Then I configured the chrony configuration file, which is /etc/chrony.conf. I just show important lines:

    vi /etc/chrony.conf
    server 0.fedora.pool.ntp.org     #these are the time servers that I get time through
    server 1.fedora.pool.ntp.org     #internet connection
    server 2.fedora.pool.ntp.org
    # Allow client access from local network.
    allow 192.168.2/24
    keyfile /etc/chrony.keys    #key file  path
    # Specify the key used as password for chronyc.
    commandkey 1
    logdir /var/log/chrony   # logging directory  path
    log measurements statistics tracking  #enable statistics logs

Then, I enabled the commented line in the /etc/chrony.keys file.
1 a_key
Finally, I started my chrony daemon by:
service chronyd start

I typed 'chronyc <command>' to monitor the operation of chronyd. The monitoring commands are:
    sources
    sourcestats
    tracking
The followings are the output of running these commands: 
 [root@f13 ~]# chronyc tracking
Reference ID    : 69.20.226.105 (2.fedora.pool.ntp.org)
Stratum         : 3
Ref time (UTC)  : Sun Jan 8 20:10:33 2012
System time     : 0.448538870 seconds fast of NTP time
Frequency       : 0.000 ppm fast
Residual freq   : -9891.555 ppm
Skew            : 1000000.000 ppm
Root delay      : 0.108197 seconds
Root dispersion : 22.964180 seconds

[root@f13 ~]# chronyc sourcestats
210 Number of sources = 3
Name/IP Address            NP  NR  Span  Frequency  Freq Skew  Offset  Std Dev
================================================================
0.fedora.pool.ntp.org       3   3   129   -576.006     194193   +541ms    34ms
1.fedora.pool.ntp.org       3   3   130  -7632.297    1479518    +10ms   125ms
2.fedora.pool.ntp.org       3   3   131  -9891.555     296739    -21us    10ms

[root@f13 ~]# chronyc sources
210 Number of sources = 3
MS Name/IP address           Stratum Poll LastRx Last sample
================================================================
^+ 0.fedora.pool.ntp.org         3    6     13   +167ms[ -288ms] +/-  542ms
^* 1.fedora.pool.ntp.org         2    6     10    -83ms[ -538ms] +/-  115ms
^+ 2.fedora.pool.ntp.org         2    6      8    -89ms[  -89ms] +/-  191ms

 
Now, it is the time to configure the guest machine. The processes are the same as host, but the only difference is that I changed the server address to my host in /etc/chrony.conf.

vi /etc/chrony.conf
server 192.168.2.5     #this is the ip address of my host
Also, there is no need to define client access for local network. So, you can comment that statement. The following is the status of the guest machine:

[root@vm01 ~]# chronyc sources
210 Number of sources = 1
MS Name/IP address           Stratum Poll LastRx Last sample
===============================================================
^~ 192.168.2.5                  16    6     43    -51ms[  -51ms] +/- 1500ms

[root@vm01 ~]# chronyc sourcesstatus
210 Number of sources = 1
MS Name/IP address           Stratum Poll LastRx Last sample
================================================================
^* 192.168.2.5                   3    6     19    +50ms[  +52ms] +/-  226ms

[root@vm01 ~]# chronyc tracking
Reference ID    : 192.168.2.5 (192.168.2.5)
Stratum         : 4
Ref time (UTC)  : Sun Jan 8 22:45:16 2012
System time     : 0.000000354 seconds slow of NTP time
Frequency       : 35.881 ppm slow
Residual freq   : -0.413 ppm
Skew            : 23.131 ppm
Root delay      : 0.062902 seconds
Root dispersion : 0.146990 seconds

 
Accuracy
Advantages
Disadvantage
Chrony is very accurate and if you look at to the output of chronyc command above, you will see that the accuracy is      microsecond.

Chrony supports intermittent internet connections (like a modem). Chrony also keeps track of the computers internal clock error compared to the NTP time to correct the time when the computer isn't connected to the internet (which is also handy even with a continuously connection).
In my opinion, the only major drawback is that chrony is not as widely tested as ntpd and there could be serious bugs   hidden. I found some security issues in pervious versions of chrony on internet.

 

Sunday, December 25, 2011

Setup and Configure Sendmail Server

Hello Everyone,
After verifying connectivity, DNS, and telnet to smtp, it is right time to configure your Sendmail server. To enable masquerading and binding your domain for sendmail, you should change the sendmail configuration file which is located in /etc/mail/sendmail.mc. Open this file with vi and change the following lines:
change:
LOCAL_DOMAIN(`localhost.localdomain')dnl     to     LOCAL_DOMAIN(khosro.org)dnl
dnl MASQUERADE_AS(`mydomain.com')dnl      to   MASQUERADE_AS(khosro.org)dnl
dnl FEATURE(masquerade_envelope)dnl            to   FEATURE(masquerade_envelope)dnl
dnl FEATURE(masquerade_entire_domain)   to FEATURE(masquerade_entire_domain)dnl
dnl MASQUERADE_DOMAIN(localhost.localdomain)dnl   to MASQUERADE_DOMAIN(khosro.org)dnl

Replace khosro.org with your domain name.
Now, you should run the following command in order to take effect your change in configuration file. You should use m4 command like this:
m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
Now, restart your sendmail with this command:    service sendmail restart
If everything is fine, you should able to send an email. Create a file and put some text on this file. Name this file to message_file. Run this command in order to send an email to your friend.

mail -v -s "Test from Khosro" root@mymachine.khosro.org < message_file

Change mymachine.khosro.org to your machine name and domain name. Use mail command to check the inbox and verify your email that you already sent it.  
Please leave your comments or questions. I will try to answer as soon as possible.
Thanks,
Khosro Taraghi

Exporting all Email Accounts from Zimbra Server for Microsoft Transporter Suite

Hello Everyone,

In order to move all email accounts and data from IMAP or POP3 Zimbra Server in Linux box machine to Exchange Server 2007, we need to create a .CSV file with the following columns:
  • SourceIdentity: The e-mail account that the user has in the IMAP/POP3 Server
  • SourceServer: The name or IP of the IMAP/POP3 Server
  • SourceLoginID: the account user name used to connect on the IMAP/POP3 server
  • SourcePassword: the user’s password
  • TargetIdentity: the Exchange Server 2007 identity will receive the data from the previous IMAP/POP3 Server settings  
To make life easier, I made a script that export all users from Zimbra to a CSV file. 
Here is the script:

#!/bin/bash
clear
echo "Processing account, please wait.............................."
USERS=`su - zimbra -c 'zmprov -l gaa'`
#Assume that domain name is test.com
exchange="@test.com"
echo "SourceIdentity,SourceServer,SourceLoginID,SourcePassword,TargetIdentity" > export_users.csv
for ACCOUNT in $USERS
 do
  SourceIdentity=`echo $ACCOUNT`
  #Assume that domain name is xyz.com for Linux box and Zimbra
  SourceServer=`echo "xyz.com"`
  SourceLoginID=`echo $ACCOUNT | awk -F@ '{print $1}'`
  SourcePassword=`echo "P@ssw0rd"`
  TargetIdentity=`echo -n $ACCOUNT | awk -F@ '{print $1}'`
  TargetIdentity=${TargetIdentity}${exchange}
  if [ $SourceLoginID == "admin" ] || [ $SourceLoginID == "spam" ] || [ $SourceLoginID == "ham" ] || [ $SourceLoginID == "virus-quarantine" ]
  then
   echo "Skipping system account, $ACCOUNT..."
  else
   echo "$SourceIdentity,$SourceServer,$SourceLoginID,$SourcePassword,$TargetIdentity" >> export_users.csv
  fi
 done



Now, we can use this CSV file in Microsoft Transporter Suite to import users to Exchange 2007.
Hope enjoy using this script. Please leave your comments or questions. I will try to answer as soon as possible.
Thanks,
Khosro Taraghi