Setup ntp server » Historie » Version 2
Jeremias Keihsler, 17.04.2024 09:34
| 1 | 1 | Jeremias Keihsler | h1. Install Procedure for ntp-server |
|---|---|---|---|
| 2 | |||
| 3 | h2. Requirements |
||
| 4 | |||
| 5 | 2 | Jeremias Keihsler | To install ntpd you will need the following: |
| 6 | 1 | Jeremias Keihsler | * a installed and supported operating system (e.g. CentOS 6.x) |
| 7 | * root-access |
||
| 8 | * a fast internet connection |
||
| 9 | |||
| 10 | h2. Preliminary Note |
||
| 11 | |||
| 12 | This procedure is based on a documentation supplied by |
||
| 13 | * http://www.cyberciti.biz/faq/rhel-fedora-centos-configure-ntp-client-server/ |
||
| 14 | * http://http://www.gtkdb.de/index_7_576.html |
||
| 15 | * http://linuxwave.blogspot.com/2007/08/setting-up-your-own-ntp-server.html |
||
| 16 | |||
| 17 | h2. Install |
||
| 18 | |||
| 19 | Install ntp: |
||
| 20 | <pre><code class="bash"> |
||
| 21 | yum install ntp |
||
| 22 | </code></pre> |
||
| 23 | |||
| 24 | h2. Configure ntp Server |
||
| 25 | |||
| 26 | <pre><code class="bash"> |
||
| 27 | vim /etc/ntp.conf |
||
| 28 | </code></pre> |
||
| 29 | |||
| 30 | h3. Use external ntp-Server as reference |
||
| 31 | Basically the ntp.conf is ready configured, so there is nothing to change |
||
| 32 | |||
| 33 | If there is need to use additional or different ntp-server then add it to the @server@ section |
||
| 34 | |||
| 35 | h3. Use internal clock as reference |
||
| 36 | |||
| 37 | This is only necessary if there is no reliable time-source or ntp-server available at all |
||
| 38 | <pre><code class="bash"> |
||
| 39 | server 127.127.1.0 # local clock |
||
| 40 | fudge 127.127.1.0 stratum 4 # set stratum to any value from 0 to 16, the higher the safer, defaults to 10, 4 is working with WinXP and Win7 |
||
| 41 | </code></pre> |
||
| 42 | |||
| 43 | h2. Start ntp Server |
||
| 44 | |||
| 45 | manually start ntp Server: |
||
| 46 | <pre><code class="bash"> |
||
| 47 | /etc/init.d/ntpd start |
||
| 48 | </code></pre> |
||
| 49 | |||
| 50 | automatically start the service at boot time: |
||
| 51 | <pre><code class="bash"> |
||
| 52 | /sbin/service ntpd on |
||
| 53 | </code></pre> |
||
| 54 | |||
| 55 | you can check the runlevels by |
||
| 56 | <pre><code class="bash"> |
||
| 57 | /sbin/chkconfig --list ntpd |
||
| 58 | </code></pre> |
||
| 59 | you should get an output like: |
||
| 60 | <pre><code class="bash"> |
||
| 61 | ntpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off |
||
| 62 | </code></pre> |
||
| 63 | |||
| 64 | h2. configure firewall |
||
| 65 | |||
| 66 | Open NTP Port (123) on Iptables Firewall |
||
| 67 | <pre><code class="bash"> |
||
| 68 | system-config-firewall-tui |
||
| 69 | </code></pre> |
||
| 70 | add port @123:udp@ |
||
| 71 | |||
| 72 | check if settings are ok |
||
| 73 | <pre><code class="bash"> |
||
| 74 | cat /etc/sysconfig/iptables |
||
| 75 | </code></pre> |
||
| 76 | You should have following line before COMMIT: |
||
| 77 | <pre><code class="bash"> |
||
| 78 | -A RH-Firewall-1-INPUT -m state --state NEW -p udp --dport 123 -j ACCEPT |
||
| 79 | </code></pre> |
||
| 80 | Restart Iptables Firewall: |
||
| 81 | <pre><code class="bash"> |
||
| 82 | /etc/init.d/iptables restart |
||
| 83 | </code></pre> |
||
| 84 | |||
| 85 | h2. Usage |
||
| 86 | |||
| 87 | try to connect via windows machine and enter as a internet-time-source the ip-adress of the new ntp-server. (e.g. 192.168.2.53) |
||
| 88 | |||
| 89 | try to connect via linux machine and use to sync time: |
||
| 90 | <pre><code class="bash"> |
||
| 91 | ntpdate 192.168.2.53 |
||
| 92 | </code></pre> |