Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I work at a datacenter and work on servers in various global locations. We have about 10 proxy servers and no good way to know which proxy server to use on which server/domain/vlan ect... Don't ask why as I have and have been told "go ask security". Anyhow I wanted to use a batch script to telnet to each proxy server on port 8080. I have the proxy server's IP addresses and know they're listening on 8080. How could I from a script check one by one and come back with a response?

Hope this makes sense. At this time I have to go into internet settings -> connection -> proxies and try one by one. And these are windows 03 & 08 servers.

Any help is greatly appreciated!

To clarify. I'm looking for a script that will go through a list of known proxies and ports and verify connectivity.

Got the following error with the powershell script enter image description here

share|improve this question
    
I don't understand what it is that you're actually asking. –  joeqwerty Jan 23 '11 at 4:24
    
see my update in bold –  shaiss Jan 23 '11 at 4:29
    
Gotcha. Thanks for the clarification. –  joeqwerty Jan 23 '11 at 4:35

2 Answers 2

up vote 3 down vote accepted

I would use some other command line tool like wget instead. These will be much more easily batched. wget is not designed to make requests directly to proxies, but you'll still get a response from the proxy (probably a 502 or something) which is all you need given your requirements.

wget myproxy1:8080
wget myproxy2:8080
wget myproxy3:8080
...

You'll get some kind of HTTP response out of the ones that are responding and a connection timeout for the ones that aren't.

EDIT:
Here's something using Powershell:

$proxyArray = @("proxy1.mynet.com:8080","proxy2.mynet.com:8080")
foreach ($proxy in $proxyArray) {
  $httpRequest = [System.Net.WebRequest]::Create("http://www.google.com")
  $httpRequest.Proxy = new-object -typename System.Net.WebProxy -argumentlist $proxy
  $httpRequest.GetResponse()
}

Using that you'll get some kind of HTTP response out of the proxies that are listening, a connection timeout, or host not found / name resolution error.

share|improve this answer
    
I can't use wget as they are win servers and I cannot install unauthorized software –  shaiss Jan 23 '11 at 4:42
    
Try telnet then. –  joeqwerty Jan 23 '11 at 4:50
2  
you'd not be running wget on the servers, you'd be running it on a client system. –  Journeyman Geek Jan 23 '11 at 4:59
    
I got an error with the powershell script. I just copied and pasted your code, filled in my proxies. Am I missing an Import-Module command or something else? –  shaiss Jan 26 '11 at 13:27
    
@shaiss What's the error you're getting? –  squillman Jan 26 '11 at 14:10

Configure proxy.pac on your clients. Look at this link will explain how to set it up. http://en.wikipedia.org/wiki/Proxy_auto-config

HTH

share|improve this answer
    
A client will not loop through all of the proxies in the return list. If the first proxy in the return list answers then the browser uses that one and ignores the rest. –  squillman Jan 23 '11 at 14:34
    
Different clients in our network have access to different proxies. That's why I need a simple script or a portable app. –  shaiss Jan 27 '11 at 19:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.