Ubuntu 18.04+ instructions (netplan)

Post Reply
User avatar
Edge100x
Founder
Founder
Posts: 12945
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Ubuntu 18.04+ instructions (netplan)

Post by Edge100x »

  1. Open /etc/netplan/01-netcfg.yaml in your favorite text editor. For instance,

    Code: Select all

    nano /etc/netplan/01-netcfg.yaml
  2. Find the indented line that starts with "addresses:". It should look something like this:

    Code: Select all

          addresses: [ 1.2.3.1/24, 1.2.3.4/24, 1.2.3.5/24 ]
    Or, it may look like this:

    Code: Select all

          addresses:
          - 1.2.3.1/24
          - 1.2.3.4/24
          - 1.2.3.5/24
    Delete what is currently between the brackets, or just all of the IP addresses, if they are on separate lines as in the second format. Then, for each of the IP addresses listed on the "IP list" page,
    1. Start a new line, with spaces to line up with the "a" under the word "addresses", followed by a dash and another space.
    2. Type the IP address, followed by a slash.
    3. Look at the "netmask" column. If it reads "255.255.255.0", type a "24" after the slash. If it reads "255.255.254.0", type a "23" after the slash.
    4. If another IP address is listed that needs to be handled next, repeat the steps for each other IP address.
  3. Find the indented line that starts with "gateway4:". It should look something like this:

    Code: Select all

          gateway4: 1.2.3.254
    Replace the IP address with the first gateway listed on the IP list page. Only one gateway address needs to be entered.
  4. Save the file and exit the text editor. For instance, in nano, press Control-S, followed by Control-X.
  5. Type this command to reload the network:

    Code: Select all

    netplan apply
User avatar
Edge100x
Founder
Founder
Posts: 12945
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Ubuntu 18.04 instructions

Post by Edge100x »

For reference, here is an example default 01-netcfg.yaml file.

Code: Select all

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      addresses: 
      - 1.2.3.4/24
      gateway4: 1.2.3.254
      nameservers:
          addresses:
          - 8.8.8.8
          - 8.8.4.4
          - 1.1.1.1
Post Reply