简单NTP server 脚本一键生成
#!/bin/bash
##guying
IP=`ifconfig eth0 |grep 'inet addr' |awk -F '[ :]+' '{print $4}'`
yum -y install ntp*
sed -i 's/BOOTPROTO=dhcp/BOOTPROTO=static/g' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i 's/BOOTPROTO="dhcp"/BOOTPROTO=static/g' /etc/sysconfig/network-scripts/ifcfg-eth0
sed -i 's/BOOTPROTO=none/BOOTPROTO=static/g' /etc/sysconfig/network-scripts/ifcfg-eth0
echo "IPADDR=192.168.66.181" >>/etc/sysconfig/network-scripts/ifcfg-eth0
echo "NETMASK=255.255.255.0" >>/etc/sysconfig/network-scripts/ifcfg-eth0
service network restart 1>/dev/null 2>/dev/null
sed -i "s/#restrict 192.168.1.0/restrict 192.168.66.0/g" /etc/ntp.conf
sed -i "s/#server*/server/g" /etc/ntp.conf
sed -i "s/#fudge*/fudge/g" /etc/ntp.conf
sed -i "s/restrict default kod nomodify notrap nopeer noquery/#restrict default kod nomodify notrap nopeer noquery/g" /etc/ntp.conf
echo server ntp.nasa.gov >>/etc/ntp.conf
echo logfile /var/log/ntp >>/etc/ntp.conf
echo $IP >> /etc/ntp/step-tickers
echo "127.127.1.0 " >> /etc/ntp/step-tickers
echo "SYNC_HWCLOCK=yes" >>/etc/sysconfig/ntpd
service ntpd restart #重启服务完毕等个十分钟再用client进行时间同步
阅读(2692) | 评论(0) | 转发(0) |