root@server:/etc/network/if-up.d# cat route.sh
#!/bin/sh
# START
/sbin/ip route del default via 电信网关IP地址 dev ens19
/sbin/ip route add default via 联通网关IP地址 dev ens18
# END
root@server:/etc/network/if-up.d#
# 其中,两个网关IP地址,需要自定义,按实际的来,网络在主机内部对应的名称,可能是ens18,ens19,ens3,ens5,eth0,eth1,根据实际来。
up ip addr add 2a04:92c7:abcd:481::78bc/64 dev eth0
up ip addr add 2a04:92c7:abcd:481:2126:6232:4691:21f1/64 dev eth0
up ip addr add 2a04:92c7:abcd:481:5fe4:268e:d1b4:ece0/64 dev eth0
up ip -6 route add 2a04:92c7:abcd::1 dev eth0
up ip -6 route add default via 2a04:92c7:abcd::1
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