我在 Hetzner 服务器上有一个带有 Proxmox 的附加 IP,我想将其路由到 Ubuntu 客户机
这是我在主机和客户机上的网络配置
我的客户机是 Ubuntu 18.04
配置不起作用
我的 PVE 主机网络配置:
# network interface settings; autogenerated
# Please do NOT modify this file directly, unless you know what
# you're doing.
#
# If you want to manage parts of the network configuration manually,
# please utilize the 'source' or 'source-directory' directives to do
# so.
# PVE will preserve these directives, but will NOT read its network
# configuration from sourced files, so do not attempt to move any of
# the PVE managed interfaces into external files!
source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback
auto enp0s31f6
iface enp0s31f6 inet static
address 77.77.77.241
netmask 255.255.255.192
gateway 77.77.77.193
pointopoint 77.77.77.193
up route add -net 77.77.77.192 netmask 255.255.255.192 gw 77.77.77.193 dev enp0s31f6
post-up echo 1 > /proc/sys/net/ipv4/conf/enp0s31f6/proxy_arp
# route 77.77.77.192/26 via 77.77.77.193
auto vmbr0
iface vmbr0 inet static
address 77.77.77.241
netmask 255.255.255.192
bridge_ports none
bridge_stp off
bridge_fd 0
bridge_maxwait 0
up route add -host 77.77.77.242 dev vmbr0
我的 Ubuntu VM 网络配置:
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
version: 2
renderer: networkd
ethernets:
ens18:
addresses:
- 77.77.77.242/26
dhcp4: no
dhcp6: no
gateway4: 77.77.77.193
routes:
- to: 0.0.0.0/0
via: 77.77.77.193
on-link: true
nameservers:
addresses:
- 8.8.8.8
- 4.2.2.4
我还创建了一个名为 /etc/sysctl.d/99-networking.conf 的文件并插入以下内容
net.ipv4.ip_forward=1
net.ipv4.conf.enp0s31f6.send_redirects=0
net.ipv6.conf.all.forwarding=1
我无法使用桥接模式,因为 Hetzner 不允许在同一个外部 IP 上使用多个 MAC,所以我必须使用路由模式