我已经正确配置了主机服务器和虚拟服务器 (VPS(KVM)) 上的网络,使它们能够通过三个接口之一进行通信和访问。它们每个都运行良好,但我不知道我哪里错了,因为三个接口不能同时工作。
这是我的配置
内部网络
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: yes
外部接口
network:
version: 2
ethernets:
enp2s0:
dhcp4: no
dhcp6: no
addresses:
- 51.38.110.9/32
gateway4: 145.239.244.1
nameservers:
addresses:
- 213.186.33.99
- 8.8.8.8
- 8.8.4.4
search: []
optional: true
routes:
- to: 145.239.244.1/32
via: 51.38.110.9
scope: link
network:
version: 2
ethernets:
enp3s0:
dhcp4: no
dhcp6: no
addresses:
- 51.38.110.8/32
gateway4: 145.239.244.1
nameservers:
addresses:
- 213.186.33.99
- 8.8.8.8
- 8.8.4.4
search: []
optional: true
routes:
- to: 145.239.244.1/32
via: 51.38.110.8
scope: link
network:
version: 2
ethernets:
enp4s0:
dhcp4: no
dhcp6: no
addresses:
- 51.38.110.7/32
gateway4: 145.239.244.1
nameservers:
addresses:
- 213.186.33.99
- 8.8.8.8
- 8.8.4.4
search: []
optional: true
routes:
- to: 145.239.244.1/32
via: 51.38.110.7
scope: link
预先感谢
答案1
最终 .yaml 文件的前身......
用这个替换所有.yaml 文件...
我有两个例子给你……
示例 #1
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: yes
enp2s0:
addresses: [51.38.110.9/32]
nameservers:
addresses:
- 213.186.33.99
- 8.8.8.8
- 8.8.4.4
routes:
- to: 145.239.244.1/32 # this might be wrong
via: 51.38.110.9 # this might be wrong
scope: link
optional: true
enp3s0:
addresses: [51.38.110.8/32]
nameservers:
addresses:
- 213.186.33.99
- 8.8.8.8
- 8.8.4.4
routes:
- to: 145.239.244.1/32 # this might be wrong
via: 51.38.110.8 # this might be wrong
scope: link
optional: true
enp4s0:
addresses: [51.38.110.7/32]
nameservers:
addresses:
- 213.186.33.99
- 8.8.8.8
- 8.8.4.4
routes:
- to: 145.239.244.1/32 # this might be wrong
via: 51.38.110.7 # this might be wrong
scope: link
optional: true
enp5s0:
dhcp4: no
dhcp6: no
示例 #2
network:
version: 2
renderer: networkd
ethernets:
enp1s0:
dhcp4: yes
enp2s0:
addresses: [51.38.110.9/32]
gateway4: 145.239.244.1 # don't use together with routes:
nameservers:
addresses:
- 213.186.33.99
- 8.8.8.8
- 8.8.4.4
optional: true
enp3s0:
addresses: [51.38.110.8/32]
gateway4: 145.239.244.1 # don't use together with routes:
nameservers:
addresses:
- 213.186.33.99
- 8.8.8.8
- 8.8.4.4
optional: true
enp4s0:
addresses: [51.38.110.7/32]
gateway4: 145.239.244.1 # don't use together with routes:
nameservers:
addresses:
- 213.186.33.99
- 8.8.8.8
- 8.8.4.4
optional: true
enp5s0:
dhcp4: no
dhcp6: no
sudo netplan --debug generate
# 生成配置文件
sudo netplan apply
# 应用配置
reboot
# 重启计算机
答案2
所有提供的解决方案都不起作用,直到我为所有 IP 设置一个 MAC 地址http://ovh.com。它可能不适用于其他托管服务提供商。