Oct 13, 2007

Adding NTP Time Server on Linux


This was written and done on a Redhat ES4 and Cent OS machine but is a general guide and should apply to most Linux distribution types.

Syncing your Linux Server with an NTP Time Server

Adding a time server is very easy and only requires modification of two files. Lets begin.

Step 1

  • SSH into your machine to goto the console. Become the user root.

Step 2

  • Backup your current ntp.conf file - 'cp /etc/ntp.conf /etc/ntp.conf.ORIG'

Step 3

  • Edit your ntp.conf file - 'vi /etc/ntp.conf'

Edit your /etc/ntp.conf


Step 4

  • Scroll down until you see:

# --- OUR TIMESERVERS -----
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org

Editing ntp.conf

Step 5

  • Comment out these lines by adding a '#' before each line. (If using vi type 'i' to begin editing)

# --- OUR TIMESERVERS -----
#server 0.pool.ntp.org
#server 1.pool.ntp.org
#server 2.pool.ntp.org

Step 6

  • Below the last server add your server IP or Domain

# --- OUR TIMESERVERS -----
#server 0.pool.ntp.org
#server 1.pool.ntp.org
#server 2.pool.ntp.org
server 192.168.0.1

Editing your ntp.conf file

Step 7

  • Save the file and exit (if using vi save by typing :wq)

Step 8

  • Now we will edit your step-tickers file. Make a backup by using this commaind: 'cp /etc/ntp/step-tickers /etc/ntp/step-tickers.ORIG'

Step 9

  • Open the file in your favorite editor: 'vi /etc/ntp/step-tickers'
  • The file will normally be blank.

Step 10

  • Add your time-server IP or Domain to the file (if using vi type i to begin inserting).
  • 192.168.0.1

Editing your step-tickers file

Step 11

  • Save and exit the file (if using vi type ':wq')

Step 12

  • Now we want to enable ntp at startup and start the service now. Execute the command 'chkconfig --level 2345 ntpd on'

Step 13

  • Start the service now, execute: 'service ntpd start' - if everything goes well you should see:

Starting ntpd service


Congratulations, your Linux server should now be synced. Type 'date' to determine if the time has been synced correctly.

No comments: