For CentOS Stream 8 and CentOS Stream 9.

In a private network, the servers communicate via local IPs that are not routed on the Internet. To use a server in a private network, you must configure the network interface on the server. To configure the network interface for the private network:

Requirements
  • You have created a private network.

  • You have assigned the desired server to the private network in the Cloud Panel.

Determining the subnet address and subnet mask of the private network

  • Activate the desired private network in the Network > Private Network area.

  • Make a note of the subnet address and the subnet mask. These are displayed in the Configuration area.

Configuring the Private Network Interface

  • Log in to the server.

  • If the server has been assigned to a private network, there is an additional, non-configured network interface on the assigned server. To display this, enter the following command:

    [root@localhost ~]# ip addr

    Example:

    [root@localhost ~]# ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether 00:50:56:2d:ff:ae brd ff:ff:ff:ff:ff:ff
        altname enp11s0
        inet 217.160.29.162/32 scope global dynamic noprefixroute ens192
           valid_lft 24491sec preferred_lft 24491sec
        inet6 fe80::250:56ff:fe2d:ffae/64 scope link noprefixroute
           valid_lft forever preferred_lft forever
    3: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether 00:50:56:2b:fd:bf brd ff:ff:ff:ff:ff:ff
        altname enp19s0
        inet6 fe80::3766:8db9:43a9:bc87/64 scope link noprefixroute
           valid_lft forever preferred_lft forever

  • Make a note of the name of the non-configured network interface for the private network and the MAC address. In the example above, the name of the non-configured network interface for the private network is ens224. The MAC address is 00:50:56:2b:fd:bf.

  • Use vi to create the configuration file for the unconfigured interface. Example:

    [root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens224

  • To configure the private network, enter the following information:

    NAME="Private [NAME_OF_PRIVATE_NETWORK_INTERFACE]"
    DEVICE="[NAME_OF_PRIVATE_NETWORK_INTERFACE]"
    IPADDR="[IP-ADDRESS_OF_SERVERS_IN_PRIVATE_NETWORK]"
    NETMASK="[SUBNETMASK_OF_PRIVATE_NETWORK]"
    HWADDR="[MAC ADDRESS]"
    BOOTPROTO="none"
    ONBOOT="yes"
    USERCTL="no"

    Example:

    NAME="Private ens224"
    DEVICE="ens224"
    IPADDR="192.168.2.2"
    NETMASK="255.255.255.0"
    HWADDR="00:50:56:2b:fd:bf"
    BOOTPROTO="none"
    ONBOOT="yes"
    USERCTL="no

Notes

  • In order to be able to use a server in a private network, you must manually assign an IP address under which the server can be reached in the private network as part of the manual configuration of the network interface. This IP address cannot be routed to public networks.

    You need the following information to define the IP address:

    Subnet address: The subnet address specifies the private network in this case.

    Subnet mask: The subnet mask specifies which part of the IP address is used to identify the host (or server) and which part classifies the network itself.

    Using this information, you can define the IP address under which the server should be accessible in the private network.

    Example:

    If the defined subnet address or network range is 192.168.1.0 and the subnet mask 255.255.255.0 is used, this means that all computers or servers match in the first three bytes. In total, you can use a maximum of 254 host addresses in this example (192.168.1.1 to 192.168.1.254). Thus, if you have assigned 2 servers to a private network, you can assign, for example, IP addresses 192.168.1.1 and 192.168.1.2 to the respective servers.

  • The editor vi has an insert mode and a command mode. You can call the insert mode with the [i] key. In this mode, the characters entered are immediately inserted into the text. To enter the command mode, press the ESC key afterwards. If you use the command mode, your keyboard entries are interpreted as a command.

  • To exit vi and save the file, type the following command and then press Enter:

    :wq

  • Restart the server to apply the changes. To do this, type the following command:

    [root@localhost ~]# systemctl reboot

Check configuration

To check whether the network interface for the private network has been configured correctly, send a ping to the IP address of another server assigned to the private network. Example:

[root@localhost ~]# ping -c 1 192.168.2.1
PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data.
64 bytes from 192.168.2.1: icmp_seq=1 ttl=64 time=0.037 ms

--- 192.168.2.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.037/0.037/0.037/0.000 ms

When the data packets are delivered to the server, the network interface has been configured for the private network.