Перейти к содержимому
Выделенные серверыТехническое

[DEMO] Configure additional IPs

Add an additional IP to the network interface on Ubuntu (netplan) or Debian (ifupdown).

Эта статья пока недоступна на языке «русский». Вы читаете версию на языке «английский».
На этой странице

Find the interface name

bash
ip addr show

Look for the interface that holds your main IP (for example eth0 or enp1s0).

Add the IP

Edit the existing file in /etc/netplan/:

/etc/netplan/50-cloud-init.yaml
network:
  version: 2
  ethernets:
    [INTERFACE]:
      addresses:
        - [MAIN_IP]/[PREFIX]
        - [ADDITIONAL_IP]/32

Apply with automatic rollback if something goes wrong:

bash
sudo netplan try

Add these lines under the main interface:

/etc/network/interfaces
up ip addr add [ADDITIONAL_IP]/32 dev [INTERFACE]
down ip addr del [ADDITIONAL_IP]/32 dev [INTERFACE]

Then restart networking:

bash
sudo systemctl restart networking