LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-08-2005, 01:36 AM   #1
kruemel
LQ Newbie
 
Registered: Dec 2005
Posts: 2

Rep: Reputation: 0
Question How to open/close ports in a shell prog ?


Hi !

I want to open and close tcp/ip ports in a shell program !


Who can help me !?

Joern
 
Old 12-08-2005, 06:06 PM   #2
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
What do you mean? Do you want to configure a firewall like iptables or do you just want to set up a listener and kill it at will?


Håkan
 
Old 12-09-2005, 12:13 AM   #3
kruemel
LQ Newbie
 
Registered: Dec 2005
Posts: 2

Original Poster
Rep: Reputation: 0
Hi !

Yes ! I want to open and close on Port at free will !

No Firewall or something !

Its for monitoring !

Joern
 
Old 12-09-2005, 03:14 AM   #4
hw-tph
Senior Member
 
Registered: Sep 2003
Location: Sweden
Distribution: Debian
Posts: 3,032

Rep: Reputation: 58
Try netcat.
Code:
nc -l -p [localport] -e [program]
The above will start listening on the specified local TCP port and when an incoming connection is made on that port the program of your choice is executed (try /bin/bash for a shell). Note that this is suicide security wise. Oh, and since this is Linux you cannot listen on privileged ports without being root. And listening like in the above command, as root, will only result in you being completely rooted and your machine turned into a SPAM relay and/or server for spreading pirated pr0n.

Håkan
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I close open ports ??? apache Linux - Security 2 07-20-2004 07:44 PM
Which ports should I keep open and which close?? apache Linux - Security 3 07-19-2004 08:31 AM
how to close open ports mayagenesis Linux - Networking 1 07-31-2003 12:47 AM
How do i close my open ports??? Synth218 Slackware 10 07-06-2003 02:31 PM
open ports... how do i close them? prodigius Linux - Security 3 01-18-2002 08:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 06:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration