Solved

NTP Server

Posted on 2009-04-13
3
685 Views
Last Modified: 2012-05-06
We have a NTP server and the configuration file follw:

[root@natbox]# cat /etc/ntp.conf

restrict default nomodify notrap noquery
# -- CLIENT NETWORK -------
restrict 192.168.216.0 mask 255.255.255.0 nomodify notrap
restrict 10.36.0.0 mask 255.255.0.0 nomodify notrap
restrict 192.168.213.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.223.0 mask 255.255.255.0 nomodify notrap
restrict 192.168.215.0 mask 255.255.255.0 nomodify notrap
# --- OUR TIMESERVERS -----
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org

server  127.127.1.0     # local clock
fudge   127.127.1.0 stratum 10
driftfile /var/lib/ntp/drift
broadcastdelay  0.008
keys            /etc/ntp/keys

[root@natbox]# cat /etc/ntp/keys

#65535  M       akey
#1      M       pass

Can i get a good explanation for the above contents of ntp.conf file.
Also can I get a standard good ntp.conf sample file, which should be secure and good client communication.

When i type "ntpq -p" in server it saying time out, but when i type "ntpq -p server ip" it displays the output.
So this seems server is not listening localy. Any comments on this?
0
Comment
Question by:linuxraja
3 Comments
 
LVL 5

Expert Comment

by:50centos
ID: 24134244
Here you go. Save file as *.sh, then run script.
echo "restrict 127.0.0.1" > ntp.conf.tmp
echo "restrict default kod nomodify notrap" >> ntp.conf.tmp
echo -n > step-tickers.tmp
if [ "$1" == "" ]
then
        echo "No file specified, please manually enter the NTP servers."
        echo  "You may enter as many servers as you like."
        echo  "Please enter the first server."
        read -e SERVER
        echo "server $SERVER" >> ntp.conf.tmp
        echo "$SERVER" >> step-tickers.tmp
        until [ -z "$SERVER" ]
        do
                echo "Please enter the next server, just press 'Enter' when done."
                read -e SERVER
                if [ ! -z "$SERVER" ]
                then
                        echo "server $SERVER" >> ntp.conf.tmp
                        echo "$SERVER" >> step-tickers.tmp
                fi
        done
else
        FILE="$1"
        if [ ! -f $FILE ]
        then
                echo "*** $FILE does not exist ***"
                exit 9
        elif [ ! -r $FILE ]
        then
                echo "*** unable to read $FILE ***"
                exit 10
        fi
        exec 7<&0
        exec<$FILE
        while read LINE
        do
                SERVER=$LINE
                echo "server $SERVER" >> ntp.conf.tmp
                echo "$SERVER" >> step-tickers.tmp
        done
        exec 0<&7
fi
 
echo "driftfile /var/lib/ntp/drift" >> ntp.conf.tmp
echo "The following server(s) will be used for NTP..."
cat step-tickers.tmp
if [ "$2" == "q" ] 
then
        CONFIRM="y"
else
        echo "Is this correct and do you want to continue setting up NTP ('y' or 'n') ? "
        read -e CONFIRM
fi
until [ "$CONFIRM" == "y" ] || [ "$CONFIRM" == "n" ] || [ "$CONFIRM" == "Y" ] || [ "$CONFIRM" == "N" ]
do
        echo "Please enter either 'y' or 'n': "
        read -e $CONFIRM
done
if [ "$CONFIRM" == "y" ] || [ "$CONFIRM" == "Y" ]
then
        echo "Backing up current config files..."
        cp /etc/ntp.conf /etc/ntp.conf.bk
        if [ "$?" -ne "0" ] 
        then
                echo "*** Unable to backup /etc/ntp.conf ***"
                exit 1
        fi
        cp /etc/ntp/step-tickers /etc/ntp/step-tickers.bk
        if [ "$?" -ne "0" ]
        then 
                echo "*** Unable to backup /etc/ntp/step-tickers ***"
                exit 2
        fi
        echo "Creating new config files..."
        mv -f ntp.conf.tmp /etc/ntp.conf
        if [ "$?" -ne "0" ]
        then
                echo "*** Unable to create /etc/ntp.conf ***"
                exit 3
        fi
        mv -f step-tickers.tmp /etc/ntp/step-tickers
        if [ "$?" -ne "0" ]
        then
                echo "*** Unable to create /etc/ntp/step-tickers ***"
                exit 4
        fi
        echo "Restarting NTP service..."
        service ntpd restart
        if [ "$?" -ne "0" ]
        then
                echo "*** Unable to restart NTP service ***"
                exit 5
        fi
        echo "Setting NTP to autostart..."
        chkconfig --level 345 ntpd on
        if [ "$?" -ne "0" ]
        then
                echo "*** Unable to setup NTP to autostart ***"
                exit 6
        fi
        echo "Syncing hardware clock to NTP time..."
        hwclock --systohc
        if [ "$?" -ne "0" ] 
        then
                echo "*** Unable to set hardware clock to NTP time..."
                exit 7
        fi
        echo "NTP is now setup."
        echo "If you would like to monitor the daemon run 'watch \"ntpq -p\"'."
else
        echo "User cancelled."
        exit 
fi

Open in new window

0
 
LVL 13

Accepted Solution

by:
WizRd-Linux earned 500 total points
ID: 24134471
ntpq -p will show the information relating to the server lines in your configuration file, as these are the default servers it isn't surprising that it is timing out.

Firstly, change away from the default ones to use a different time server, your upstream provider may offer one.  Once you have "fixed" up the configuration file you should be right.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Samba Question 11 103
CLI command keep running after close 7 54
IMAP copying tool 14 42
Can't "Unset" Proxy in Apache headers for PCI compliance... 4 31
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question