[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. But if I change the default gateway first and then execute Iexplore.exe, it went to Korea.

So how can I flush the route table cache? Thanks.

This question is related to windows winsock routes

The answer is


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)


route -f causes damage. So we need to either disconnect the correct parts of the routing table or find out how to rebuild it.


In Microsoft Windows, you can go through by route -f command 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 arp command.