Configuration of ntp in secure environments

TAGS: linux ntp apparmor

What to do when time of yours machines doesn’t syncing

Step 1. Find out correct ntp server address in your net.
If you trying to configure time on machines in production environments there is a good chance tha default ntp server would not be accessible.
How to check ntp server accessibility
service ntp stop ntpdate -su $ip tail /var/log/syslog

Step 2. Check your apparmor status - loaded profiles etc
apparmor_status
or aa-status
or
cat /sys/kernel/security/apparmor/profiles

Sample output
apparmor module is loaded. 6 profiles are loaded. 6 profiles are in enforce mode. /sbin/dhclient /usr/lib/NetworkManager/nm-dhcp-client.action /usr/lib/connman/scripts/dhclient-script /usr/sbin/mysqld /usr/sbin/ntpd /usr/sbin/tcpdump If you have similar output, you can also check dmesg output
dmesg
There you can find lines like
audit: type=1400 audit(1508845970.970:16): apparmor="DENIED" operation="capable" profile="/usr/sbin/ntpd" pid=2606 comm="ntpd" capability=12 capname="net_admin"
It means that apparmor has blocked your ntp syncing and you should disable ntp profile
Step 3. Disable ntp profile in apparmor
ln -s /etc/apparmor.d/usr.sbin.ntpd /etc/apparmor.d/disable/ apparmor_parser -R /etc/apparmor.d/usr.sbin.ntpd
Step 4. Check that everything ok
service ntp stop ntpdate -su $ip tail /var/log/syslog dmesg
Step 5. Start service
service ntp start

Written on October 24, 2017

Archive

linux openstack kubernetes gluster ceph ansible docker systemctl python openshift log centos sed registry kolla kibana keepalived elasticsearch deploy cloud-init auth HA zabbix vsphere vmware venv tools swift ssl ssh scm ruby rsyslog rhel rbac rabbitmq prometheus postgres policy pgpool2 patrole pacemaker ntp nfs net mq monitoring mongo mbr lvm logstash kubespray kubeadm kolla-ansible jenkins jekyII java ironic helm heketi harbor grub github ganesha fluentd fluent-bit fio drbd diskimage-builder devstack debug deb db cisco cicd ceph-ansible calico build bitbucket benchmarking apparmor api NUMA Linux Golang Go ELK 3par