{"id":1315,"date":"2018-05-31T19:56:39","date_gmt":"2018-05-31T17:56:39","guid":{"rendered":"https:\/\/bergs.biz\/blog\/?p=1315"},"modified":"2018-05-31T20:00:39","modified_gmt":"2018-05-31T18:00:39","slug":"ntp-running-in-chroot-stopped-working-after-debian-stretch-upgrade","status":"publish","type":"post","link":"https:\/\/bergs.biz\/blog\/2018\/05\/31\/ntp-running-in-chroot-stopped-working-after-debian-stretch-upgrade\/","title":{"rendered":"ntp running in chroot stopped working after Debian Stretch upgrade"},"content":{"rendered":"<p>Today I upgraded my root server from Jessie to Stretch, and suddenly ntp stopped working.<\/p>\n<p>I found errors like follows in the log, which were obviously due to failures in name resolution:<\/p>\n<pre>2018-05-31T07:44:48.900756+00:00 myhost ntpd[22855]: giving up resolving host 1.debian.pool.ntp.org: Servname not supported for ai_socktype (-8)<\/pre>\n<p>The solution to make this work was to bind-mount some files and directories essential for name resolution into the chroot jail.<\/p>\n<p>First create some directories and some dummy files:<\/p>\n<pre># mkdir \/var\/lib\/ntp\/etc \/var\/lib\/ntp\/lib \/var\/lib\/ntp\/proc\r\n# mkdir \/var\/lib\/ntp\/usr \/var\/lib\/ntp\/usr\/lib\r\n# touch \/var\/lib\/ntp\/etc\/resolv.conf \/var\/lib\/ntp\/etc\/services\r\n\r\n<\/pre>\n<p>Then update your <code>\/etc\/fstab<\/code> as follows:<\/p>\n<pre>...\r\n#ntpd chroot mounts\r\n\/etc\/resolv.conf  \/var\/lib\/ntp\/etc\/resolv.conf none bind 0 0\r\n\/etc\/services\t  \/var\/lib\/ntp\/etc\/services none bind 0 0\r\n\/lib\t\t  \/var\/lib\/ntp\/lib none bind 0 0\r\n\/usr\/lib\t  \/var\/lib\/ntp\/usr\/lib none bind 0 0\r\n\/proc\t\t  \/var\/lib\/ntp\/proc none bind 0 0\r\n<\/pre>\n<p>Finally mount all these binds:<\/p>\n<pre># mount -a<\/pre>\n<p>Thanks to the ArchLinux guys where I <a href=\"https:\/\/wiki.archlinux.org\/index.php\/Network_Time_Protocol_daemon#Running_in_a_chroot\" target=\"_blank\" rel=\"noopener noreferrer\">found<\/a> this.<\/p>\n<p>To check whether your ntp is working again, you can use the following command which shows a list of peers known to your ntp server:<\/p>\n<pre># ntpq -p\r\n\u00a0\u00a0\u00a0\u00a0 remote\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 refid\u00a0\u00a0\u00a0\u00a0\u00a0 st t when poll reach\u00a0\u00a0 delay\u00a0\u00a0 offset\u00a0 jitter\r\n==============================================================================\r\n\u00a00.debian.pool.n .POOL.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 16 p\u00a0\u00a0\u00a0 -\u00a0\u00a0 64\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 0.000\u00a0\u00a0\u00a0 0.000\u00a0\u00a0 0.000\r\n\u00a01.debian.pool.n .POOL.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 16 p\u00a0\u00a0\u00a0 -\u00a0\u00a0 64\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 0.000\u00a0\u00a0\u00a0 0.000\u00a0\u00a0 0.000\r\n\u00a02.debian.pool.n .POOL.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 16 p\u00a0\u00a0\u00a0 -\u00a0\u00a0 64\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 0.000\u00a0\u00a0\u00a0 0.000\u00a0\u00a0 0.000\r\n\u00a03.debian.pool.n .POOL.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 16 p\u00a0\u00a0\u00a0 -\u00a0\u00a0 64\u00a0\u00a0\u00a0 0\u00a0\u00a0\u00a0 0.000\u00a0\u00a0\u00a0 0.000\u00a0\u00a0 0.000\r\n*ptbtime1.ptb.de .PTB.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1 u\u00a0\u00a0 46\u00a0\u00a0 64\u00a0 377\u00a0\u00a0 11.483\u00a0\u00a0 -0.411\u00a0\u00a0 0.201\r\n+ptbtime2.ptb.de .PTB.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1 u\u00a0\u00a0 52\u00a0\u00a0 64\u00a0 377\u00a0\u00a0 11.502\u00a0\u00a0 -0.533\u00a0\u00a0 1.069\r\n+ptbtime3.ptb.de .PTB.\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1 u\u00a0\u00a0 47\u00a0\u00a0 64\u00a0 377\u00a0\u00a0 11.451\u00a0\u00a0 -0.510\u00a0\u00a0 3.866\r\n#batleth.sapient 131.188.3.221\u00a0\u00a0\u00a0 2 u\u00a0\u00a0 44\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 0.188\u00a0\u00a0\u00a0 1.097\u00a0\u00a0 0.176\r\n#5.199.135.170 ( 130.149.17.21\u00a0\u00a0\u00a0 2 u\u00a0\u00a0 45\u00a0\u00a0 64\u00a0 377\u00a0\u00a0 11.271\u00a0\u00a0\u00a0 0.581\u00a0\u00a0 0.396\r\n-mail.morbitzer. 193.175.73.151\u00a0\u00a0 2 u\u00a0\u00a0 47\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 2.760\u00a0\u00a0\u00a0 0.556\u00a0\u00a0 0.278\r\n#hotel.zq1.de\u00a0\u00a0\u00a0 161.62.157.173\u00a0\u00a0 3 u\u00a0\u00a0 46\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 0.094\u00a0\u00a0\u00a0 1.384\u00a0\u00a0 0.261\r\n-ntp2.m-online.n 212.18.1.106\u00a0\u00a0\u00a0\u00a0 2 u\u00a0\u00a0 47\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 7.167\u00a0\u00a0 -0.333\u00a0\u00a0 0.190\r\n#2a03:b0c0:3:d0: 81.94.123.16\u00a0\u00a0\u00a0\u00a0 3 u\u00a0\u00a0 49\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 6.288\u00a0\u00a0 -2.071\u00a0\u00a0 1.760\r\n#touka.thehomeof 130.149.17.21\u00a0\u00a0\u00a0 2 u\u00a0\u00a0 48\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 0.206\u00a0\u00a0\u00a0 0.932\u00a0\u00a0 0.222\r\n+maggo.info\u00a0\u00a0\u00a0\u00a0\u00a0 124.216.164.14\u00a0\u00a0 2 u\u00a0\u00a0 42\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 0.278\u00a0\u00a0 -0.137\u00a0\u00a0 0.436\r\n+weyoun4.cord.de 124.216.164.14\u00a0\u00a0 2 u\u00a0\u00a0 44\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 2.849\u00a0\u00a0 -0.255\u00a0\u00a0 0.409\r\n+opnsense.sauff. 222.217.153.8\u00a0\u00a0\u00a0 2 u\u00a0\u00a0 43\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 0.270\u00a0\u00a0 -0.617\u00a0\u00a0 0.167\r\n-web1.sys.ccs-ba 192.53.103.104\u00a0\u00a0 2 u\u00a0\u00a0 35\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 0.173\u00a0\u00a0 -1.251\u00a0\u00a0 0.220\r\n#uruz.org\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 122.227.206.195\u00a0 3 u\u00a0\u00a0 49\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 0.216\u00a0\u00a0\u00a0 1.694\u00a0\u00a0 0.309\r\n#clients5.arcani 162.23.41.55\u00a0\u00a0\u00a0\u00a0 2 u\u00a0\u00a0 38\u00a0\u00a0 64\u00a0 377\u00a0\u00a0\u00a0 6.120\u00a0\u00a0 -1.500\u00a0\u00a0 0.130\r\n+stratum2-1.NTP. 129.70.130.71\u00a0\u00a0\u00a0 2 u\u00a0\u00a0 47\u00a0\u00a0 64\u00a0 377\u00a0\u00a0 14.043\u00a0\u00a0\u00a0 1.625\u00a0\u00a0 0.394<\/pre>\n<p>The following command confirms that your current time is actually correct (within certain limits, of course):<\/p>\n<pre># ntpstat\r\nsynchronised to NTP server (192.53.103.108) at stratum 2\r\n\u00a0\u00a0 time correct to within 15 ms\r\n\u00a0\u00a0 polling server every 64 s<\/pre>\n<p>If this was helpful, I would be happy to hear from you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to make ntp in chroot jail work in Debian Stretch.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,34,122,33,84],"tags":[281,144,284,285],"class_list":["post-1315","post","type-post","status-publish","format-standard","hentry","category-computers","category-debian","category-english","category-linux-computers","category-networking-computers","tag-debian","tag-dns","tag-ntp","tag-stretch"],"_links":{"self":[{"href":"https:\/\/bergs.biz\/blog\/wp-json\/wp\/v2\/posts\/1315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bergs.biz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bergs.biz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bergs.biz\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bergs.biz\/blog\/wp-json\/wp\/v2\/comments?post=1315"}],"version-history":[{"count":6,"href":"https:\/\/bergs.biz\/blog\/wp-json\/wp\/v2\/posts\/1315\/revisions"}],"predecessor-version":[{"id":1321,"href":"https:\/\/bergs.biz\/blog\/wp-json\/wp\/v2\/posts\/1315\/revisions\/1321"}],"wp:attachment":[{"href":"https:\/\/bergs.biz\/blog\/wp-json\/wp\/v2\/media?parent=1315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bergs.biz\/blog\/wp-json\/wp\/v2\/categories?post=1315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bergs.biz\/blog\/wp-json\/wp\/v2\/tags?post=1315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}