Hivelocity provides Layer 2 virtual networks to connect your servers and other infrastructure. Here are some things to know about our VLANs:

  • VLANs are available in all facilities.
  • VLANs are a client account level entity.
  • VLANs have no additional costs.
  • The initial limit is 10 VLANs per client account across all facilities. The limit can be increased by contacting [email protected].
  • Self-serve VLANs are local to a facility. Cross-facility VLANs can be requested by contacting [email protected]

Creating a VLAN

VLANs must be created before you can add ports or route IPs to them.

Via the API

Pass the facility code in which you want to create the VLAN. Remember, only devices in the same facility can be added to the VLAN. To create the VLAN call the POST /vlan endpoint.

curl --request POST \
     --url https://core.hivelocity.net/api/v2/vlan/ \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --header "X-API-KEY: $API_KEY" \
     --data '
{
     "facilityCode": "NYC1",
     "privateNetworkingOnly": false
}

Using a VLAN

Once created, you can add any of your device's ports or bonds into the VLAN. By default, any interface added into the VLAN will be added in trunked mode and tagged. This tag will need to be added to your server in order for it to communicate over the VLAN. You may specify a Native VLAN as described later on this page.

Adding a Port/Bond to a VLAN

Via API

In the API, you assign ports/bonds as members of a VLAN by sending a PUT to the PUT /vlan/{vlanId} endpoint. This endpoint changes the VLAN setup to match the exact state of values given. For example, if you have port 123 in the VLAN and you want to remove it while adding port 456 and bond 789 you would run the following command:

curl --request PUT \
     --url https://core.hivelocity.net/api/v2/vlan/{vlanId} \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --header "X-API-KEY: $API_KEY" \
     --data '
{
     "portIds": [
          456,
          789
     ],
     "ipIds": []
}

Configuring a Port/Bond to Use a Tagged VLAN

Once your port/bond is in the VLAN, you will need to modify the interface on your server in order to make use of the tagged VLAN.

AlmaLinux

Before doing any configuration, ensure 8021q module is loaded.

sudo modprobe --first-time 8021q
modinfo 8021q

In this example, we’ll configure an enp6s0 interface on the server. You can target any interface, including any bonds.

$ ip link  show  dev enp6s0
2: enp6s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether 38:90:a5:14:96:54 brd ff:ff:ff:ff:ff:ff

Make sure the NetworkManager service is running.

$ systemctl status NetworkManager

Now you can use nmcli to create VLAN interface for enp6s0. Get the VLAN Tag ID from the Hivelocity API of your targeted VLAN. In this example, we will use the id 21. Run the following command to create an 802.1Q VLAN interface on Ethernet interface enp6s0:

$ nmcli con add type vlan con-name VLAN21 ifname VLAN21 dev enp6s0 id 21

If you have added IPs to a Routed VLAN Interface, you can then assign an IP address to the Ethernet's VLAN Interface:

$ nmcli connection modify VLAN21 ipv4.addresses 172.10.10.11/24 \
  ipv4.method manual ipv4.gateway 172.10.10.1 \
  ipv4.dns 172.10.10.1 +ipv4.dns 8.8.8.8

To check your work, run:

$ nmcli connection show VLAN21

That's it! You have successfully configured VLAN tagging for your ethernet or bonded interface.

Ubuntu 20

To enable interface communication over a tagged VLAN, open the Netplan configuration file:

sudo nano /etc/netplan/01-netcfg.yaml

Your netplan filename may be slightly different, but it will always be in the /etc/netplan directory.

network:
  version: 2
  renderer: networkd
  ethernets:
    ens3:
      dhcp4: yes

Pick the interface you wish to use: either your port or your bond. In this example we use the ens3 interface. Edit the netplan file as follows:

  • Set the set-name field to a name of your choice
  • Create a vlans section and name your vlan. In this example vlan15
  • Set the id of the VLAN to the tag id returned in the VLAN api request to the Hivelocity API.
  • Set the link value to the name of used for set-name of the ens3 interface.
network:
    version: 2
    renderer: networkd
    ethernets:
        ens3:
            set-name: mainif
    vlans:
        vlan15:
            id: 15
            link: mainif

Once done, save the file and apply the changes by running the following command:

sudo netplan apply

That’s it! You have assigned a static IP to your Ubuntu server. If you'd like to do something more complicated, netplan is well documented in the ubuntu docs.

Windows

To enable communication over tagged VLAN you must first put your target interface into a NIC Team. If you are targeting a bond you can skip this step, since your bond is already a NIC team.

In this example we are targeting interface Ethernet1. Using PowerShell:

New-NetLbfoTeam -Name vTeam -TeamMembers "Ethernet1" -TeamingMode SwitchIndependent -LoadBalancingAlgorithm Dynamic

Next, add the VLAN Tag ID returned by the Hivelocity API when you created the VLAN and add it to the NIC Team. In this example, the tag id is 24:

Add-NetLbfoTeamNic -Team vTeam -VlanID 24 -Name VLAN24

Thats it!

Adding IPs to a VLAN

A Routed VLAN interface with a public IP Subnet is a common setup for hypervisor-like environments, such as k8s deployments. See Routed VLAN Interfaces for instructions on how to make IP Subnets available to interfaces on your VLAN.

Managing VLANs

Via the API

Make a GET request to /vlan to get a list of all your active VLANs.

curl -X GET \
-H "Content-Type: application/json" \
-H "X-API-KEY: $API_KEY" \
https://core.hivelocity.net/api/v2/vlan

Deleting a VLAN

A VLAN cannot be deleted until all bonds, ports and IPs are removed.

Via the API

Pass a DELETE request to /vlans/{VLAN_ID}.

curl -X DELETE \
-H "Content-Type: application/json" \
-H "X-API-KEY: $API_KEY" \
https://core.hivelocity.net/api/v2/vlan/{vlanId}

Setting a Native VLAN

The Hivelocity Bare Metal Cloud native VLAN feature enables support for untagged packets when multiple VLANs are configured on an interface. Packets destined for the native VLAN will always go out as untagged packets. When the interface receives packets that are untagged, it will automatically belong to the native VLAN.

Via the API

You may pass in port objects for each port on the target device. This endpoint changes the ports to match the exact state of values given. For example, if you have ipAssignments on the port and you want to update the native VLAN and you do not pass in the ipAssignment value, the existing ipAssignment will be removed.

curl --request PUT \
     --url https://core.hivelocity.net/api/v2/device/123/ports \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --data '
{
     "ports": [
          {
               "ipAssignments": [],
               "portId": 456,
               "enabled": true,
              "nativeVlanId": 998
          }
     ]
}

Removing a Native VLAN

Make a PUT request to /devices/{deviceId}/ports with a null value for nativeVlanId to remove the native VLAN.

curl --request PUT \
     --url https://core.hivelocity.net/api/v2/device/{deviceId}/ports \
     --header 'Accept: application/json' \
     --header 'Content-Type: application/json' \
     --data '
{
     "ports": [
          {
               "ipAssignments": [],
               "portId": 456,
               "enabled": true,
               "nativeVlanId": null
          }
     ]
}

What’s Next