Add route batch file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

My office needs a persistant route added to the routing table on all the
workstations. So we put the following in a batch file:

route add 10.xxx.xx.xx mask 255.255.0.0 10.xxx.x.x -P

The intention was to put it in a logon script or group policy. Execpt when
we run the batch file we get stuck in a loop as it runs the line over and
over. We've tried adding pause and exit commands with the same results.
Anyone have any tricks to avoid this or see a mistake on my part?
Thanks in advance for any thoughts.
 
Well, starting at the beginning,...using Host Routing (routes set at
indivudual host instead of a router) indicates a possible design issue.
Routing should be done only at the LAN's router,...individual hosts should
only have a Default Route to the LAN's router where additional decisions are
made from there. I know there are exceptions in some cases, but this is the
starting point,..the concept you should begin with. So why do you feel you
need to do it the way you are attempting to begin with? Let's start there.

As far as batch files,...batch files run from the top down and stop when
they hit the end. They do not repeat unless they are repeatedly "called"
over and over by and external process or there may be a few cases where
there is an improperly written "GoTo" or "Loop" written into it. So I
cannot really answer that one,..I have nothing to go on.
 
Even if you do go with routing from the hosts, there is no need to do it
repeatedly everytime a user logs into the machine or everytime the machine
is started up (which login scripts or GPOs would cause). The fact that you
use the "-p" parameter makes it permanent. You do it once and it is done
forever until that route manually deleted. So I don't agree with the login
script or the GPO idea. The batch file concept would be fine but it only
need run once manully and that is it. But in the end I don't like
controlling routing from the individual host to begin with, if it can be
avoided.
 
Your asking for more info but this is all there is....
If I were up to me the routing would be assigned by the router. But people
over my head do not have it set up this way. This is a case where a vpn has
been set up between our location and an office in another city for faster
connection between the two.
As far as the batch file, it contains this one line only and is not being
"called" by anything, I manually double click on it to test it. I assumed
this is some kind of glitch and was hoping to find someone who had seen it
before.


Phillip Windell said:
Well, starting at the beginning,...using Host Routing (routes set at
indivudual host instead of a router) indicates a possible design issue.
Routing should be done only at the LAN's router,...individual hosts should
only have a Default Route to the LAN's router where additional decisions are
made from there. I know there are exceptions in some cases, but this is the
starting point,..the concept you should begin with. So why do you feel you
need to do it the way you are attempting to begin with? Let's start there.

As far as batch files,...batch files run from the top down and stop when
they hit the end. They do not repeat unless they are repeatedly "called"
over and over by and external process or there may be a few cases where
there is an improperly written "GoTo" or "Loop" written into it. So I
cannot really answer that one,..I have nothing to go on.


--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com


stephanie said:
My office needs a persistant route added to the routing table on all the
workstations. So we put the following in a batch file:

route add 10.xxx.xx.xx mask 255.255.0.0 10.xxx.x.x -P

The intention was to put it in a logon script or group policy. Execpt when
we run the batch file we get stuck in a loop as it runs the line over and
over. We've tried adding pause and exit commands with the same results.
Anyone have any tricks to avoid this or see a mistake on my part?
Thanks in advance for any thoughts.
 
If I were going to manually run a script at each machine why would I need the
script, the idea here is to not manually apply this to 85 individual
machines. Thanks anyway.

stephanie said:
Your asking for more info but this is all there is....
If I were up to me the routing would be assigned by the router. But people
over my head do not have it set up this way. This is a case where a vpn has
been set up between our location and an office in another city for faster
connection between the two.
As far as the batch file, it contains this one line only and is not being
"called" by anything, I manually double click on it to test it. I assumed
this is some kind of glitch and was hoping to find someone who had seen it
before.


Phillip Windell said:
Well, starting at the beginning,...using Host Routing (routes set at
indivudual host instead of a router) indicates a possible design issue.
Routing should be done only at the LAN's router,...individual hosts should
only have a Default Route to the LAN's router where additional decisions are
made from there. I know there are exceptions in some cases, but this is the
starting point,..the concept you should begin with. So why do you feel you
need to do it the way you are attempting to begin with? Let's start there.

As far as batch files,...batch files run from the top down and stop when
they hit the end. They do not repeat unless they are repeatedly "called"
over and over by and external process or there may be a few cases where
there is an improperly written "GoTo" or "Loop" written into it. So I
cannot really answer that one,..I have nothing to go on.


