尝试在一个以太网端口上为不同子网上的两个 IP 地址配置一个 Ubuntu 18.04 机器,每个 IP 地址都有一个网关,以便端口转发可以从不同的路由器进行。
这是基于 Netplan 文档的。两个 IP 都可以使用,但没有入站或出站互联网访问。
network:
version: 2
renderer: networkd
ethernets:
enp6s0:
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
addresses:
- 192.168.13.200/24
- 192.168.1.100/24
routes:
- to: 0.0.0.0/0
via: 192.168.13.1
metric: 200
- to: 0.0.0.0/0
via: 192.168.1.1
metric: 300
enp8s0:
addresses: [192.168.2.100/24]
dhcp4: false
dhcp6: false
下一次尝试基于另一个答案,但是当我尝试这个时出现错误:“错误:enp6s0:NetworkManager 不支持非默认路由表”
network:
version: 2
renderer: networkd
ethernets:
enp8s0:
addresses: [192.168.2.100/24]
dhcp4: false
dhcp6: false
enp6s0:
dhcp4: no
dhcp6: no
addresses:
- 192.168.1.100/24
- 192.168.13.200/24
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
routes:
- to: 0.0.0.0/0
via: 192.168.1.1
metric: 150
- to: 0.0.0.0/0
via: 192.168.13.1
metric: 150
table: 102
routing-policy:
- from: 192.168.13.0/24
table: 102
- to: 192.168.13.0/24
table: 102
enp7s0:
dhcp4: yes