For AI agents: the complete documentation index is available at /en/llms.txt, the full documentation bundle is available at /en/llms-full.txt, and this page is available as Markdown at /en/vps/privat-natverk.md.
  • English
  • Private network

    Every customer has their own private network between their VPS servers. It is a layer 2 network: the servers see each other directly, as if they were plugged into the same switch. No other customer can reach it, and it cannot be reached from the internet.

    All your VPS services are on the same private network, both VPS Bygg själv and VPS Cloud. What differs is how the servers get their addresses:

    • VPS Bygg själv: the server gets a second network card on the private network, without an address. You choose the addresses and set them yourself.
    • VPS Cloud: the service gets its own private /24, for example 10.240.7.0/24. The portal assigns the addresses for you when you create servers.

    Below is one example for each product, and one for combining them.

    Example 1: VPS Bygg själv

    You have two servers, web1 and db1, and want the web server to talk to the database over the private network.

    Step 1: Find the network card

    Log in to the server and list the network cards:

    ip -br link

    The first card (usually eth0) has your public address. The second, often eth1 or ens19, is the private network. It shows DOWN or has no address until you have configured it.

    Step 2: Choose addresses

    Choose a private address range that you do not use anywhere else, for example 10.10.0.0/24, and give each server its own address in it:

    ServerPrivate address
    web110.10.0.11/24
    db110.10.0.12/24

    Do not set a gateway on the private card. The server should keep reaching the internet through its public card.

    Step 3: Set the address

    The server already has network settings from cloud-init, which sets up the private card for DHCP. There is no DHCP on the private network, so you set the address yourself in a way that cloud-init does not overwrite. Pick your system:

    Ubuntu (netplan). Create /etc/netplan/60-privat.yaml with your card name and address:

    network:
      version: 2
      ethernets:
        eth1:
          addresses: [10.10.0.11/24]
    sudo chmod 600 /etc/netplan/60-privat.yaml
    sudo netplan apply

    Debian (ifupdown). First turn off cloud-init's network settings:

    echo 'network: {config: disabled}' | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

    Then open /etc/network/interfaces.d/50-cloud-init. Delete everything from the line auto eth1 and down, and write this instead:

    auto eth1
    iface eth1 inet static
        address 10.10.0.11/24

    Restart the server with sudo reboot.

    Rocky Linux, AlmaLinux and Fedora (NetworkManager). Create your own profile with a higher priority than cloud-init's, or cloud-init's profile takes over at the next restart:

    sudo nmcli con add type ethernet ifname eth1 con-name privat \
      connection.autoconnect-priority 200 \
      ipv4.method manual ipv4.addresses 10.10.0.11/24 ipv6.method disabled
    sudo nmcli con up privat

    FreeBSD. cloud-init rewrites ifconfig_eth1 at every boot, so add the address as an alias:

    sudo sysrc ifconfig_eth1_alias0="inet 10.10.0.11/24"
    sudo ifconfig eth1 inet 10.10.0.11/24 alias

    Do the same on db1 with 10.10.0.12/24.

    Step 4: Test

    From web1:

    ping -c 3 10.10.0.12

    Then let the database listen on the private address (10.10.0.12) instead of the public one, so it is not exposed to the internet at all.

    Example 2: VPS Cloud

    You have a VPS Cloud service and want one public server, web1, and one database server, db1, that only exists on the private network.

    Step 1: Find your private network

    The service gets its private /24 automatically when you order. You see it as a separate choice under IPv4 Pool when you create a server, for example 10.240.7.0/24.

    When you add a network interface, the private network is called v followed by a code, for example v1266, in the Bridge field. pub1 is the public network.

    The addresses .0, .1 and .255 in your /24 are never assigned.

    Step 2: Create the public server

    1. Open the service in the portal and choose Add new server.
    2. Fill in the hostname and a password, and select your key under SSH keys. Then choose the OS template and the server's cores, RAM and disk. See Logging in to the server if you have not saved a key.
    3. Under Interface net0: choose IPv4 Pool Public IP(s) and Number of IPs 1.
    4. Click Create new Virtual Machine.

    Step 3: Connect the public server to the private network

    1. Open the server and go to Interfaces.
    2. Choose Add new network interface.
    3. Select your private network under Bridge and your private /24 under IPv4 Pool.
    4. Click Assign new IP and then Add new network interface. The server restarts and gets the address on the new interface (net1).

    Step 4: Create the private server

    1. Choose Add new server and fill in the fields as in step 2.
    2. Under Interface net0: select your private /24 under IPv4 Pool. The server is then placed on your private network.
    3. Click Create new Virtual Machine.

    A private server does not use any of the public IPv4 addresses in your pool.

    Step 5: Test

    Log in to web1 and ping the private address of db1, which you find in the Network Interfaces table on the server:

    ping -c 3 10.240.7.23

    You reach db1 over SSH from web1 on the same address. db1 has no public address, so you log in to it through web1, for example with ssh -J.

    Internet from a private server

    A server that is only on the private network cannot reach the internet, so it cannot install updates, for example. Let the public server share its internet connection (NAT). The example below is for Ubuntu and Debian, with web1 on 10.240.7.10 and eth0 as the public card.

    On web1 (the public server):

    echo 'net.ipv4.ip_forward = 1' | sudo tee /etc/sysctl.d/90-nat.conf
    sudo sysctl --system
    
    sudo apt-get install -y nftables
    sudo tee /etc/nftables.conf > /dev/null <<'EOF'
    #!/usr/sbin/nft -f
    flush ruleset
    table ip nat {
      chain postrouting {
        type nat hook postrouting priority srcnat;
        ip saddr 10.240.7.0/24 oifname "eth0" masquerade
      }
    }
    EOF
    sudo systemctl enable --now nftables

    On db1 (the private server): add a default route via web1. Create /etc/netplan/60-default-via-natgw.yaml:

    network:
      version: 2
      ethernets:
        eth0:
          routes:
            - to: default
              via: 10.240.7.10
    sudo chmod 600 /etc/netplan/60-default-via-natgw.yaml
    sudo netplan apply

    Use netplan rather than ip route add, otherwise the route disappears the next time the network restarts. Test with sudo apt-get update on db1.

    The firewall on the NAT server

    flush ruleset clears every nftables rule on the server. If you have your own firewall rules in nftables, add table ip nat to your existing /etc/nftables.conf instead.

    Example 3: Bygg själv and Cloud together

    Since all your services share the same private network, a VPS Bygg själv server can talk directly to your Cloud servers. It only needs an address in the same /24.

    Give the Bygg själv server the address ending in .1 in your Cloud network, for example 10.240.7.1/24, using the steps in example 1. The portal never assigns that address to a Cloud server.

    If you have several Bygg själv servers that need to reach your Cloud servers, put them in a network of their own, for example 10.10.0.0/24, and give the Cloud servers that need to reach them an extra address in the same network.

    Several Cloud services

    If you have several VPS Cloud services, they are all on the same private network, but each service has its own /24. Servers in different /24s cannot reach each other without an extra address or route. If you want all servers in the same network, create them in the same service.

    Good to know

    • The private network has an MTU of 1500.
    • Only your own servers can reach the private network, but it is still a good idea to protect the servers with a firewall of their own.
    • The addresses on the private network are only valid with us and are never visible on the internet.