Scripts and IP subnets.

Posted on 2003-03-18
Medium Priority
Last Modified: 2010-04-13
Is there any way of preventing login scripts from running when logging in from a specific IP subnet...??

I have location A & B. These locations are connected using VPN- tunnels.
When a user from location A takes a visit to location B with his laptop and logs in, the login script excecutes with a result in talking up all the bandwidth, because of antivrus updates and etc.

Can this be prevented?

Thx in advance..

Question by:Rubeck
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Accepted Solution

YarnoSG earned 375 total points
ID: 8159791
assuming NT/2000, your login script can include a check for the machine's own IP:

here is a script I wrote that puts the IP octets into individual variables, which you can then do whatever you want with;  it employs three different techniqes depending on your situation (one is active and two are commented out)

It is fully commented;  I wrote it while teaching a DOS class.

:: IpToVar.CMD
:: by Steven Yarnot
:: Last Modified 11/28/2001 Cleaned Up Code (redundant If Statements removed)
:: Batch for seting the individual octets of an Ip to variables;
:: Most helpful in environments with subnet mask  
:: for quickly retrieving subnet
:: Usage:  IpToVar TargetNode
:: Sets variables:     Oct1     first octet
::               Oct2     second octet          
::               Oct3     third octet
::               Oct4     fourth octet
:: works on NT and Win2000.
:: Three approaches to same problem:  one uses IPCONFIG, another NSLOOKUP and the Third
:: ping.  Ipconfig will be quicker if you are querying the local PC, and the Ping and NSLOOKUP approaches
:: can be used for remote pcs;  The ping approach can also identify Live clients

:: More Comments Added 11/28/2001 after walking my DOS class through this:
:: For Statment executes a single packet ping;  if successful, third line of response will contain
:: "Reply" in the %i variable.  This will make the IF statement valid.  the first Set will then execute
:: with %k as the data (first octet of IP), followed in succession by the remaining 3 octets.   Because
:: the "&&" is used, they will only be executed if the IF statement is successful.

@echo off

:: Set the OCT variables to a default value first if you are using this in a script;  with failed pings,
:: the OCT variables will not be set and so therefore would be what they were the last time unless you
:: give them a default.

set Oct1=off& Set Oct2=off& set Oct3=off& set Oct4=off

:: The Ping approach 1:

for /f "tokens=1,2,3,4,5,6 delims=:,. "  %%i in ('ping %1 -n 1') do if "%%i"=="Reply" set Oct1=%%k && set Oct2=%%l && set Oct3=%%m && set Oct4=%%n

:: The Ping approach 2: (DOES NOT DETERMINE IF OFF OR ON)

:: for /f "tokens=1,2,3,4,5,6,7,8,9 delims=[]:,. "  %%i in ('ping %1 -n 1') do if "%%i"=="Pinging" set Oct1=%%n && set Oct2=%%o && set Oct3=%%p && set Oct4=%%q

:: The nslookup approach:

:: for /f "tokens=1,2,3,4,5,6 delims=:,. "  %%i in ('nslookup %1') do if "%%i"=="Address" set Oct1=%%k && set Oct2=%%l && set Oct3=%%m && set Oct4=%%n

:: The IpConfig approach:
:: note there are tabs imbedded in the if statements;  edit with caution.

::for /f "tokens=1,2,3,4,5,6 delims=:,. "  %%i in ('ipconfig') do if "%%i"=="     IP" set Oct1=%%k && set Oct2=%%l && set Oct3=%%m && set Oct4=%%n

::Echo %1 %Oct1%  %Oct2%  %Oct3%  %Oct4% >> P:\iptovar.txt
:: Output to a A CSV by Subnet (assumes Subnet Mask)
echo %oct3%,%1,SMSServerName,LOC >> p:\PinglistSubn.CSV

once you have the octets in the variables, you can manipulate them with IF statements in a login script.

-Steven Yarnot

Expert Comment

ID: 8159803
Oh, and as to your problem;  you could have a "short and sweet" login script run by everybody, (this script is really only one line, with oodles and gobs of comments), and then branch to either the REAL login script or EXIT.


Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question