日度归档:2022年9月16日

Ubuntu/Debian 为网卡增加IP地址 2022-9-16

临时为网卡增加IP地址,需要root权限执行

root@server:~# ip address add 192.168.12.22/24 dev eth0    # 增加
root@server:~# ip address del 192.168.12.22/24 dev eth0    # 删除

如果临时添加,先ping,到新增的IP网络可通,再在云服务器上的网卡文件里,配置静态IP地址

To reconfigure servers running Debian, you will need to edit the file
/etc/network/interfaces.d/50-cloud-init

To reconfigure servers running Ubuntu, you will need to edit the file
/etc/netplan/50-cloud-init.yaml 

To reconfigure servers running CentOS, you will need to edit the file
/etc/sysconfig/network-scripts/ifcfg-eth0 

添加之后,重启网络服务,或者直接重启主机都可生效。