How to Create Private Network for Interconnecting VPSes on Linux Based Server
In this wiki article, we'll walk you through the process of setting up a private network to interconnect multiple Virtual Private Servers (VPS). A private network allows these servers to communicate securely and efficiently, fostering collaboration and data transfer between them. By communicating directly within the private network, VPS instances can experience lower latency compared to traversing external networks. This reduction in latency contributes to faster data transfer and response times, making efficient use of available bandwidth.
Prerequisites:
-
VPS with a supported Linux distribution installed (e.g., Ubuntu, AlmaLinux).
-
Root or sudo access to the VPS instances
- To set up a private network, your VPS must be assigned a private IP address. To allocate a private IP address for your VPS, please reach out to us via a support ticket.
Steps to configure a Private Network on VPS:
Identify Network Interface
ip a
In the output, look for the network interface you want to configure (e.g., ens3).
If your current public network is with DHCP
and you want to keep it that way, choose Method 1 Conversely, if you'd rather set both the Public Network and Private Network to 'Static', opt for Method 2
Method 1: Keeping public IP as DHCP and internal IP as static
As your server is already with DHCP
, there is no need to change with public network interface file.
RHEL / CentOS / Fedora
Create Network Configuration File for Private Network:
sudo nano /etc/sysconfig/network-scripts/ifcfg-ens3:1
Add the following configuration to the file, adjusting the values according to your specific network requirements:
TYPE=Ethernet
BOOTPROTO=none
IPADDR=VPS_PRIVATE_IP # Set your desired private IP address
NETMASK=IP_NETMASK # Set your subnet mask
GATEWAY=IP_GATEWAY" # Set your gateway address
DNS1=8.8.8.8 # Set your primary DNS server
DNS2=8.8.4.4 # Set your secondary DNS server
NAME=ens3:1
DEVICE=ens3:1
ONBOOT=yes
Save
the changes and exit
the text editor.
Restart NetworkManager:
sudo systemctl restart NetworkManager
Check the Configuration
ip a
Debian / Ubuntu
Create Network Configuration File for Private Network:
sudo nano /etc/netplan/00-private-netcfg.yaml
Add the following configuration to the file, adjusting the values according to your specific network requirements:
network:
version: 2
renderer: networkd
ethernets:
ens3:
addresses:
- YOUR_PRIVATE_IP_with_PREFIX
routes:
- to: default
via: YOUR_PRIVATE_IP_GATEWAY
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
Save
the changes and exit
the text editor.
Apply the Changes
sudo netplan apply
Restart Networking Service
sudo systemctl restart systemd-networkd
Check the Configuration
ip addr
Method 2: Configure both public IP and internal IP as static
If your server network is with DHCP
, you can easily switch it to a static IP address by following the below mentioned steps,
RHEL / CentOS / Fedora
Open the Network Configuration File:
sudo nano /etc/sysconfig/network-scripts/ifcfg-ens3
Edit the Configuration:
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=eui64
NAME=ens3
UUID=62de617a-5f83-4ecb-a54c-89afd27ee4a7
DEVICE=ens3
ONBOOT=yes
IPADDR=YOUR_SERVER_PUBLIC_IP_ADDRESS # The desired static IPv4 address for the interface
NETMASK=IP_SUBNET_MASK # The subnet mask for your network
GATEWAY=YOUR_GATEWAY_IP # The IP address of your gateway.
DNS1=8.8.8.8 # The IP address of your primary DNS server.
DNS2=8.8.4.4 # The IP address of your secondary DNS server
Save
the changes and exit
the text editor.
Create Network Configuration File for Private Network:
sudo nano /etc/sysconfig/network-scripts/ifcfg-ens3:1
Add the following configuration to the file, adjusting the values according to your specific network requirements:
TYPE=Ethernet
BOOTPROTO=none
IPADDR=VPS_PRIVATE_IP # Set your desired private IP address
NETMASK=IP_NETMASK # Set your subnet mask
GATEWAY=IP_GATEWAY" # Set your gateway address
DNS1=8.8.8.8 # Set your primary DNS server
DNS2=8.8.4.4 # Set your secondary DNS server
NAME=ens3:1
DEVICE=ens3:1
ONBOOT=yes
Save
the changes and exit
the text editor.
Restart NetworkManager
sudo systemctl restart NetworkManager
Check the Configuration
ip a
Debian / Ubuntu
Open the Network Configuration File:
sudo nano /etc/netplan/<your_network_config_file>
Replace the
with actual name of your network file (e.g., '00-network-manager-all.yaml' or '00-installer-config.yaml') To navigate the 'network' file, List the files in the directory /etc/netplan/
. If you see multiple files, choose the one that corresponds to your network setup.
Edit the Configuration:
network:
version: 2
renderer: networkd
ethernets:
ens3:
addresses:
- YOUR_SERVER_IP_with_PREFIX
routes:
- to: default
via: YOUR_IP_GATEWAY
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
Save
the changes and exit
the text editor.
Create Network Configuration File for Private Network:
sudo nano /etc/netplan/00-private-netcfg.yaml
Add the following configuration to the file, adjusting the values according to your specific network requirements:
network:
version: 2
renderer: networkd
ethernets:
ens3:
addresses:
- YOUR_PRIVATE_IP_with_PRIFIX
routes:
- to: default
via: YOUR_PRIVATE_IP_GATEWAY
nameservers:
addresses:
- 8.8.8.8
- 8.8.4.4
Save
the changes and exit
the text editor.
Apply the Changes
sudo netplan apply
Restart Networking Service
sudo systemctl restart systemd-networkd
Check the Configuration
ip addr
You can verify the connectivity of your private IP by pinging it
ping your_private_ip_address
If you have multiple VPSes within the same datacenter with us, you can establish interconnectivity between them by assigning private IP addresses to each of your VPSes by following the above mentioned steps.
CrownCloud - Get a SSD powered KVM VPS at $4.5/month!
Use the code WELCOME
for 10% off!
1 GB RAM / 25 GB SSD / 1 CPU Core / 1 TB Bandwidth per month
Available Locations: LAX | MIA | ATL | FRA | AMS