---
# System prepended metadata

title: NTP configuration
tags: [PMC-100]

---

---
tags: PMC-100
---

# NTP configuration
```
### Update ubuntu
sudo apt-get update

### install NTP 
sudo apt-get install ntp

### If issue in installing ntp and update 
1. ps aux | grep -i apt
2. sudo killall apt apt-get
3. echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null

### Start NTP server
sudo systemctl enable ntp
sudo systemctl start ntp
sudo systemctl status ntp



### testing ntp server
1. ntpq -p
```

### NTP file and location

```
1. drift --> cat /var/lib/ntp/ntp.drift 
2. config --> cat /etc/ntp.conf 
```


### Useful commands

1. firewall ntp udp rule --> `grep -E -w '123/udp' /etc/services` 
2. update server once changes done --> `ntpdate 10.10.80.106`
3. verify authentication --> `ntpq -c authinfo`


### Testing NTP Server and client
1. Change the time or date in server
    * timedatectl set-time 12:00:00
    * timedatectl set-ntp 0 --> automatic ntp off 
    * timedatectl set-ntp 1 --> automatic ntp on
    * LC_TIME=en_US.utf8 (time language change)

# Reference

1. [Config ntp server ](https://kifarunix.com/install-and-setup-ntp-server-on-ubuntu-22-04-debian-11/)
2. [Config ntp client ](https://kifarunix.com/install-and-configure-ntp-client-on-ubuntu-debian-systems/)
3. [Will help for firwall issue](https://linuxhint.com/setup-ntp-server-and-client-on-ubuntu/)
4. [NTP server pool](https://www.pool.ntp.org/zone/tw)
5. [NTP command link](https://manpages.ubuntu.com/manpages/xenial/man5/ntp.conf.5.html)
6. [To understand ntp peer details](https://timetoolsltd.com/ntp/how-to-install-and-configure-ntp-on-linux/)
7. [Understand the NTP process](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/deployment_guide/s1-understanding_leap_seconds)
8. [Debugging issue](https://luppeng.wordpress.com/2020/02/05/using-an-undisciplined-local-clock-to-cause-ntpd-to-exit-panic-and-how-to-recover-from-it/)