--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com


stephanie said:
My office needs a persistant route added to the routing table on all the
workstations. So we put the following in a batch file:

route add 10.xxx.xx.xx mask 255.255.0.0 10.xxx.x.x -P

The intention was to put it in a logon script or group policy. Execpt when
we run the batch file we get stuck in a loop as it runs the line over and
over. We've tried adding pause and exit commands with the same results.
Anyone have any tricks to avoid this or see a mistake on my part?
Thanks in advance for any thoughts.
 
stephanie said:
If I were going to manually run a script at each machine why would I need the
script, the idea here is to not manually apply this to 85 individual
machines. Thanks anyway.

Why does everyone have to "cop an attitude" everytime I try to help them to
do something the *right* way? So you want help making the "wrong way" or at
least the "less than ideal way" work? Ok, well the "idea" isn't to run the
batch file manually or automatically,...the "idea" here is to make your
routing works properly and find the best most efficient method to accomplish
that.

My point with the script was that *however* you run it,...it only needs run
once,...so login scripts are not the right choice because it would re-run
everytime the user logged in. Now you could leave it in as a login script
for one or two days to be sure every user has run it at least once then
remove it.

We can not possibly know why the command keeps repeating if you won't show
anyone the exact batchfile's entire contents and also tell us exactly how
you have "run" the script so far to this point?

This whole thing just made my point,...that is why you don't manage routing
at the individual hosts level. Just to give you a perspective with the 85
machines you have, our systems totals well over 2000 machines counting all
20+ sites that are connected via VPN and span from Utah to Rhode Island and
from GrandRapids Michigan down to Puerto Rico in the Carribean.

I have 3 physical Internet Connections and 5 ways out to the Internet with
one Router-to-Router VPN at just the one location I am sitting at here,
other sites are similar so multiply that by 20. I have not one single
workstation here that uses local static routes to make it work. I have 3
bosses over me here and about 3 more at our Corp HQ and if they are doing
something that isn't the best way,...I tell them so,...that is part of my
job,...and I often win, and once in a while I don't,...so I am not oblivous
to what you might have to deal with your bosses.
 
Ok, I saw where you said that this was the only line in the file and it was
run manually. The answer is it could not possibly go into a loop. But
without knowing the IP Range where you are sitting, and the IP Range of the
remote site, and the IP# of the VPN Device I have no way of knowing that the
line is correct. But the "-p" usually comes first and is usually lower case,
although I'm not sure that either really matters.

route -p add 10.xxx.xx.xx mask 255.255.0.0 10.xxx.x.x
 
Phillip Windell said:
Well, starting at the beginning,...using Host Routing (routes set at
indivudual host instead of a router) indicates a possible design issue.

Maybe but such designs are common and
some of theme make perfect sense. Classic
example is a Web server between firewall
(inner/outer routers).

Another perfectly valid example is machines
on a subnet that can access one net (e.g., THE
Internet through one router) and another net (e.g.,
a wireless network) through another router.
Routing should be done only at the LAN's router,...individual hosts should
only have a Default Route to the LAN's router where additional decisions are
made from there.

And the above is just wrong. It misunderstand
that every IP machine "routes" for itself.

To avoid (additional) manual routes for individual
workstations would cause those between multiple
routers to send traffic inefficiently (i.e., twice on
the same wire) much of the time.
I know there are exceptions in some cases, but this is the
starting point,..the concept you should begin with.

When you need them you need them and the situation
is much more common than you allow.
 
stephanie said:
If I were going to manually run a script at each machine why would I need the
script, the idea here is to not manually apply this to 85 individual
machines. Thanks anyway.

That "line" will not rerun itself (all by itself.)

It will run once UNLESS the batch file itself is
in a loop or somehow CALLS itself.

(Like calling the batch file Route.cmd )

Test it on the machine manually to prove it
runs correctly. (Not to really deploy it.)

You can also call "route.exe" explicitly to
guarantee that it runs ONLY the exe:

%systemroot%\\system32\route.exe etc.......

--
Herb Martin

stephanie said:
Your asking for more info but this is all there is....
If I were up to me the routing would be assigned by the router. But people
over my head do not have it set up this way. This is a case where a vpn has
been set up between our location and an office in another city for faster
connection between the two.
As far as the batch file, it contains this one line only and is not being
"called" by anything, I manually double click on it to test it. I assumed
this is some kind of glitch and was hoping to find someone who had seen it
before.


