本文へスキップ
専用サーバー技術情報

[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