尝试在虚拟机上安装 vps,从网络 10.0.0.0/24 到 192.168.0.0/24 创建重新路由,使用 2 个网卡,一个连接到 10.x 网络,IP 为 10.0.0.3(NAT),另一个连接到 192.x 网络,IP 为 192.168.0.3(仅主机)
知识产权
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eno16777728: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:15:83:8b brd ff:ff:ff:ff:ff:ff
inet 10.0.0.3/24 brd 10.0.0.255 scope global eno16777728
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe15:838b/64 scope link
valid_lft forever preferred_lft forever
3: eno33554952: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:15:83:95 brd ff:ff:ff:ff:ff:ff
inet 192.168.0.3/24 brd 192.168.0.255 scope global eno33554952
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe15:8395/64 scope link
valid_lft forever preferred_lft forever
使用 nmcli
nmcli connection modify "eno16777728" +ipv4.routes "192.168.0.0/24 10.0.0.3"
nmcli connection modify "eno33554952" +ipv4.routes "10.0.0.0/24 192.168.0.3"
nmcli connection reload
nmcli connection up eno16777728
nmcli connection up eno33554952
网络状态监测
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.0.0.2 0.0.0.0 UG 0 0 0 eno16777728
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eno16777728
192.168.0.0 10.0.0.3 255.255.255.0 UG 0 0 0 eno16777728
192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eno33554952
从其他 10.x vps 执行 ping 192.x
ping 192.168.0.3
PING 192.168.0.3 (192.168.0.3) 56(84) bytes of data.
From 192.168.0.24 icmp_seq=2 Destination Host Unreachable
From 192.168.0.24 icmp_seq=5 Destination Host Unreachable
From 192.168.0.24 icmp_seq=9 Destination Host Unreachable
我做错了什么......
答案1
我认为你没有做错任何事,一切看起来都很好,但是看看你的 ping 结果,你是否有 192.168.0.24 网关或类似的东西?如果没有,我认为你的 eno33554952 接口有问题,请检查 VM 配置。