Phillip Windell said:
Well, starting at the beginning,...using Host Routing (routes set at
indivudual host instead of a router) indicates a possible design issue.
Routing should be done only at the LAN's router,...individual hosts should
only have a Default Route to the LAN's router where additional decisions are
made from there. I know there are exceptions in some cases, but this is the
starting point,..the concept you should begin with. So why do you feel you
need to do it the way you are attempting to begin with? Let's start there.

As far as batch files,...batch files run from the top down and stop when
they hit the end. They do not repeat unless they are repeatedly "called"
over and over by and external process or there may be a few cases where
there is an improperly written "GoTo" or "Loop" written into it. So I
cannot really answer that one,..I have nothing to go on.


--

Phillip Windell [MCP, MVP, CCNA]
www.wandtv.com


My office needs a persistant route added to the routing table on all the
workstations. So we put the following in a batch file:

route add 10.xxx.xx.xx mask 255.255.0.0 10.xxx.x.x -P

The intention was to put it in a logon script or group policy. Execpt
when
we run the batch file we get stuck in a loop as it runs the line over and
over. We've tried adding pause and exit commands with the same results.
Anyone have any tricks to avoid this or see a mistake on my part?
Thanks in advance for any thoughts.
 
Well thanks for your help, sorry about "coping an attitude" before I was
already a little flustrated with the problem and just wanted to find a
solution to it, not discuss how it would be implimented. Anyway this is the
exact line (as of right now):
route -p add 10.30.0.0 mask 255.255.0.0 10.111.6.1
I didn't originally think the exact IPs would be of any help...but there it
is just in case. And the IP at the PC I'm working on is 10.111.40.55, does
any of this sound like a problem?
 
stephanie said:
Well thanks for your help, sorry about "coping an attitude" before I was
already a little flustrated with the problem and just wanted to find a
solution to it, not discuss how it would be implimented.

No problem,..I'm sure I've been oversensitive to that somewhat
lately,..maybe it is a full moon or time ot the year,..I just hope I don't
start "molting" or "flying north" or something.
Anyway this is the
exact line (as of right now):
route -p add 10.30.0.0 mask 255.255.0.0 10.111.6.1
I didn't originally think the exact IPs would be of any help...but there it
is just in case. And the IP at the PC I'm working on is 10.111.40.55, does
any of this sound like a problem?

It looks fine. Pick one machine as a "victem" and do these steps and see
what we get.

1. Make sure all the normal network TCP/IP settings are correct.
2. Open a command prompt and type "Route -f" to clear the route table, then
reboot the machine. The route table will rebuild "clean".
3. Now manually run the batch file

What happens?
 
Tried it on a test pc and it worked. The batch file ran as expected(no
looping) the route was added as a persistant route. ( I did also chage the
name of the batch file and ran it from a network drive instead of the
desktop.) I'll need to make sure I'm not lossing anything important by
clearing the table, but I think we have a winner, at least I should be able
to work the rest out from here.
Thanks again for all your time.
 
stephanie said:
Tried it on a test pc and it worked. The batch file ran as expected(no
looping) the route was added as a persistant route. ( I did also chage the
name of the batch file and ran it from a network drive instead of the
desktop.) I'll need to make sure I'm not lossing anything important by
clearing the table, but I think we have a winner, at least I should be able
to work the rest out from here.
Thanks again for all your time.

No problem! Good luck!
 
OK,
So #1 how can you tell if the command is running repeatedly?

I assume you are correct...

With 2003 server, I have had to give the GUID pathname to the script if
it runs as part of the policy. I have an internet cafe and I have a
login batch file that touches a web site at login and at logout. This
way I can have the staff just look at a web page to get total login
time.

I tried for several days to "just" use the file and a "path", nothing.
Then I changed to the complete GUID for the file and shazaam! It
worked. Very frustrating.

The other thing is to NEVER assume that "route" is wheare you think. If
someone replaces route with another application in your path variable
you could be subject to a hack. I suggest using explicit paths for
these, or use the system variables for the path.

The other thing that affects these kinds of issues is the context that
the batch file runs in is different that when your logged in and
clicking on it.

Hope this helps, just trying to pay it forward!

Geoff
 
If anyone else has this issue, naming your file route.bat is a bad idea when using the route command!

Change your filename, or use the full route.exe path.
 
Back
Top