LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-10-2004, 04:17 AM   #1
KiLLaWaBBiT
Member
 
Registered: Mar 2003
Location: UK
Distribution: Slackware 10.2, Kernel 2.6.13
Posts: 69

Rep: Reputation: 15
Closing Ports


Could anyone please tell me how to close ports manually, having a nightmare here! Many thanx for any replies.
 
Old 12-10-2004, 04:43 AM   #2
syl20
Member
 
Registered: Aug 2003
Posts: 65

Rep: Reputation: Disabled
Hi KiLLaWaBBiT
to close port, turn off daemon using ports you want to close.
To close port 25, turn off smtpd.
 
Old 12-10-2004, 05:14 AM   #3
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Also open /etc/inetd.conf (or /etc/xinetd.conf) and comment out all the services you don't need. Then restart inetd (or xinetd)
 
Old 12-10-2004, 09:46 PM   #4
sigsegv
Senior Member
 
Registered: Nov 2004
Location: Third rock from the Sun
Distribution: NetBSD-2, FreeBSD-5.4, OpenBSD-3.[67], RHEL[34], OSX 10.4.1
Posts: 1,197

Rep: Reputation: 47
iptables -I INPUT -j DROP would do it nicely. Note that this will close *all* ports though.
 
Old 12-10-2004, 11:23 PM   #5
sh1ft
Member
 
Registered: Feb 2004
Location: Ottawa, Ontario, Can
Distribution: Slackware, ubuntu
Posts: 391

Rep: Reputation: 32
To close a specific port you could do:

Code:
iptables -A INPUT -p tcp -dport 21 -j DROP
For example. Use the man pages to see what this means, the ones for iptables are surprisingly good.
 
Old 12-17-2004, 08:07 PM   #6
cormander
Member
 
Registered: Dec 2004
Location: Hawaii
Distribution: Fedora & CentOS
Posts: 72

Rep: Reputation: 15
Quote:
Originally posted by sigsegv
iptables -I INPUT -j DROP would do it nicely. Note that this will close *all* ports though.
It is generally a good idea to do this at the bottom of your iptables firewall script. This is called a "deny-by-default" policy.

Make sure you open all the desired ports before this entry:

Code:
 iptables -A INPUT -p tcp -dport 21 -j ACCEPT
etc

-Corey
 
Old 12-17-2004, 08:53 PM   #7
sigsegv
Senior Member
 
Registered: Nov 2004
Location: Third rock from the Sun
Distribution: NetBSD-2, FreeBSD-5.4, OpenBSD-3.[67], RHEL[34], OSX 10.4.1
Posts: 1,197

Rep: Reputation: 47
In the interest of accuracy, it's a rule that DENYs all packets on INPUT that cross it. The default policy is something else entirely, and a "deny by default" policy would be accomplished like so:

Code:
# Flush old rules
iptables -F
iptables -t nat -F
iptables -t mangle -F

# Set default action (policy)
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

# Put rules to do something useful here
 
  


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
Closing ports??? NCC-1701&NCC-1701-D Linux - Security 6 05-29-2005 09:23 AM
Closing these ports... greygoose80 Slackware 2 12-19-2004 11:12 PM
Closing Some Ports wonderpun Linux - Security 8 08-17-2003 03:09 PM
closing ports im1crazyassmofo Linux - Security 2 01-02-2003 09:50 PM
CLOSING PORTS Stephanie Linux - Security 9 05-23-2001 12:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 02:33 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