![VMWare 上的 Ubuntu 具有多个适配器 - 无法 ping 外部](https://linux22.com/image/781966/VMWare%20%E4%B8%8A%E7%9A%84%20Ubuntu%20%E5%85%B7%E6%9C%89%E5%A4%9A%E4%B8%AA%E9%80%82%E9%85%8D%E5%99%A8%20-%20%E6%97%A0%E6%B3%95%20ping%20%E5%A4%96%E9%83%A8.png)
我制作了一台带有 3 个网卡的机器。配置的网络内一切正常,但路由似乎无法正常工作:
ping 8.8.8.8
ping: connect: Network is unreachable
这是我的配置:
/etc/netplan/00-installer-config.yaml:
network:
version: 2
ethernets:
ens160:
addresses:
- 172.16.1.114/16
match:
macaddress: 00:50:56:aa:00:1d
nameservers:
addresses:
- 172.16.1.11
- 172.16.1.20
search:
- domain.com
set-name: produzione
routes:
- to: 0.0.0.0/0
via: 172.16.1.1
table: 60
routing-policy:
- from: 172.16.1.114
table: 60
priority: 300
ens192:
addresses:
- 172.21.2.114/16
match:
macaddress: 00:50:56:aa:6f:ed
nameservers:
addresses:
- 172.16.1.11
- 172.16.1.20
search:
- domain.com
set-name: qa
routes:
- to: 0.0.0.0/0
via: 172.21.1.1
table: 61
routing-policy:
- from: 172.21.2.114
table: 61
priority: 300
ens224:
addresses:
- 172.21.1.114/16
match:
macaddress: 00:50:56:aa:16:92
nameservers:
addresses:
- 172.16.1.11
- 172.16.1.20
search:
- domain.com
set-name: sviluppo
routes:
- to: 0.0.0.0/0
via: 172.21.1.1
table: 62
routing-policy:
- from: 172.21.1.114
table: 62
priority: 300
/etc/iproute2/rt_tables.d/swarm.conf:
# produzione
60 60
# qa
61 61
# sviluppo
62 62
任何帮助深表感谢。
答案1
我忘记了每个接口的路由策略,为了达到 0.0.0.0:
例如:
routing-policy:
- from: 172.16.1.114
table: 60
- to: 0.0.0.0/0
table: 60
以下是我的情况的完整配置:
network:
version: 2
ethernets:
ens160:
dhcp4: no
addresses:
- 172.16.1.114/16
match:
macaddress: 00:50:56:aa:00:1d
nameservers:
addresses:
- 172.16.1.11
- 172.16.1.20
search:
- domain.com
set-name: produzione
routes:
- to: 0.0.0.0/0
via: 172.16.1.1
table: 60
routing-policy:
- from: 172.16.1.114
table: 60
- to: 0.0.0.0/0
table: 60
ens192:
dhcp4: no
addresses:
- 172.21.2.114/16
match:
macaddress: 00:50:56:aa:6f:ed
nameservers:
addresses:
- 172.16.1.11
- 172.16.1.20
search:
- domain.com
set-name: qa
routes:
- to: 0.0.0.0/0
via: 172.21.1.1
table: 61
routing-policy:
- from: 172.21.2.114
table: 61
- to: 0.0.0.0/0
table: 61
ens224:
dhcp4: no
addresses:
- 172.21.1.114/16
match:
macaddress: 00:50:56:aa:16:92
nameservers:
addresses:
- 172.16.1.11
- 172.16.1.20
search:
- domain.com
set-name: sviluppo
routes:
- to: 0.0.0.0/0
via: 172.21.1.1
table: 62
routing-policy:
- from: 172.21.1.114
table: 62
- to: 0.0.0.0/0
table: 62