TELNET instead PING

D

DCK

Hello :)

Into group-archive i found most e-mails, which touches PINGing.
In my work i've used TELNET for testing if host is operational.
Sometimes, for unknown reasons, workstation doesn't respond
for PINGing. But in WinNT network, all hosts has a nbsession
listening on port 139. I always use this script instead PING
command (hope, will be usefull for someone :) ):



"""
TelPing.py
- Simple Python script to probe workstation in WinNT Network

(c) 2004 Michal Kaczor (26.01.2004)
(e-mail address removed)
"""

import telnetlib
import sys


def tel_ping(tn_host,tn_port):
try:
tn = telnetlib.Telnet(tn_host,tn_port)
print 'Host:',tn_host,' Port:',tn_port,' <-- CONNECTED'
tn.close()
except:
print 'Host:',tn_host,' Port:',tn_port,' <-- Error: NO CONNECTION'


def main():
if (len(sys.argv)==3):
tel_ping(sys.argv[1],sys.argv[2])
else:
print 'Usage: telping.py <host> <port>'

if __name__ == "__main__":
main()
 
S

Serge A. Ribalchenko

DCK said:
Hello :)

Into group-archive i found most e-mails, which touches PINGing.
In my work i've used TELNET for testing if host is operational.
Sometimes, for unknown reasons, workstation doesn't respond
for PINGing. But in WinNT network, all hosts has a nbsession
listening on port 139. I always use this script instead PING
command (hope, will be usefull for someone :) ):

thanks a lot.
Can you do the same using ARP who-has request ? :)
 
P

Peter Hansen

DCK said:
Into group-archive i found most e-mails, which touches PINGing.
In my work i've used TELNET for testing if host is operational.
Sometimes, for unknown reasons, workstation doesn't respond
for PINGing. But in WinNT network, all hosts has a nbsession
listening on port 139. I always use this script instead PING
command (hope, will be usefull for someone :) ):

Interesting, but why would you use TELNET for that? Telnet is
simply one of many possible protocols, whereas you need only
open a socket to the port to see if the host is responding.

from socket import *
s = socket(AF_INET, SOCK_STREAM)
try:
s.connect((host, port))
print 'host connected'
s.close()
except error:
print 'host not responding'

Should basically do the same job ...

-Peter
 
G

Gandalf

Peter said:
DCK wrote:



Interesting, but why would you use TELNET for that? Telnet is
simply one of many possible protocols, whereas you need only
open a socket to the port to see if the host is responding.
Exactly. All you need is an open port you can check.

Note: that reason you talked about is most likely a packet filtering
firewall. A good firewall
can block PING, Telnet, Nbsession and many others. In most cases, the
best policy
is to lock everything by default and permit only the ones you really
want. Firewall
rules can include source addresses too. It is possible that a computer
do not respond
on PING and TELNET ports for you but it does for a similar request from
another
computer. I think there is no universal way to determine if a remote
host is alive or not.
 
P

Peter Hansen

Gandalf said:
I think there is no universal way to determine if a remote host is alive or not.

That is definitely the case, because of course the firewall could just as
easily block all traffic that is not from a specific IP address as well.

-Peter
 
S

Serge A. Ribalchenko

Gandalf wrote:

Note: that reason you talked about is most likely a packet filtering
firewall. A good firewall
can block PING, Telnet, Nbsession and many others. In most cases, the
best policy
is to lock everything by default and permit only the ones you really
want. Firewall
rules can include source addresses too. It is possible that a computer
do not respond
on PING and TELNET ports for you but it does for a similar request from
another
computer. I think there is no universal way to determine if a remote
host is alive or not.

If we are talking about IP network segment in the same ethernet layer,
can you ignore my ARP request - who-has <your-ip> ?
 
G

Gandalf

If we are talking about IP network segment in the same ethernet layer,
can you ignore my ARP request - who-has <your-ip> ?
Probably I cannot. :)
But this applies only when you are in the same segment.
By the way, is it possible to send an ARP request from pure Python? ;-)
AFAIK Python provides tools for level 3 and above only.
 
D

DCK

Peter said:
Interesting, but why would you use TELNET for that? Telnet is
simply one of many possible protocols, whereas you need only
open a socket to the port to see if the host is responding.
I was on some kind of Network course, where teacher said, that telnet
is better then PING. In my work i found this usefull for pinging
network. When i meet with Python, i foud TELNETLIB module and write
simply scheduled script which probe network.
from socket import *
s = socket(AF_INET, SOCK_STREAM)
try:
s.connect((host, port))
print 'host connected'
s.close()
except error:
print 'host not responding'

THX for this advice. In future i will read manual carefully :)

Greetz
Michal DCK Kaczor
 
K

Kirk Strauser

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

DCK said:
I was on some kind of Network course, where teacher said, that telnet is
better then PING.

Your teacher was on crack. That's like saying that "table lamps are better
than pencil cups". :)
- --
Kirk Strauser
The Strauser Group
Open. Solutions. Simple.
http://www.strausergroup.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)

iD8DBQFAFn/T5sRg+Y0CpvERAq0UAJ9WhPxMY1Um93QwcOLqGHy+0KlcQgCeJbdW
4o7kvcO5ryEZ8HrSwDy7o9c=
=kPeN
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top