Link to home
Start Free TrialLog in
Avatar of portillosjohn
portillosjohn

asked on

Set Default Gateway With Bat File

How does one set the default gateway for all NIC's with a bat file?
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Is this fixed addresses then rather than DHCP allocated?

If it is temporary you can remove the default route and point it elsewhere using:

route delete 0.0.0.0
route add 0.0.0.0 mask 0.0.0.0 x.x.x.x

steve
And you would normally only want one default gateway, can you explain please?
Avatar of portillosjohn
portillosjohn

ASKER

I only want one default gateway. Its just that the nics are named differently on the machines that I will be using the script on.
You can do it using netsh.  If you do

netsh dump > x.txt
and have a look at x.txt it will give you an idea of the commands.

e.g.

netsh interface ipv4 delete route prefix=0.0.0.0/0 interface="Local Area Connection"
netsh interface ipv4 add route prefix=0.0.0.0/0 interface="Local Area Connection" nexthop=x.x.x.x publish=Yes

Steve
ASKER CERTIFIED SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial