Solved

how to close cirtain ports

Posted on 1998-04-13
1
193 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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.

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now