首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iproute2和netplan配置

iproute2和netplan配置
EN

Server Fault用户
提问于 2023-03-08 15:31:32
回答 1查看 137关注 0票数 0

我想使用两个网络接口,每个都有自己的默认网关,同时。我在谷歌上发现,iproute2程序可以解决我的问题,但我也必须配置网络计划才能实现这一点。我发现的唯一信息是关于/etc/network/interfaces

代码语言:javascript
复制
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以添加这些行时

代码语言:javascript
复制
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规则显示

代码语言:javascript
复制
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

不知道哪里出了问题。任何帮助都是非常感谢的。

EN

回答 1

Server Fault用户

发布于 2023-03-08 15:55:56

解用

代码语言:javascript
复制
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 rt2
票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1125648

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档