LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 03-31-2009, 01:32 PM   #1
gazza1z
Member
 
Registered: Sep 2008
Posts: 30

Rep: Reputation: 15
How do you open and close ports in LFS


System : BLFS svn-20090124
Kernel : 2.6.27.4

I would like to open a port, use it, close it then run nmap to make sure it is closed. In Windows it seems straight forward enough but I have no idea how to do it in Linux.

Thanks.
 
Old 03-31-2009, 01:53 PM   #2
reptiler
Member
 
Registered: Mar 2009
Location: Hong Kong
Distribution: Fedora
Posts: 184

Rep: Reputation: 42
If you have no clue then probably everything is "open", although really open of course requires a service listening on the port. Thus "open" here refers to unfiltered.
In order to close a port stop the service listening on it.
In order to filter a port and thus make it appear closed use iptables.
 
Old 04-01-2009, 03:39 PM   #3
gazza1z
Member
 
Registered: Sep 2008
Posts: 30

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by reptiler View Post
If you have no clue then probably everything is "open", although really open of course requires a service listening on the port. Thus "open" here refers to unfiltered.
In order to close a port stop the service listening on it.
In order to filter a port and thus make it appear closed use iptables.
I have haven't got a service running yet, I was just asking how to open and close ports. Is it really that difficult as I have been reading up on iptables and it makes absolutely no sense to me whatsoever.

What I need to know is if I run the mysql daemon will that automatically open a port (3306 I think it uses) and will it shut it down when I stop the daemon running and if it doesn't can I shut it down myself?
 
Old 04-01-2009, 10:28 PM   #4
reptiler
Member
 
Registered: Mar 2009
Location: Hong Kong
Distribution: Fedora
Posts: 184

Rep: Reputation: 42
As said, a port is closed if no service is listening on it.
That means that 3306 is closed as long MySQL is not started (okay, something else might use the port, it's unlikely though).

A service handles it's port itself, you don't need to specifically open and close ports.

What you may need to do is filtering and "unfiltering" ports, which is done through IPTables, which is a packet-filter (to express it slightly simplified).
If IPTables is set to filter 3306 then, even after MySQL has started listening on that port, and thus the port being technically open, it will appear closed due to IPTables rejecting connection to the port.
 
Old 04-02-2009, 01:28 PM   #5
gazza1z
Member
 
Registered: Sep 2008
Posts: 30

Original Poster
Rep: Reputation: 15
Ok, Thanks for you help. I'll just have to try to understand how iptables work.
 
Old 04-02-2009, 02:06 PM   #6
reptiler
Member
 
Registered: Mar 2009
Location: Hong Kong
Distribution: Fedora
Posts: 184

Rep: Reputation: 42
There's a great tutorial over here.
 
Old 04-03-2009, 01:37 PM   #7
gazza1z
Member
 
Registered: Sep 2008
Posts: 30

Original Poster
Rep: Reputation: 15
Thanks again. Much appreciated
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
open ports for utorrent using iptables n close smpt to that ports shtorrent00 Linux - Networking 2 09-30-2008 04:34 PM
Want to close open ports shan_nathan Linux - Security 2 09-29-2007 03:21 PM
How do i close my open ports??? Synth218 Slackware 10 07-06-2003 03:31 PM
open ports... how do i close them? prodigius Linux - Security 3 01-18-2002 09:35 AM
how to close open ports zyan Linux - Security 3 08-04-2001 09:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 07:57 PM.

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