How to Create a Linode Private Network with Ease

Author

Reads 1.1K

Close-up of data network cables connected to a patch panel in a server room.
Credit: pexels.com, Close-up of data network cables connected to a patch panel in a server room.

Creating a Linode Private Network is a straightforward process that requires just a few steps. You'll need to create a new network by clicking the "Create a new network" button in the Linode Cloud Manager.

To do this, navigate to the Networking tab and click the "Create a new network" button. This will take you to the network creation page where you can enter a name for your network.

A private network is a virtual network that exists within your Linode account, allowing you to create a secure and isolated environment for your Linodes. This is particularly useful for development and testing purposes.

If this caught your attention, see: Azure Create Virtual Network

Setting Up Private Network

Setting up a private network on Linode involves configuring your database servers to connect securely within the VPC. This requires assigning a private IP address to each server, which is a static value that remains the same even if the IP address changes.

To set up database servers, you can use the linode_instance and linode_stackscript resources, which can install Postgres and set up the database and credentials. Two database servers can be set up, with the second one including configuration to add it to the VPC and allowing access only from the same network.

Computer server in data center room
Credit: pexels.com, Computer server in data center room

The second database server configuration allows access only from the same network, while the first one allows all internet connections. This is achieved by writing different settings to the Client Authentication file (pg_hba.conf).

To configure the VPC settings, you'll need to explicitly assign the server's private IP address, which is the same static value given to the application server. This ensures that the application server can connect to the database from within the VPC.

Here's a comparison of the two database server configurations:

If you're trying to get private IPs set up with your Linodes, make sure you've restarted your linode since adding the private IP. If not, sending in a support ticket can be a good option, as the Linode staff are known to be helpful in resolving such issues.

Using Private IPs

You can use private IPs on your Linode, but you need to restart your Linode after adding the private IP. If that doesn't work, you can send in a support ticket and the Linode staff will help you get it working.

Ethernet Cables Plugged in Network Switch
Credit: pexels.com, Ethernet Cables Plugged in Network Switch

Linode's private IPs are not automatically configured to work between Linodes in the same data center, so you need to set them up manually.

To use a private IP, you need to add it to your Linode's Network tab and restart the Linode. If you're still having trouble, check your /etc/network/interfaces file to make sure it's configured correctly.

Here are some key points to keep in mind when using private IPs:

  • Restart your Linode after adding a private IP.
  • Check your /etc/network/interfaces file for correct configuration.

Set Up Database Servers

Setting up database servers in a Linode private network is a straightforward process that can be accomplished using the linode_instance and linode_stackscript resources. This method allows for the creation of multiple database servers, each with its own configuration.

The first database server is set up in the same way as the application servers, but with a couple of key differences. The second database server includes configuration to add it to the VPC.

Here are the key differences between the two database servers:

  • The second database includes configuration to add it to the VPC.
  • Different settings are written to the Client Authentication file (pg_hba.conf).

The second database server only allows access from the same network, while the first database server allows all internet connections. This is achieved by configuring the pg_hba.conf file to include "host all all samenet md5" for the second database and "host all all all md5" for the first database.

The private IP address of each server is explicitly assigned when configuring the VPC settings, ensuring that the servers can connect to each other within the VPC. This is the same static value that was given to the application server.

For your interest: Network Host

Configuring Steps

Close Up Photo of Network Switch
Credit: pexels.com, Close Up Photo of Network Switch

To configure your Linode private network, you'll need to follow these steps.

First, make sure you're logged in as the root user, or prefix all commands with sudo. If you're not already logged in, type `sudo su` to switch to the root user.

The first real step is to remove the Linode generated file that already exists. Type `rm /etc/systemd/network/05-eth0.network` to delete the file.

Next, create a new networking config file using your preferred text editor, such as Vim, nano, or any other editor you prefer. Type `vim /etc/netplan/eth0.yaml` to open the file in Vim.

Copy and paste the template below into the file. You can remove the comments (the # and everything after it) if you desire.

Here's a summary of the template:

In the template, you'll see IP addresses and gateways specified. Make sure to replace these with your actual network settings.

Once you've copied and pasted the template, save the file and exit the editor.

Finally, validate and apply the network configuration with the command `netplan apply`. This will update your network settings to use the new configuration.

Bessie Fanetti

Senior Writer

Bessie Fanetti is an avid traveler and food enthusiast, with a passion for exploring new cultures and cuisines. She has visited over 25 countries and counting, always on the lookout for hidden gems and local favorites. In addition to her love of travel, Bessie is also a seasoned marketer with over 20 years of experience in branding and advertising.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.