block a network port

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • abcd

    #1

    block a network port

    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.

  • Larry Bates

    #2
    Re: block a network port

    abcd wrote:
    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

    Comment

    • abcd

      #3
      Re: block a network port

      Larry Bates wrote:
      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?

      Comment

      • alex23

        #4
        Re: block a network port

        abcd wrote:
        ok, no of any python solutions? or command-line firewalls?
        You did try searching Google for "python firewall", right?



        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

        Comment

        • Butternut Squash

          #5
          Re: block a network port

          abcd wrote:
          Larry Bates wrote:
          >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?
          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.

          Comment

          • Tim Williams

            #6
            Re: block a network port

            On 29 Aug 2006 20:43:49 -0700, alex23 <wuwei23@gmail. comwrote:
            abcd wrote:
            ok, no of any python solutions? or command-line firewalls?
            >
            You did try searching Google for "python firewall", right?
            >

            >
            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.popen 3('C:\\ipfw\\bi n\\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 :)

            Comment

            Working...