Update network settings on devices in the subnetwork
If you changed the network settings (DNS servers, default gateway, static routes) of a private subnet that has devices on it, you must update the network settings on all devices on the subnet to apply the settings.
Update network settings on the cloud server
If you first change the network settings of a private subnet (DNS servers, default gateway, static routes) and then create cloud servers in it, all settings on the servers will be automatically assigned.
If you first created the cloud servers and then changed the subnet network settings to apply the settings:
- Check DHCP on the private subnet.
- Apply the new network settings on the cloud server.
- Modify the cloud server network configuration files.
1. Check DHCP on the private subnet
- In the Control panel, on the top menu, click Products and select Cloud Servers.
- Go to Network → Private Networks tab.
- Open the Network page → Subnets tab.
- In the subnet card, open the Automatic Network Settings block.
- Check whether the DHCP server toggle switch is on or off.
2. Apply the new network settings to the cloud server
If DHCP is enabled
Apply the new network settings depending on the DHCP client:
-
re-request information from the DHCP server on the cloud server — the new network settings will be added without deleting the old ones:
dhclient <interface_name>
Specify
<interface_name>
is the interface name, for exampleeth0
; -
or turn off, then turn on the port and re-request information from the DHCP server on the cloud server — the new network settings will be added, while the old ones will be deleted:
INTERFACE=<interface_name>; ip link set $INTERFACE down && ip link set $INTERFACE up && dhclient $INTERFACE
Specify
<interface_name>
is the interface name, for exampleeth0
.
If DHCP is turned off
If DHCP is disabled on the private subnet, the algorithm for applying new network settings depends on the presence of a cloud-init or cloudbase-init agent in the images from which the cloud server is created. Agents are pre-installed in all pre-built cloud platform images. Agents must be installed if you uploaded an image to the Selectel image repository using the Prepare an ISO image to work with the cloud platform instructions.
Cloud-init is installed
Cloud-init is not installed
- In the dashboard, on the top menu, click Products and select Cloud Servers.
- Open the Cloud Server page → Ports tab.
- If the When Restarting Server option is specified in the Port Setup block, perform a programmatic reboot of the server.
- If the Port Configuration block specifies Manual in the network configuration file, modify the cloud server network configuration file.
Modify the network configuration file of the cloud server.
3. Modify the cloud server network configuration file
You must modify the cloud server network configuration file if DHCP is disabled on the private subnet and:
- cloud server is created from an image without cloud-init or cloudbase-init agent;
- The cloud server is created from a cloud-init or cloudbase-init agent image, but the Port Configuration block specifies the Manual option in the network configuration file.
If you later enable DHCP on a private subnet, the network settings specified in the file will no longer work — DHCP applies its own settings to all servers.
These are instructions with examples of changing network settings in the network configuration file: DNS servers, default gateway, static routes. Configuration files and network settings may vary from distribution to distribution.
Linux
Windows
The configuration depends on the utility that is installed on the cloud server: ifupdown or netplan. In cloud servers created from off-the-shelf images running Ubuntu 18.04, 20.04, and 22.04, the default utility for network configuration is ifupdown. You can switch the network configuration from ifupdown to netplan.
ifupdown
netplan
-
Open the CLI.
-
If the cloud server is created from a cloud-init image, the network settings will be synchronized with it and the previous network settings will be specified after the server restarts. To disable synchronization, disable network configuration:
echo "network: {config: disabled}" >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
-
Open the network configuration file:
nano /etc/network/interfaces.d/50-cloud-init.cfg
-
Change the network settings:
auto lo
iface lo inet loopback
dns-nameservers <dns_server_1> <dns_server_2>
auto <interface_name>
iface <interface_name> inet static
address <ip_address>
mtu 1500
post-up route add default gw <gateway> || true
pre-down route del default gw <gateway> || true
up route add -net <destination_subnet_ip_address> netmask <destination_subnet_netmask> gw <next_hop_ip_address>Specify:
<dns_server_1>
,<dns_server_2>
— DNS servers of the private subnet;<interface_name>
— name of the network interface;<ip_address>
— The IP address of the cloud server with the private subnet mask in which it resides. For example,192.168.0.5/29
;<gateway>
— default gateway of the private subnet;<destination_subnet_ip_address>
— for static routes: the IP address of the destination subnet to which traffic will be routed, e.g.172.16.0.8
;<destination_subnet_netmask>
— for static routes: destination subnet mask, for example,29
;<next_hop_ip_address>
— for static routes: next-hop is the IP address through which devices on the source subnet will forward traffic to the destination subnet. You can enter any address from the source subnet.
-
Open the CLI.
-
Open the network configuration file:
nano /etc/netplan/config.yaml
-
Change the network settings:
network:
version: 2
renderer: networkd
ethernets:
<interface_name>:
addresses:
- <ip_address>
nameservers:
addresses: [<dns_server_1>, <dns_server_2>]
routes:
- to: default
via: <gateway>
- to: <destination_subnet>
via: <next_hop_ip_address>Specify:
<interface_name>
— name of the network interface;<ip_address>
— The IP address of the cloud server with the private subnet mask in which it resides. For example,192.168.0.5/29
;<dns_server_1>
,<dns_server_2>
— DNS servers of the private subnet;<gateway>
— default gateway of the private subnet;<destination_subnet>
— for static routes: the CIDR of the destination subnet to which traffic will be routed, e.g.172.16.0.8/29
;<next_hop_ip_address>
— for static routes: next-hop is the IP address through which devices on the source subnet will forward traffic to the destination subnet. You can enter any address from the source subnet.
-
Check the syntax of the file:
sudo netplan try
-
Apply the settings:
sudo netplan apply
-
Configure a static route:
route -p ADD <destination_subnet_ip_address> \
MASK <destination_subnet_netmask> <next_hop_ip_address> \
METRIC <priority>Specify:
<destination_subnet_ip_address>
— The IP address of the destination subnet to which traffic will be routed, e.g.172.16.0.8
;<destination_subnet_netmask>
— destination subnet mask, e.g,29
;<next_hop_ip_address>
— gateway (next-hop) — The IP address through which devices on the source subnet will route traffic to the destination subnet. You can enter any address from the source subnet;<priority>
— an integer that specifies the priority of the specified gateway. For example,1
— is the highest priority.
Update network settings on the Managed Kubernetes cluster
If you first change the network settings of the private subnet (DNS servers, default gateway, static routes) and then create Managed Kubernetes cluster nodes in it, all the settings on the cluster nodes will be written automatically.
If you first created the Managed Kubernetes cluster nodes and then changed the subnet network settings, reinstall the nodes sequentially to apply the settings.
Update network settings on the cloud database cluster
If you first change the network settings of a private subnet (DNS servers, default gateway, static routes) and then create a cloud database cluster in it, all settings on the cluster are automatically prescribed.
If you first create a cloud database cluster and then change the network subnet settings. to apply the settings:
- create a ticket.. Specify:
- Cloud database cluster ID. You can copy in the control panel: in the top menu, click Products → Cloud Databases → in the cluster row, click ;
- Project ID. You can copy in the control panel: in the top menu, click Products → Cloud Databases → open the projects menu (the name of the current project) → in the project line, click ;
- pool in which the subnet is located;
- new network settings to be applied;
- or recreate the cloud database cluster, for example, restore it from a backup. See Restore a cluster (example for PostgreSQL) for details.
Update network settings on the cloud load balancer
If you first change the network settings of a private subnet (DNS servers, default gateway, static routes) and then create a cloud load balancer on it, all settings on the load balancer will be automatically prescribed.
If you first created the cloud load balancer and then changed the network subnet settings to apply the settings:
- recreate the balancer instance.. All balancer settings, target groups and rules will be preserved;
- or recreate the load balancer.
Update the network settings on the file store
If you first change the network settings of a private subnet (DNS servers, default gateway, static routes) and then create a file storage in it, all the settings on the storage will be written automatically.
If you created the file storage first and then changed the network subnet settings, apply the changes.
- In the Control Panel, on the top menu, click Products and select File Storage.
- Open the File Storage page → Settings tab.
- Click Update network settings.