打开 /etc/netplan/目录,找到yaml配置文件
vi 01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
eno1:
addresses:
- 111.222.111.222/32
- 111.222.111.223/32 #新增的IPv4 1
- 111.222.111.224/32 #新增的IPv4 2
- 2a01:2a01:2a01:2a01::2/64
- 2a01:2a01:2a01:2a02::2/64 #新增的IPv6 1
- 2a01:2a01:2a01:2a03::2/64 #新增的IPv6 2
routes:
- on-link: true
to: 0.0.0.0/0
via: 111.222.111.1
- to: default
via: 2a01::1
nameservers:
addresses:
- 192.12.64.2
- 2a01:2a01:2a01::add:1
- 192.12.64.1
- 2a01:2a01:2a01::add:2
新增的IPv4 1与新增的IPv4 2就是添加的新IPv4,新增的IPv6 1和新增的IPv6 2就是添加的新IPv6,有几个添加几个。添加完成后保存配置文件:
:wq!
最后重启网卡即可:
sudo netplan apply
重启完成后ping下新添加的IP看看是否生效。
原创文章,作者:中国IPv6网,如若转载,请注明出处:https://www.ipv6s.com/basis/routing/202210112780.html