Quantcast
Channel: Java mon amour
Viewing all articles
Browse latest Browse all 1121

Poor man's firewall test

$
0
0
on the Destination host:

nc -l myhost.acme.com 3872

and make sure you are actually listening:

netstat -an | grep 3872
tcp        0      0 10.33.80.121:3872           0.0.0.0:*                   LISTEN

On the Source host:

echo ciao | nc myhost.acme.com 3872

and the "ciao" should appear on Destination and the nc should exit.

If you don't have nc installed, there are alternatives to nc:

wlst or python:

import socket
HOST = 'myhost.acme.com'
PORT = 3872
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT)) 
s.send('Hello, world')
data = s.recv(1024)
s.close()
 
 
(see http://docs.python.org/release/2.5.2/lib/socket-example.html)
 
 
or simply  run
telnet myhost.acme.com 3872
 
 
To receive data, run Java or python:
 
from java.net import ServerSocket
ss = ServerSocket(3872)
ss.accept()


(see http://docs.oracle.com/javase/6/docs/api/java/net/ServerSocket.html )


Viewing all articles
Browse latest Browse all 1121

Trending Articles