跳到正文
独立服务器技术

[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