NetworkManager

In Ubuntu 21.04, you will not see and files at /etc/network/interfaces. Also, in checking /etc/neteplan/01-network-manager-all.yaml there is a message:

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

Change to static IP address if you use Ubuntu as a server. The interface name [enp1s0] is different on each environment, replace it to your own one.

Rename to disable default setting

# mv /etc/netplan/00-installer-config.yaml /etc/netplan/00-installer-config.yaml.org

Create new

root@localhost:~# vi /etc/netplan/01-netcfg.yaml

Edits:

network:
  ethernets:
    # interface name
    enp1s0:
      dhcp4: no
      # IP address/subnet mask
      addresses: [192.168.0.45/24]
      # default gateway
      gateway4: 192.168.0.1
      nameservers:
        # name server to bind
        addresses: [8.8.8.8,1.1.1.1]
      dhcp6: no
  version: 2

# apply changes

root@localhost:~# netplan apply

Check networking

root@localhost:~# ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 52:54:00:37:5a:11 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.30/24 brd 10.0.0.255 scope global enp1s0
       valid_lft forever preferred_lft forever
    inet6 fe80::5054:ff:fe37:5a11/64 scope link
       valid_lft forever preferred_lft forever

Leave a Comment