Setting Up a Private Network for Dedicated Servers (Ubuntu/Debian)
Please use the “Print” function at the bottom of the page to create a PDF.
For Dedicated Servers managed in the Cloud Panel
With a private network, you can divide your existing network into several logical networks. The servers communicate using local IPs that are not routed on the Internet.
The use of private networks offers you the following advantages:
You can organise your networks according to organisational aspects.
You can easily add or remove your servers.
You can reduce latency and network load.
You can optimise traffic by prioritising data packets.
Each server can only communicate with servers on the same private network.
You can seal off servers with confidential data.
The use of a private network can be useful in the following example cases:
Setting up a private network for departments or project teams
Setting up a private network connected to a load balancer
Setting up a private network for a web server and a database server
You can create a private network consisting of dedicated servers by configuring tagged VLANs. VLANs are virtual local networks. These are combined into one standard in IEEE 802.1Q. With VLANs, you can divide an existing physical network into multiple logical networks with different subnets. The data traffic is encapsulated so that data from one or more VLANs can be transmitted independently of each other.
Tagged VLANs do not have a fixed assignment between the virtual network and a port. The assignment is made by marking the data packets. The data packets are provided with tags in which the VLAN ID is stored. This is done according to IEEE 802.1Q by the respective terminal device. In this case, these are the servers assigned to the private network.
Using the VLAN ID, a switch can recognise to which VLAN the data packet belongs. This allows multiple VLANs to be used via a single switch port.
Caution
This article assumes you have a basic knowledge of Linux server administration.
If you do not configure the server correctly, it may no longer be available.
To use the private network for dedicated servers, you must configure all the servers assigned to the network.
To configure an Ethernet interface of a server with Ubuntu as an IEEE 802.1Q VLAN trunk:
Prerequisites
You have created at least two dedicated servers.
You have assigned the dedicated servers to a private network.
Determining the VLAN ID
The VLAN ID is required for configuring the network card.
How to determine the VLAN ID:
Open the Cloud Panel.
Select the desired server in the Infrastructure > Server section.
Scroll to the Private Networks menu item.
Make a note of the VLAN ID. Example: VLAN: 3509
Installing the VLAN Package
Log on to the server as an administrator.
Make sure that the VLAN package is installed. To install the VLAN package, enter the following commands:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install vlan
Configuring the Network Interface
In this step, you must configure the network interface for the VLAN or the private network. The example below assumes that a host needs access to a VLAN connected to the eth0 network interface. The assigned IP address for the host is 192.168.2.1/24 for VLAN 3509. For other VLANs, the setup is the same.
Note
The name of the network interface must comply with the naming convention supported by vconfig. The input format used and recommended here is ethx.y. Here ethx is the name of the physical interface. The placeholder y is the VLAN ID.
Open the file /etc/network/interfaces with vi.
root@example.com:~# vi /etc/network/interfaces
Note
The vi editor has an insert mode and a command mode.
You can enter the insert mode by pressing the i button. In this mode, the entered characters are immediately inserted into the text.
To enter the command mode, press the ESC key. When you use the command mode, your keyboard input is interpreted as a command.
Define the network interface. Enter the required information in the following form:
auto [NAME_OF_THE_PHYSICAL_INTERFACE_AND_VLAN-ID]
iface [NAME_OF_THE_PHYSICAL_INTERFACE_AND_VLAN-ID] inet static
address [IP-ADDRESS_OF_THE_SERVERS_IN_PRIVATE_NETWORK]
netmask [MAC-ADDRESS]Example:
auto eth0.3509
iface eth0.3509 inet static
address 192.168.2.1
netmask 255.255.255.0To exit vi and save the file, type the command below and then press Enter:
:wq
To restart the network interface for the private network, type the following command:
root@example.com:~# ifup [NAME_OF_THE_PHYSICAL_INTERFACE_AND_VLAN-ID]
Example:
ifup eth0.3509
Testing the Network Configuration
To test the network configuration, type the following command:
ifconfig [NAME_OF_THE_PHYSICAL_INTERFACE_AND_VLAN-ID]
Example:
ifconfig eth0.3509
If the network interface has been successfully configured, the following message is displayed, for example:
eth0.3509 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:192.168.2.1 Bcast:12.168.2.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Troubleshooting
The physical network interface was not found:
For example, if the physical network interface is not found, the following error message is displayed:
/etc/network/if-pre-up.d/vlan: line 15: vconfig: command not found
SIOCSIFADDR: No such device
vlan1: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
vlan1: ERROR while getting interface flags: No such device
Failed to bring up vlan1.
Enter the command ifconfig and check if the physical network interface exists. Then open the /etc/network/interfaces file and check whether the name of the interface was specified correctly.
/proc/net/vlan config could not be opened
When you test the network configuration, you receive an error message that is identical or similar to the following error message.
WARNING: Could not open /proc/net/vlan/config. Maybe you need to load the 8021q module, or maybe you are not using PROCFS???
ERROR: trying to set name type for VLAN subsystem, error: Package not installed
WARNING: Could not open /proc/net/vlan/config. Maybe you need to load the 8021q module, or maybe you are not using PROCFS???
ERROR: trying to add VLAN #1 to IF -:eth0:- error: Package not installed
SIOCSIFADDR: No such device
eth0.1: ERROR while getting interface flags: No such device
SIOCSIFNETMASK: No such device
eth0.1: ERROR while getting interface flags: No such device
Failed to bring up eth0.1.
If you receive such an error message when testing the network configuration, this may be due to the following reasons:
The kernel module 802.1Q was not found.
The /proc directory was not mounted.
To reload the kernel module, enter the command ifup.
To check whether the 802.1Q kernel module is currently loaded, type the following command:
lsmod | grep 8021q
If the kernel module 802.1Q is not listed, it was not found. To confirm this, enter the following command:
modprobe 8021q
If you are using a normal kernel, you can use the following command to load the required module package:
apt-get install linux-image-2.6.26-2-486