Check telnet port multiple server

Dear Team,

I want to check multiple linux server to check port open.
eg. 192.168.1.12 80 , 192.168.1.12 443

Please provide script for that?

@pradeep1807

unix.com is not a script writing service.

You should write your script and post and then our members will help you.

However, you must do your own work.

1 Like

Have you considered the nmap tool?

1 Like

Or nc ( netcat )?

1 Like

you realy should have a lock on nmap

nmap -p 443 192.168.1.0/24

1 Like

Hello Pradeep,
I have googled and found some python codes doing this task.
You might do the same but seems like unethical.

Kind regards
Boris

1 Like

Unethical? Well, using those IP addresses, I would assume that this is an unroutable segment of your network (perhaps a private or management segment) rather than a public address. Using scanning tools such as have been mentioned on the public internet is probably unethical and might get your connection blocked by your service provider too. The tools can be used to look for weaknesses on the public internet so everyone is very wary of them and providers are quite hot on keeping their customers clean else other providers may block them out too.

Probing your own devices to see what ports are open, filtered or closed seems a valid thing to do, but don't go mad on it.

Kind regards,
Robin

1 Like

Everyone should scan their own IT network and devices from time to time for IT security reasons.

Everyone should to backups their own IT network and devices often for IT security reasons.

Everyone should keep their system and apps updated to the latest software versions as soon as they reasonably can for IT security reasons.

Fun mode: ON

Hey you can even write your portscanner in plain bash :wink:

See here:
TCP Port Scanner in Bash

for short(GNU coreutils(for "timeout") needed or a perl script if coreutils are not available):

for port in 80 443 12345; do 
  timeout 3 echo >/dev/tcp/google.com/$port &&     
  echo "port $port is open" ||     
  echo "port $port is closed" 
 done  

Hmm. Doesn't work as expected :frowning: ...

This one works :slight_smile: ...

for port in 80 443 12345; do 
  timeout 3 bash -c "echo >/dev/tcp/google.com/$port" &&     
  echo "port $port is open" ||     
  echo "port $port is closed" 
done