aws_EC2_多网卡多IP配置
弹性网络接口
弹性网络接口 - Amazon Elastic Compute Cloud
如何让我的辅助网络接口在我的 Ubuntu Amazon 弹性计算云 (Amazon EC2) 实例中工作?
配置 Ubuntu 18.04
Ubuntu 18.04 已将其网络配置切换为 Netplan。以下示例使用了 Netplan 配置。请注意,Netplan 使用了 YAML 格式,因此缩进很重要。下面的示例使用了一个双空格缩进。
1.为辅助接口创建一个配置文件:
vim /etc/netplan/51-eth1.yaml
2.将以下行添加到 51-eth1.yaml 文件。
network:
ethernets:
eth0:
addresses: [172.31.23.111/24,172.31.16.119/24]
dhcp4: true
dhcp6: false
match:
macaddress: 0e:d9:c7:d9:e3:83
set-name: eth0
eth1:
addresses:
- 172.31.17.236/20
- 172.31.20.75/20
dhcp4: no
routes:
- to: 0.0.0.0/0
via: 172.31.16.1 # Default gateway
table: 1000
- to: 172.31.17.236
via: 0.0.0.0
scope: link
table: 1000
- to: 172.31.20.75
via: 0.0.0.0
scope: link
table: 1000
routing-policy:
- from: 172.31.17.236
table: 1000
routing-policy:
- from: 172.31.20.75
table: 1000
version: 2
network:
version: 2
renderer: networkd
ethernets:
eth1:
addresses:
- 172.31.17.236/20
dhcp4: no
routes:
- to: 0.0.0.0/0
via: 172.31.16.1 # Default gateway
table: 1000
- to: 172.31.17.236
via: 0.0.0.0
scope: link
table: 1000
routing-policy:
- from: 172.31.17.236
table: 1000
network:
version: 2
renderer: networkd
ethernets:
eth1:
addresses:
- 172.31.24.153/20
- 172.31.28.195/20
dhcp4: no
routes:
- to: 0.0.0.0/0
via: 172.31.16.1 # Default gateway
table: 1000
- to: 172.31.24.153
via: 0.0.0.0
scope: link
table: 1000
- to: 172.31.28.195
via: 0.0.0.0
scope: link
table: 1000
routing-policy:
- from: 172.31.24.153
table: 1000
- from: 172.31.28.195
table: 100