Test multiple IP:Port servers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Test multiple IP:Port servers
# 1  
Old 03-30-2017
Wrench Test multiple IP:Port servers

Hello,

I am pretty unskilled in bash and I need some script and my skills ale limited (yet) I am learning but situation now needs some more skills.

is there possibility to simply check IP address with ports from csv file?

My csv has hundred of IPs in this format

Code:
123.123.321.321:80,22,443
223.223.321.321:80,22,443

Is there possibility to check IPs in this order and format via bash script to make it automatic?

Can shell script take care of commas in that csv? In best way I want that telnet test output in some tetxt file with format
Code:
IP:PORT - FAIL/OK

.. is that possible?

Thank you alot in advance
# 2  
Old 03-30-2017
How about
Code:
awk -F: '{for (i=split ($2, T, ","); i>0; i--) print "nc -zv ", $1, T[i]}' file | sh
nc: connect to 10.1.1.11 port 80 (tcp) failed: Connection refused
Connection to 10.1.1.11 22 port [tcp/ssh] succeeded!
nc: connect to 10.1.1.11 port 21 (tcp) failed: Connection refused

# 3  
Old 03-30-2017
Quote:
Originally Posted by RudiC
How about
Code:
awk -F: '{for (i=split ($2, T, ","); i>0; i--) print "nc -zv ", $1, T[i]}' file | sh
nc: connect to 10.1.1.11 port 80 (tcp) failed: Connection refused
Connection to 10.1.1.11 22 port [tcp/ssh] succeeded!
nc: connect to 10.1.1.11 port 21 (tcp) failed: Connection refused

I copied youd script and it gives me
Code:
111.222.333.444.555: inverse host lookup failed: Host name lookup failure 
(UNKNOW)  [111.222.333.444.555] 22 (ssh) open

I don't understand to that Inverse host lookup failed..
# 4  
Old 03-30-2017
With that IP address I understand that message well. It has several errors. Use well structured IP addresses only.
# 5  
Old 03-30-2017
Quote:
Originally Posted by RudiC
With that IP address I understand that message well. It has several errors. Use well structured IP addresses only.
Thats just example I wont expose my IPs publicly :-) This error was on normal IP address.
# 6  
Old 03-30-2017
DNS resolution seems to fail, which may well be if we're dealing with e.g. an unregistered host on the LAN. Other reasons are possible as well. Still, that looks like an informative message; the test itself seems to have worked...
# 7  
Old 03-30-2017
Quote:
Originally Posted by RudiC
DNS resolution seems to fail, which may well be if we're dealing with e.g. an unregistered host on the LAN. Other reasons are possible as well. Still, that looks like an informative message; the test itself seems to have worked...
Yes, the main functions works, thank you alot .. :-)

And can I setup output like
Code:
awk -F: '{for (i=split ($2, T, ","); i>0; i--) print "nc -zv ", $1, T[i]}' file | sh > output.txt

?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to apply the update statement in multiple servers on multiple dbs at a time .?

Hi , Can any please help the below requirement on all multiple servers and multiple dbs. update configuration set value='yes' ;1) the above statement apply on 31 Databases at a time on different Ip address eg : 10.104.1.12 (unix ip address ) the above ip box contains 4 db's eg : db... (2 Replies)
Discussion started by: venkat918
2 Replies

2. UNIX for Dummies Questions & Answers

Test connectivity to IP/port

I want to test the connectivity to an IP with Port number = xxxx. I only know telnet can do it. For example, telnet <IP> <port>. But I don't have telnet installed (no package) on my Red Hat Linux server. I searched the Internet and realized that I will need either the installation media which... (2 Replies)
Discussion started by: learnix
2 Replies

3. UNIX for Dummies Questions & Answers

Shell Script to test telnet connection using port

Hello, I need to test telnet connections using port number for few hosts. Could you please help me? Thanks !! (1 Reply)
Discussion started by: skhichi
1 Replies

4. Programming

Using socket to test a TCP port

Hello, I'm trying to write a small c application to test a tcp port. This works fine for the most part but the default timeout on the connect is very long. I have been reading many posts but and it looks like I need to set the socket to be non-blocking and poll for a result. I have been totally... (2 Replies)
Discussion started by: tjones1105
2 Replies

5. UNIX for Dummies Questions & Answers

Refurbished Netra 240 servers hangs after POST test

Hello everyone, I'm extremely new when it comes to SUN servers so bear with me and hopefully I can describe the issue I have accurately. At work we just received a refurbished SUN Netra 240 server. I was told to change some of the EEprom settings, and to do that I was to use a... (0 Replies)
Discussion started by: afferbwt
0 Replies

6. Solaris

How i test the UDP port is working?

Hi anybody know how to test out the UDP port working? cos UDP cannot use telnet to test... Sumemr (2 Replies)
Discussion started by: summerpeh
2 Replies

7. Shell Programming and Scripting

rsh to change multiple ip in multiple servers?

good day. i jsut wanted to know what is the best script or the best way changing a lot of Ip's in all servers. Do you have any idea? im using awk to change IP,what if, you have lots of servers. You need to change it one by one? It will take time to change it manually. (2 Replies)
Discussion started by: kenshinhimura
2 Replies

8. Shell Programming and Scripting

Telnet script to test open ports on mult servers

Hello All, Can somebody help me with this script. I have an output file with a list of servers ips and ports. I need to be able to run this script to list all the server ips in the outfile and find out if the port is open or not. #!/bin/sh IFS=#;for i in $(cat portTest); do # check... (2 Replies)
Discussion started by: liketheshell
2 Replies

9. Shell Programming and Scripting

ftp to multiple servers

Hi folks. I am writing a ksh ftp script. The problem is, I need to transfer the files to several different servers. Is there a way to close a connection and move on to the next in one script or do I need to write a separate script for each one? Thanks, kristy (2 Replies)
Discussion started by: kristy
2 Replies
Login or Register to Ask a Question