windows 如何在Windows中刷新路由表?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9739156/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to flush route table in windows?
提问by jay
I am trying to write a program that changes the default gateway of network time by time. But it seems that there are caches on the route table in every process so that I cannot control the network behavior accurately. Can I just flush route table to that process?
我正在尝试编写一个程序,该程序可以随时间更改网络时间的默认网关。但是好像每个进程的路由表上都有缓存,无法准确控制网络行为。我可以将路由表刷新到该进程吗?
For example if I executed an Iexplore.exe first, then changed the default gateway to a Korean vpn, IE still went to amercia default gateway. But if I change the default gateway first and then execute Iexplore.exe, it went to Korea.
比如我先执行了一个Iexplore.exe,然后把默认网关改成韩文vpn,IE还是跑到了美国默认网关。但是如果我先改默认网关,然后执行Iexplore.exe,就跑到韩国了。
So how can I flush the route table cache? Thanks.
那么如何刷新路由表缓存呢?谢谢。
回答by exceed
From command prompt as admin run:
从命令提示符以管理员身份运行:
netsh interface ip delete destinationcache
Works on Win7.
适用于Win7。
回答by DMart
route -f causes damage. So we need to either disconnect the correct parts of the routing table or find out how to rebuild it.
route -f 会造成损坏。所以我们需要要么断开路由表的正确部分,要么找出如何重建它。
回答by w33mhz
You can open a command prompt and do a
您可以打开命令提示符并执行
route print
and see your current routing table.
并查看您当前的路由表。
You can modify it by
你可以修改它
route add d.d.d.d mask m.m.m.m g.g.g.g
route delete d.d.d.d mask m.m.m.m g.g.g.g
route change d.d.d.d mask m.m.m.m g.g.g.g
these seem to work
这些似乎有效
I run a ping d.d.d.d -t change the route and it changes. (my test involved routing to a dead route and the ping stopped)
我运行 ping dddd -t 更改路线并更改。(我的测试涉及路由到死路由并且 ping 停止)
回答by Rizwan Ranjha
In Microsoft Windows, you can go through by route -fcommand to delete your current Gateway, check route / ?for more advance option, like add / delete etc and also can write a batch to add route on specific time as well but if you need to delete IP cache, then you have the option to use arpcommand.
在 Microsoft Windows 中,您可以通过route -f命令删除您当前的网关,检查route / ? 对于更高级的选项,如添加/删除等,也可以编写批处理以在特定时间添加路由,但如果您需要删除 IP 缓存,则可以选择使用arp命令。