Ubuntu Server Netplan Static IP With VLAN Settings

This post is the basic configuration needed to setup a static IP address on Ubuntu Server using a VLAN. It is VERY important to note that when using Netplan spacing must be exact. DO NOT use tabs to fill out spaces. Make sure to change the interface name to the interface presented in your installation otherwise this will not work.

  1. Netplan configuration which is located at /etc/netplan most files are named 00-installer-config.yaml
network:
  ethernets:
    ens160: {}
  version: 2
  vlans:
    ens160.99:
      addresses:
      - 192.168.60.2/24
      gateway4: 192.168.60.1
      nameservers:
        addresses:
        - 8.8.8.8
        search: []
      id: 99
      link: ens160

2. Apply the configuration using sudo netplan apply . If the configuration fails to paste check your spacing as everything must be spaced properly.

2 Comments

  1. Hi,

    I am trying to configure static IP on an interface with tagged VLAN.

    I use below configuration in yaml file
    cat 03-vlan.yaml

    network:
    version: 2
    renderer: networkd
    ethernets:
    eno12429: {}
    vlans:
    eno12429.108:
    addresses: [x.x.x.x/28]
    gateway4: “x.x.x.x”
    nameservers:
    addresses:
    – x.x.x.x
    – x.x.x.x
    id: 108
    link: eno12429

    There is no error in netplan apply. Issue is that I am unable to ping gateway. VLAN configuration in switch is correct.
    I am unable to comment more as screenshot not possible here and typing here is bit challenging. Any other scenario you can think so which I should check here.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.