Files
mkdocs-wiki/docs/linux/netplan.md
T
2024-06-30 14:11:32 +00:00

5.2 KiB
Raw Blame History

Netplan

Netplan is a utility for configuring network interfaces in modern versions of Ubuntu and other Linux distributions. Netplan generates the corresponding configuration files for the underlying network configuration subsystem, such as systemd-networkd or NetworkManager.


How to use

Netplan uses YAML configuration files in the /etc/netplan/ to describe network interfaces, IP addresses, routes, and other network-related parameters.

Example: /etc/netplan/01-netcfg.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: true

This configuration sets up a DHCP client for the enp0s3 Ethernet interface, using the systemd-networkd renderer.

To apply this configuration, run the following command.

sudo netplan apply.

You can also test a new Netplan configuration without applying it permanently. This is useful if you want to try out a new network configuration without disrupting your current network connection.

sudo netplan try

Static IP addresses

To define a static IP address in Netplan, you can use the addresses key in the configuration file for the relevant network interface. Here’s an example configuration file that sets a static IP address of 192.168.1.10 with a net mask of 24 bits for the enp0s3 Ethernet interface:

network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      addresses:
        - 192.168.1.10/24
      gateway4: