小编Bob*_*Bob的帖子

Linux 上可以有多少个自定义路由表?

我一直在 Linux 上使用自定义路由表,我对“ip route”命令的一些文档和行为感到有些困惑。似乎唯一有效的值应该是 0-255 加上 /etc/iproute2/rt_tables 中定义的名称:

255 local
254 main
253 default
0   unspec
Run Code Online (Sandbox Code Playgroud)

这将为自定义表留下 1-252。尝试使用未定义的表名会出现错误:

$ ip route show table kermit
Error: argument "kermit" is wrong: table id value is invalid
Run Code Online (Sandbox Code Playgroud)

但是,似乎我可以使用远高于 255 的数字而不会出错:

$ ip route show table 1000
[no output]
$ ip route add 10.10.10.0/24 dev eth0 table 1000
[no output]
$ ip route show table 1000
10.10.10.0/24 dev eth0  scope link
Run Code Online (Sandbox Code Playgroud)

在某些时候,事情变得更加奇怪。在 maxint (2^31) 处,它“溢出”到本地表 (255):

$ ip route show table 2147483647
[no output] …
Run Code Online (Sandbox Code Playgroud)

linux route iproute2

12
推荐指数
1
解决办法
2万
查看次数

标签 统计

iproute2 ×1

linux ×1

route ×1