Ports
Hivelocity servers come with a 2-port NIC by default, eth0
and eth1
, each connected to independent interfaces on a switch. The switch ports serving each of your server's NICs may be independently configured with IPs and Subnets and attached to VLANs. Depending on the server's top of rack, ports may also be bonded .
Getting Ports
Ports are retrieved by requesting them for a specific device. The port will return information about the current ports:
Via API
Make a GET
request to the /device/DEVICE_ID/ports
curl -X 'GET' \
'https://core.hivelocity.net/api/v2/device/{DEVICE_ID}/ports' \
-H 'accept: application/json' \
-H "X-API-KEY: $API_KEY"
Routing IPs to Ports
IP Subnets can be routed to a dedicated server's individual ports. To route a subnet to an individual port, first make sure that the subnet is not routed to any other entity. You can only route IPs to the public ports. In unbonded scenarios, the first port of your device (eth0
) will always be the public port.
Via API
You can route an IP Subnet to a port, power a port on/off, and update the native vlan of a port with a PUT
request to the /devices/{deviceId}/ports. 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 IP Assignment will be removed.
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": [
"789"
],
"portId": 456,
"enabled": true,
"nativeVlanId": 998
}
]
}
Using the IPs
In order for your server to accept traffic over the assigned IP address, you must first configure your operating system to use a static IP.
All the examples below assume you are assigning the subnet 68.233.234.1/30
. Replace this IP and its gateway with your IP address and Gateway.
AlmaLinux
The first thing we want to do is find the interface that we want to modify. To list all the interfaces on our system, we can use the ip a
command:
$ ip a
...
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:14:b7:83 brd ff:ff:ff:ff:ff:ff
inet 192.168.137.132/24 brd 192.168.137.255 scope global dynamic ens160
valid_lft 1299sec preferred_lft 1299sec
inet6 fe80::20c:29ff:fe14:b783/64 scope link noprefixroute
valid_lft forever preferred_lft forever
On this machine, the interface we are interested in working with is ens160
.
To make your interface accept a designated subnet use the nmcli
tool to change network settings for the target interface.
nmcli connection modify ens160 IPv4.address 68.233.234.1/30
nmcli connection modify ens160 IPv4.gateway 68.233.234.1
Ubuntu
The first step toward setting up a static IP address is identifying the name of the ethernet interface you want to configure. The ip link
command prints a list of all the available network interfaces. In this example, the name of the interface is ens3
. To do so, enter the command below:
ip link
...
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 08:00:27:6c:13:63 brd ff:ff:ff:ff:ff:ff
To assign a static IP address on the network interface, open the Netplan configuration file:
sudo nano /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
ens3:
dhcp4: yes
Your netplan filename may be slightly different, but it will always be in the /etc/netplan
directory.
To assign a static IP address to ens3
interface, edit the file as follows:
- Set DHCP to
dhcp4: no
. - Specify the static IP address. Under
addresses:
you can add one or more IPv4 or IPv6 IP addresses that will be assigned to the network interface. - Specify the gateway.
network:
version: 2
renderer: networkd
ethernets:
ens3:
dhcp4: no
addresses:
- 68.233.234.1/30
gateway4: 68.233.234.1
Once done, save the file and apply the changes by running the following command:
sudo netplan apply
Verify the changes by typing:
ip addr show dev ens3
...
ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 08:00:27:6c:13:63 brd ff:ff:ff:ff:ff:ff
inet 192.168.121.221/24 brd 192.168.121.255 scope global dynamic ens3
valid_lft 3575sec preferred_lft 3575sec
inet6 fe80::5054:ff:feb0:f500/64 scope link
valid_lft forever preferred_lft forever
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
Enter the PowerShell and find your network interfaces with the command:
Get-NetIPInterface -AddressFamily IPv4
...
ifIndex InterfaceAlias AddressFamily NlMtu(Bytes) InterfaceMetric Dhcp ConnectionState PolicyStore
------- -------------- ------------- ------------ --------------- ---- --------------- -----------
6 Ethernet IPv4 1500 15 Enabled Connected ActiveStore
1 Loopback Pseudo-Interface 1 IPv4 4294967295 75 Disabled Connected ActiveStore
In order to use a static IP, you must disable DHCP by running:
Set-NetIPInterface -InterfaceIndex 6 -Dhcp Disabled
Now you can assign your subnet to the target interface. Pay attention to the prefix length and make sure it matches your subnet mask. In our example this would be the 30
from /30
New-NetIPAddress -InterfaceIndex 6 -AddressFamily IPv4 -IPAddress "68.233.234.1" -PrefixLength 30 -DefaultGateway "68.233.234.1'
Confirm your new settings with:
ipconfig /all
...
Windows IP Configuration
Host Name . . . . . . . . . . . . : my.hivelocity.server
Primary Dns Suffix . . . . . . . : hv.server
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
DNS Suffix Search List. . . . . . : hv.server
Ethernet adapter Ethernet:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Red Hat VirtIO Ethernet Adapter
Physical Address. . . . . . . . . : 52-54-00-07-22-41
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::b547:c48c:6151:2fcf%6(Preferred)
IPv4 Address. . . . . . . . . . . : 68.233.234.1(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.252
Default Gateway . . . . . . . . . : 68.233.234.1
DNS Servers . . . . . . . . . . . : 8.8.8.8
NetBIOS over Tcpip. . . . . . . . : Enabled
Remove IPs from Ports
Once a subnet is removed from a port, the IPs will no longer reach the device. In some cases, this can cause your device to become inaccessible. If you lose access to your device, you can use the IPMI Console to reconnect to your device.
Via API
Make a PUT
request to /devices/{deviceId}/ports with a an empty list for ipAssignment
to remove the subnet and/or 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
}
]
}
Updated almost 2 years ago