block a network port

A

abcd

any ideas on how to block a network port from being used, or one that
is currently in use? For example, say I want to block port 23 from
being used. by used, I mean allowing connections to or from it.

thanks in advance.
 
L

Larry Bates

abcd said:
any ideas on how to block a network port from being used, or one that
is currently in use? For example, say I want to block port 23 from
being used. by used, I mean allowing connections to or from it.

thanks in advance.
This is not really a Python question. Blocking ports is a function
of your firewall solution.

-Larry Bates
 
A

abcd

Larry said:
This is not really a Python question. Blocking ports is a function
of your firewall solution.


ok, no of any python solutions? or command-line firewalls?
 
A

alex23

abcd said:
ok, no of any python solutions? or command-line firewalls?

You did try searching Google for "python firewall", right?

http://www.google.com.au/search?q=python+firewall

The very first entry is a pointer to a solution for Windows.

You really need to provide more information if you want more detailed
advice, like what operating environment you're working with. You should
find something in the search results to help you, though.

-alex23
 
B

Butternut Squash

abcd said:
ok, no of any python solutions? or command-line firewalls?

So now you're question is how to write a firewall in python?

You can probably bind to all the ports and not open up any connections. That
would keep something else from using the port. Simple but effective.

Firewall software is a much better solution, though

Good luck.
 
T

Tim Williams

You did try searching Google for "python firewall", right?

http://www.google.com.au/search?q=python+firewall

The very first entry is a pointer to a solution for Windows.

That first entry was my thread :)

IPFW is stable and runs as a Windows service, the rules can be
added/deleted/changed/viewed in real-time making it a good candidate
for pairing with Python.

I have used it to write servers that temporarily firewall themselves
against dubious connections.

My preferred method is something like

def ip_fw(fwcmd): #
try:
i,o,e = win32pipe.popen3('C:\\ipfw\\bin\\ipfw '+fwcmd)
return i,o,e
except:
print sys.exc_info()[0]

Nowadays I might use something other than popen3 depending on the
level of return status I needed.

(from memory, not tested, and not the best Python code )

HTH :)
 

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