如何查看 IP 路由表

如何查看 IP 路由表

我如何才能看到ip routes我已经添加了ip route add default via x.x.x.55 table test1 例如我添加了199 test1198 test2197 test3到/etc/iproute2/rt_tables

然后我运行:

ip route add default via x.x.x.55 table test1
ip route add default via x.x.x.55 table test2
ip route add default via x.x.x.55 table test3

然后当我检查时route -n,这是我唯一看到的东西

x.x.x.x   0.0.0.0         255.255.255.224 U     0      0        0 tun0

附加测试

ip route flush x.x.x.55
ip route add default via x.x.x.55 table test1
RTNETLINK answers: File exists

我添加的 test1、test2 和 test3 在哪里?

答案1

停止使用netstatroute命令,它们只会让您感到困惑,而且它们没有必要的功能。

要查看基本 IPv4 路由表:

ip route

查看特定表:

ip route list table test1

查看一切

ip route list table all

请记住,这些参数只要保持唯一可识别就可以缩写:

ip r l t all

相关内容