简体   繁体   English

如何在Windows中刷新路由表?

[英]How to flush route table in windows?

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. 例如,如果我首先执行Iexplore.exe,然后将默认网关更改为韩语vpn,IE仍然会转到amercia默认网关。 But if I change the default gateway first and then execute Iexplore.exe, it went to Korea. 但是,如果我先更改默认网关然后执行Iexplore.exe,它就会转到韩国。

So how can I flush the route table cache? 那么如何刷新路由表缓存呢? Thanks. 谢谢。

From command prompt as admin run: 从命令提示符作为管理员运行:

netsh interface ip delete destinationcache

Works on Win7. 适用于Win7。

route -f causes damage. 路线-f导致损坏。 So we need to either disconnect the correct parts of the routing table or find out how to rebuild it. 因此,我们需要断开路由表的正确部分或找出如何重建它。

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 dddd -t change the route and it changes. 我运行ping dddd -t更改路由并更改。 (my test involved routing to a dead route and the ping stopped) (我的测试涉及路由到死路线并且ping停止)

In Microsoft Windows, you can go through by route -f command to delete your current Gateway, check route / ? 在Microsoft Windows中,您可以通过route -f命令来删除当前的Gateway,检查路由/? 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 arp command. 更多高级选项,如添加/删除等,也可以编写批处理以在特定时间添加路由,但如果需要删除IP缓存,则可以选择使用arp命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM