我想使用两个网络接口,每个都有自己的默认网关,同时。我在谷歌上发现,iproute2程序可以解决我的问题,但我也必须配置网络计划才能实现这一点。我发现的唯一信息是关于/etc/network/interfaces的
auto lo
iface lo inet loopback
allow-hotplug enp7s0
iface enp7s0 inet static
address 192.168.0.101
netmask 255.255.255.0
gateway 192.168.0.1
allow-hotplug enp8s0
iface enp8s0 inet static
address 192.168.1.16
netmask 255.255.255.0已经不在Ubuntu22.04上了。如何将此配置应用于netplan?
另外,当我编辑/etc/iproute2/rt_tables以添加这些行时
1 rt2
ip route add 192.168.0.0/24 dev enp7s0 src 192.168.0.101 table rt2
ip route add default via 192.168.0.1 dev enp7s0 table rt2
ip rule add from 192.168.0.101/32 table rt2
ip rule add to 192.168.0.101/32 table rt2它产生了这个错误当我
ip规则显示
Database /etc/iproute2/rt_tables is corrupted at ip route add 192.168.0.0/24 dev enp7s0 src 192.168.0.101 table rt2
0: from all lookup local
32766: from all lookup main
32767: from all lookup default不知道哪里出了问题。任何帮助都是非常感谢的。
发布于 2023-03-08 15:55:56
解用
sudo ip route add 192.168.0.0/24 dev enp7s0 src 192.168.0.101 table rt2
sudo ip route add default via 192.168.0.1 dev enp7s0 table rt2
sudo ip rule add from 192.168.0.101/32 table rt2
sudo ip rule add to 192.168.0.101/32 table rt2https://serverfault.com/questions/1125648
复制相似问题