Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Setting Restriction of Access to Linux

Posted on 2002-04-03
10
Medium Priority
?
466 Views
Last Modified: 2013-12-16
I'm thinking to restrict acess to Linux
eg. accessing via Telnet..
How could I set the Linux in order to restrict certains ports?
0
Comment
Question by:usher
10 Comments
 
LVL 4

Expert Comment

by:MFCRich
ID: 6917938
This would depend on what criteria you are going to use to decide what is allowed and what isn't.

If you want to restrict which machines can telnet to your Linux box, inetd/xinetd can be configured to handle this or you could use firewall rules.
0
 

Author Comment

by:usher
ID: 6921170
I could not find inetd, instead, I can find xinedt.d folder
which contains several files. One of which is telnet conf file. Is this the one I need to change in order to stop this service?
0
 
LVL 1

Accepted Solution

by:
MindBender earned 200 total points
ID: 6922585
usher, You might find this easy to do with only editing
the hosts.deny and hosts.allow files.
___________________________
Typically you should have your hosts.deny set as:
ALL: ALL

___________________________
Your hosts.allow you can add the ip of the machines that you want to allow to connect to your Linux box.

ALL: 192.168.1.24
___________________________

MindBender
0
Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

 

Expert Comment

by:narayanamoorthy
ID: 6941782
You can restrict assessing your machine by two ways.

1. As said by MindBender.  This is possible only if you are using TCP wrappers.

2. By filtering (using ipchains or iptables according to your kernel).

If the telnet conf file in ur xinetd.d contains a line like /usr/sbin/tcpd in.telnetd, then u had TCP wrappers installed and the method of MindBender is absolutely right to allocate telnet only to 192.168.1.24 machine.

If you don't had TCP wrappers, then ipchains/iptables can be used.

Suppose you want to permit only 192.168.1.24 to telnet into the server.

/sbin/ipchains -A input -s ! 192.168.1.24 --destination-port 21 -j DENY

or

/sbin/ipchains -t filter -A INPUT -s ! 192.168.1.24 -p tcp --destination-port 21 -j DENY
I think this will solve ur problem

Moorthy
0
 

Expert Comment

by:narayanamoorthy
ID: 6941838
You can restrict assessing your machine by two ways.

1. As said by MindBender.  This is possible only if you are using TCP wrappers.

2. By filtering (using ipchains or iptables according to your kernel).

If the telnet conf file in ur xinetd.d contains a line like /usr/sbin/tcpd in.telnetd, then u had TCP wrappers installed and the method of MindBender is absolutely right to allocate telnet only to 192.168.1.24 machine.

If you don't had TCP wrappers, then ipchains/iptables can be used.

Suppose you want to permit only 192.168.1.24 to telnet into the server.

/sbin/ipchains -A input -s ! 192.168.1.24 --destination-port 21 -j DENY

or

/sbin/ipchains -t filter -A INPUT -s ! 192.168.1.24 -p tcp --destination-port 21 -j DENY
I think this will solve ur problem

Moorthy
0
 
LVL 1

Expert Comment

by:toddrose
ID: 6954103
This is for RedHat using xinetd.

You can use the xinetd.d/telnet file to disable ANY telnet access.  This is mine, notice the "disable = yes" line.  This prevents ANY incoming access on port 23 from starting telnet.  This will NOT prevent you from running the telnet daemon and poosibly allowing access,  this also prevents you from using telnet on your "internal" network for administration (not realy a bad thing if you use ssh instead).

Of course, if you want to use telnet internaly you need to use ipchains or iptables to restrict access to port 23 to allow only internal traffic to reach port 23.


File: telnet            Col 0              303 bytes                        100%
# default: on
# description: The telnet server serves telnet sessions; it uses \
#       unencrypted username/password pairs for authentication.
service telnet
{
        disable = yes
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/in.telnetd
        log_on_failure  += USERID
}


You can edit /etc/sysconfig/ipchains and add the following lines.

-A input -p tcp -s 192.168.10.0/24 -d 192.168.10.0/24 23:23 -y -j ACCEPT
-A input -p udp -s 192.168.10.0/24 -d 192.168.10.0/24 23:23 -j ACCEPT

These ALLOW access to port 23 ONLY when the source and destinations are inside my firewall (really the 192.168.10.x subnet).  You will need to enable the xinetd.d/telnet to use telnet.


Sinc you also asked about ports in general...
The first line DENY's tcp traffic from anywhere TO anywhere.  DENY means that a response is sent back to requestor (means someone now knows a machine is at your IP Address).  the REJECT line stops UDP traffic on ports 0 through 1023 and does NOT send any response, this means a port scanner will not "see" your system.  So for "stealth" type protection, set both to REJECT.

-A input -p tcp -s 0/0 -d 0/0 0:1023 -y -j DENY
-A input -p udp -s 0/0 -d 0/0 0:1023 -j REJECT

The ipchains man pages will give you a much better explanation of all the parameters.

FYI:
port 21 is for FTP.
I DO NOT enable Telnet and only use ssh.

Todd R.
0
 
LVL 3

Expert Comment

by:hnminh
ID: 6974651
Keep your life simple!!! TCP wrapper is xinetd in RedHat, telnet-server, wu-ftpd package is installed to work with xinetd. Follow MindBender instruction! Dont complicate a simple task by using ipchains/iptables, those are for real firewall config.
0
 

Expert Comment

by:CleanupPing
ID: 9077035
usher:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 1

Expert Comment

by:drewber
ID: 9220346
This question has been classified abandoned. I will make a recommendation to the moderators on its resolution in a week or two. I appreciate any comments that would help me to make a recommendation.
 

Unless it is clear to me that the question has been answered I will recommend delete. It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.

 
If the user does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp
 
drewber
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses

926 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