且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何查看或清除linux环境中的routing cache?

更新时间:2022-09-07 18:30:16

netstat -rn --cache 指令可以打印出linux kernel的转发表。有点类似于cisco的cef表。这个应该是kernel的转发层面的东西。应该是实际数据转发时候查询的表。
[root@localhost ~]# netstat -rn --cache
Kernel IP routing cache
Source          Destination     Gateway         Flags   MSS Window  irtt Iface
10.20.63.100    10.20.1.100     10.20.1.100     l         0 0          0 lo
10.103.5.76     10.103.5.37     10.103.5.37     il        0 0          0 lo
10.20.1.1       10.20.1.100     10.20.1.100     il        0 0          0 lo
10.103.5.201    10.103.5.255    10.103.5.255    ibl       0 0          0 lo
10.103.5.206    10.103.5.255    10.103.5.255    ibl       0 0          0 lo
10.103.5.37     10.103.5.76     10.103.5.76            1500 0          0 eth0
10.103.5.53     10.103.5.255    10.103.5.255    ibl       0 0          0 lo
10.20.1.100     10.20.63.100    10.20.1.10             1500 0          0 eth1
10.103.5.18     10.103.5.255    10.103.5.255    ibl       0 0          0 lo
10.20.1.100     10.20.63.100    10.20.1.10             1500 0          0 eth1
10.103.5.199    10.103.5.255    10.103.5.255    ibl       0 0          0 lo
[root@localhost ~]#
指令 ip -s -s ro flush cache 就可以清除ipv4 的cache. ipv6 也有相应类似指令。
[root@localhost ~]# ip -s -s ro flush cache
*** IPv4 routing cache is flushed.
[root@localhost ~]#


本文转自jasonccier 51CTO博客,原文链接:http://blog.51cto.com/jasonccie/391021,如需转载请自行联系原作者