{"id":2076,"date":"2024-10-31T08:03:31","date_gmt":"2024-10-31T12:03:31","guid":{"rendered":"https:\/\/enterpriseadmins.org\/blog\/?p=2076"},"modified":"2024-10-31T08:03:31","modified_gmt":"2024-10-31T12:03:31","slug":"step-by-step-installing-ubuntu-24-04-on-a-raspberry-pi-for-dns-and-ntp","status":"publish","type":"post","link":"https:\/\/enterpriseadmins.org\/blog\/lab-infrastructure\/step-by-step-installing-ubuntu-24-04-on-a-raspberry-pi-for-dns-and-ntp\/","title":{"rendered":"Step-by-Step: Installing Ubuntu 24.04 on a Raspberry Pi for DNS and NTP"},"content":{"rendered":"\n<p>In my home network, I have a Raspberry Pi4 which provides DNS (pi-hole) and NTP (chrony). Its a device that I don&#8217;t touch often and is a &#8216;production&#8217; type service &#8212; in my lab I don&#8217;t mind blowing up \/ breaking things&#8230; but this device needs to be stable.  If DNS goes offline the family can&#8217;t stream shows and it&#8217;s a real production down sort of situation.  Systems in my lab consume NTP from this device, and regular devices in my home network rely on it providing DNS (for ad blocking as well as conditional forwarding of lab domains to DNS servers in the lab). A few days ago, I noticed that this system was down &#8212; it wasn&#8217;t answering DNS requests and SSH\/VNC wasn&#8217;t working. After power cycling the system, I was also no longer able to ping the device. After a bit of troubleshooting, I realized that the SD card used as boot media had failed.  The system had been running 24&#215;7 for ~5 years, logging DNS requests and such, probably more write IO than anyone should expect from a consumer SD card.<\/p>\n\n\n\n<p>To resolve the issue I ordered a new SD card&#8230; but I realized that this system had about 5 years of various configurations.  I&#8217;m going to attempt to document the configuration (at least what I remember about it) below.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">OS Installation<\/h2>\n\n\n\n<p>The previous Raspberry Pi used the Raspbian OS with a GUI. However, I never really used the GUI and primarily access this system remotely. Since most other systems I manage use Ubuntu (specifically 24.04), I decided to install that OS using the server instructions from here: <a href=\"https:\/\/ubuntu.com\/tutorials\/how-to-install-ubuntu-on-your-raspberry-pi#1-overview\">https:\/\/ubuntu.com\/tutorials\/how-to-install-ubuntu-on-your-raspberry-pi#1-overview<\/a>.<\/p>\n\n\n\n<p>I used the Raspberry Pi Imager for Windows, which allowed me to customize the username\/password, hostname, etc of the OS so that it booted up and I could connect via ssh.<\/p>\n\n\n\n<p>Once I was logged into the system, the first thing I did was make sure it was up to date using <code>sudo apt update &amp;&amp; sudo apt upgrade<\/code>.  This installed a bunch of updates, so I rebooted for good measure.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Lab Certificate<\/h2>\n\n\n\n<p>In rare cases, I&#8217;ll access something from my lab from the Raspberry Pi.  To make this work without certificate warnings, I installed the lab CA certificate.  This is just two commands, one to copy the file and another to update the certs.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo wget http:\/\/www.example.com\/build\/rootca-example-com.crt -P \/usr\/local\/share\/ca-certificates\nsudo update-ca-certificates<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Install extra packages<\/h2>\n\n\n\n<p>I had a handful of extra packages that I installed. I&#8217;ll discuss each of these later, but for now we&#8217;ll install them all in one pass.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install sssd-ad sssd-tools realmd adcli chrony tinyproxy<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Proxy Server<\/h2>\n\n\n\n<p>For some occasional testing, I&#8217;ll use a proxy server in my lab. This was running in a dedicated VM, but while I&#8217;m revisiting things, I decided to co-locate it on this appliance.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># configure proxy\nsudo nano \/etc\/tinyproxy\/tinyproxy.conf\n\n# change LogLevel from Info to Warning\n# Allow 192.168.0.0\/16 by removing comment\n\nsudo systemctl reload tinyproxy<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">NTP (chrony)<\/h2>\n\n\n\n<p>I prefer having NTP servers running on physical devices.  Since I don&#8217;t have many of those in the lab, I use the Raspberry Pi as a locally accessible NTP server.  I&#8217;m using the <code>chrony<\/code> service to do this and allow anything in the lab to query this device for time. <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># configure NTP\nsudo nano \/etc\/chrony\/chrony.conf\n# append the following comment \/ allow lines to the file\n# Define the subnets that can use this host as an NTP server\nallow 192.168.0.0\/16\n\nsudo systemctl restart chrony.service<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Pi-Hole<\/h2>\n\n\n\n<p>The reason I first purchased this Raspberry Pi was to block ads on my home network using pi-hole.  <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -sSL https:\/\/install.pi-hole.net | bash\n\n# create a custom config file for various forward\/reverse domain forwarding:\nsudo nano \/etc\/dnsmasq.d\/05-custom.conf\n\n# contents of above new file\nserver=\/lab.enterpriseadmins.org\/192.168.127.30\nserver=\/lab.enterpriseadmins.org\/192.168.32.30\nserver=\/example.com\/192.168.127.30\nserver=\/example.com\/192.168.32.30\nserver=\/168.192.in-addr.arpa\/192.168.127.30\nserver=\/168.192.in-addr.arpa\/192.168.32.30\n\n# from web UI, restart resolver.\n# Update pihole settings > DNS, change from recommended allow only local requests to 'permit all origins' so that all lab subnets can resolve names.\n\n# enable php for non-pihole \/admin locations\nsudo lighttpd-enable-mod fastcgi fastcgi-php\nsudo service lighttpd reload\n\n# Create redirect page for \/ to \/admin\necho '&lt;head>  &lt;meta http-equiv=\"Refresh\" content=\"0; URL=\/admin\" \/> &lt;\/head>' | sudo tee \/var\/www\/html\/index.html\n\n# Create 'get-hostname.php' file in \/var\/www\/html as well, this is for Aria Ops management pack.  The contents of the file should be:\n&lt;?php echo '{\"hostname\":\"' . gethostname() . '\"}'; ?><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Active Directory Join<\/h2>\n\n\n\n<p>Most Ubuntu boxes in my lab are joined to Active Directory for common logins.  I configured the same for the Raspberry Pi, although it is not really required.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># configure AD\necho '%lab\\ linux\\ sudoers ALL=(ALL) NOPASSWD:ALL' | sudo tee -a \/etc\/sudoers\nsudo \/usr\/sbin\/pam-auth-update --enable mkhomedir\n\nsudo \/usr\/sbin\/realm join lab.enterpriseadmins.org -U svc-windowsjoin --computer-ou \"ou=services,ou=lab servers,dc=lab,dc=enterpriseadmins,dc=org\"\nsudo sed -i -e 's\/^#\\?use_fully_qualified_names.*\/use_fully_qualified_names = False\/g' \/etc\/sssd\/sssd.conf\nsudo systemctl restart sssd.service<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Static IP<\/h2>\n\n\n\n<p>Once everything was configured\/ready, I decided to put the device in service by changing the IP from the DHCP address originally obtained to the static IP address I have configured on most devices.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>network:\n version: 2\n ethernets:\n   eth0:\n     match:\n       macaddress: \"dc:a6:32:aa:aa:aa\"\n     dhcp4: no\n     addresses: &#91;192.168.127.53\/24]\n     routes:\n      - to: default\n        via: 192.168.127.254\n     nameservers:\n         addresses: &#91;192.168.127.53,192.168.32.53]<\/code><\/pre>\n\n\n\n<p>To make the new network settings active, we must apply those file changes with <code>sudo netplan apply<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Cleanup<\/h2>\n\n\n\n<p>The Raspberry Pi Imager utility used <code>cloud-init<\/code> to do some customizations.  This was running at each startup and left a few messages on the system console.  Since we no longer need <code>cloud-init<\/code> after the system is online, we&#8217;ll just remove the package with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt purge cloud-init<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>The Raspberry Pi in my lab has been running for about 5 years with little to no maintenance. Other than this one failed SD card things have been very reliable. The steps here are mostly notes for future reference if I need to rebuild the device again.  Hopefully you&#8217;ll find the notes helpful. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my home network, I have a Raspberry Pi4 which provides DNS (pi-hole) and NTP (chrony). Its a device that I don&#8217;t touch often and is a &#8216;production&#8217; type service &#8212; in my lab I don&#8217;t mind blowing up \/ &hellip; <a href=\"https:\/\/enterpriseadmins.org\/blog\/lab-infrastructure\/step-by-step-installing-ubuntu-24-04-on-a-raspberry-pi-for-dns-and-ntp\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9],"tags":[],"class_list":["post-2076","post","type-post","status-publish","format-standard","hentry","category-lab-infrastructure"],"_links":{"self":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/2076","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/comments?post=2076"}],"version-history":[{"count":8,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/2076\/revisions"}],"predecessor-version":[{"id":2105,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/2076\/revisions\/2105"}],"wp:attachment":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/media?parent=2076"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/categories?post=2076"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/tags?post=2076"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}