Bare Metal & VPS > Network > Switch as a Service > Configuring the network interface of an Ubuntu dedicated server

1.6 Configuring the network interface of an Ubuntu dedicated server

Prerequisites

  • To configure the network interface, you need the VLAN ID value, which you can find in the Links section of the virtual switch details page.
  • The Ethernet port manages the connection to the public network and allows VLANs (dedicated to the virtual switch) to be virtualized via a remote shell. This allows you to configure the VLANs without losing the connection to the server.

Initial server configuration

  • Access the server using an SSH client;
  • to obtain administrative (root) privileges on the server, enter the following command:
     

    $ su -

  • run the following command to edit the Netplan configuration:
     

    nano /etc/netplan/01-netcfg.yaml

  • the initial configuration will be as follows:
     

    network:
      version: 2
      renderer: networkd
      ethernets:
        enp2s0:
        dhcp4: no
        addresses:
          - 62.149.128.4/24
        routes:
          - to: default
            via: 62.149.128.1
        nameservers:
          addresses: [62.149.190.150,217.61.55.10]

    in this example, we assume that:
    • the Ethernet network adapter is named enp2s0;
    • the VLAN ID value of the virtual switch link (available on the details page) is 2022;
    • a server is already connected to the virtual switch with IP address 10.10.10.1 and subnet mask 255.255.255.0;
    • the IP address you want to set is 10.10.10.2;

Creating the new network adapter for the SWaaS service

  • Using Netplan, add the following code to create a network dedicated to the virtual switch:
     

      vlans:
        vlan2022:
          id: 2022
          link: enp2s0
          addresses: [ "10.10.10.2/24" ]

    • based on the example above, you must:
      • enter 2022 for the id;
      • enter enp2s0 for the link;
      • set the IP address to 10.10.10.2/24 (Ubuntu requires CIDR notation);
  • to save the configuration, press Ctrl+s;
  • close the text editor by pressing Ctrl+x;
  • using your SSH client, run the following commands:
    • to check the configuration file created above:
       

      netplan generate

    • if no errors are returned, the file has been written correctly and you can apply the configuration using the following command:
       

      netplan apply

    • check the configuration using the following command:
       

      ip a

    • the output will show enp2s0 as the public network and vlan2022@enp2s0 as the virtual network adapter dedicated to the SWaaS service.