DEV Community

Rümeysa Öz for OpenLAB

Posted on

Ubuntu 22.04 - Using NTP and Disabling It

1. Configuring NTP with Netplan

Netplan is a tool used for network configuration management on Ubuntu. You can use Netplan to control the use of NTP over DHCP.

1.1. Opening the Netplan Configuration File:

The Netplan configuration file is usually found under the /etc/netplan/ directory. To edit this file, use:

sudo nano /etc/netplan/00-installer-config.yaml
Enter fullscreen mode Exit fullscreen mode

1.2. Adding NTP Settings:

In the opened file, you can prevent NTP from being used over DHCP by adding the following configuration:

network:
  ethernets:
    ens18: # This should be changed according to your network adapter's name.
      renderer: networkd
      dhcp4: true
      dhcp4-overrides:
        use-ntp: false
  version: 2
Enter fullscreen mode Exit fullscreen mode

Save your changes and exit the file.

2. Applying the Configuration

To apply the configuration, run the following command:

sudo netplan apply
Enter fullscreen mode Exit fullscreen mode

This command will activate the changes you made.

3. Default Usage of NTP

By default, Ubuntu has DHCP set to use NTP. However, in certain situations, you may want to disable this feature.

3.1. Default Usage of NTP over DHCP:

By default in Netplan, DHCP is set to use NTP with the use-ntp: true setting. However, if you want to disable this feature, you need to set the use-ntp: false value under dhcp4-overrides. This has been shown in the configuration mentioned above.

REFERENCES:

Top comments (0)