Board logo

標題: 如何架設公用的NTP主機 [打印本頁]

作者: service.support    時間: 2009-2-12 13:49     標題: 如何架設公用的NTP主機

編輯/etc/ntp.conf

restrict default nomodify notrap noquery
restrict 127.0.0.1
restrict 192.168.1.55
restrict 192.168.0.0 mask 255.255.0.0 nomodify notrap
restrict 0.0.0.0 mask 0.0.0.0 nomodify notrap
server 0.asia.pool.ntp.org
server 1.asia.pool.ntp.org
server 2.asia.pool.ntp.org
server 3.asia.pool.ntp.org
server 220.130.158.52
server 128.250.36.2 prefer
server 142.3.100.2 prefer
server 0.pool.ntp.org
server 1.pool.ntp.org
server 2.pool.ntp.org
server asia.pool.ntp.org
restrict 220.130.158.52
restrict 128.250.36.2
restrict 142.3.100.2
restrict 0.asia.pool.ntp.org
restrict 1.asia.pool.ntp.org
restrict 2.asia.pool.ntp.org
restrict 3.asia.pool.ntp.org
restrict 0.pool.ntp.org
restrict 1.pool.ntp.org
restrict 2.pool.ntp.org
restrict asia.pool.ntp.org
server 127.127.1.0
fudge 127.127.1.0 stratum 10
keys    /etc/ntp/keys
driftfile /var/lib/ntp/drift
broadcastdelay  0.008

編輯 /etc/rc.d/init.d/xntpd ,  在 start 的 daemon xntpd -A 加上 -g

# xntpd         This shell script takes care of starting and stopping
#               xntpd (NTPv3 daemon).
#
# chkconfig: - 55 10
# description: xntpd is the NTPv3 daemon.

# Source function library.
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

[ -x /usr/sbin/xntpd -a -f /etc/ntp.conf ] || exit 0

RETVAL=0

# See how we were called.
case "$1" in
  start)
        # Adjust time to make life easy for xntpd
        if [ -f /etc/ntp/step-tickers ]; then
                echo -n "Syncing time for xntpd. "
                /usr/sbin/ntpdate -s -b -p 8 -u `cat /etc/ntp/step-tickers`
        fi
        # Start daemons.
        echo -n "Starting xntpd: "
        daemon xntpd -A -g
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/xntpd
        ;;
  stop)
        # Stop daemons.
        echo -n "Shutting down xntpd: "
        killproc xntpd
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xntpd
        ;;
  status)
        status xntpd
        RETVAL=$?
        ;;
  restart|reload)
        $0 stop
        $0 start
        RETVAL=$?
        ;;
  *)
        echo "Usage: xntpd {start|stop|restart|status}"
        exit 1
esac

exit $RETVAL




歡迎光臨 HGIGA Service Docs (http://docs.hgiga.com/Discuz4/) Powered by Discuz! 4.1.0