Solved

how to close cirtain ports

Posted on 1998-04-13
1
196 Views
Last Modified: 2013-12-15
I would like to set  up an www server with Linux Red 5.0

How do I close every other ports othan port80?

Would you please give specific instructions?

Thanks.

(Some people even put ugly messages if a port is telneted. That's great, too)
0
Comment
Question by:yjh123
1 Comment
 
LVL 1

Accepted Solution

by:
mzito earned 50 total points
ID: 1631557
All, the miracles of tcp wrappers and ipfwadm.  Here's the quick and dirty way (assuming your kernel is compiled to include firewalling support):
ipfwadm -If (flushes out the old rules)
ipfwadm -Ip deny (sets a default policy that incoming packets are denied)
ipfwadm -Ia accept -S 0.0.0.0/0 -D aaa.bbb.ccc.ddd/32 80 (where aaa.bbb.ccc.ddd is your ip address. This allows packets into your system on port 80)
ipfwadm -Ia accept -S 0.0.0.0/0 -D aaa.bbb.ccc.ddd/32 1025:* (this makes sure your system can accept packets on what are known as non-privileged ports....ports that nothing important is on, for when you ftp, surf the web, or send email)
ipfwadm -Ia deny -S 0.0.0.0/0 -D 0.0.0.0/0 -o (this is called a catch-all rule.  Any packets that don't match the above two rules (i.e. unless they are sent to port 80 or some port above 1024) are denied anyway, but this time, they get logged to a file, so you can see what exactly someone tried to do.

If you want to get more creative, you can  use tcp_wrappers.  It's too much to go into in great detail here, but in an example, you might put the following in your hosts.deny file:
in.telnetd:ALL: banners /etc/banners
In the directory /etc/banners, create a file called in.telnetd.  In that file, put whatever you want to be displayed on the person's screen.  This can be done for any service on the machine.  Try "man 5 hosts_access" and "man 5 hosts_options".  I personally use a shell script I modified that, whenever someone tries to access an unauthorized service, gets as much information about the attacker as possible then mails me.  If the attacker  exceeds a set number of times, all packets from their IP are rejected.  If you'd  like it, drop me a line at mzito@wwprsd.mercernet.net

Best Wishes,
Matt Zito
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question