⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcpd.html

📁 Linus guide, Linus guide, Linus guide,
💻 HTML
字号:
<HTML><HEAD>   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">   <META NAME="description" CONTENT="TCP Wrappers">   <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; OpenBSD 2.3 i386) [Netscape]">   <TITLE>TCP Wrappers-Access control for your computer!</TITLE></HEAD><BODY BGCOLOR="#FFFFFF" TEXT="#000000"><CENTER><H2>TCP Wrappers</H2></CENTER><CENTER><H3>Locked doors and a security camera for your computer!</H3></CENTER><HR><FONT SIZE="-1"><B>Last updated: June 19, 1998</B></FONT><BR><FONT SIZE="-1"><B>Development stage: Beta</B></FONT><P>How to install TCP Wrappers to keep the bad guys out and monitor connectionattempts to your computer.<P><B>How does tcp_wrappers work?</B><P>When a user tries to connect to your computer on a port, inetd looksup the port number in /etc/services, when it finds the port number it looksin the file /etc/inetd.conf for a corresponding service and runs the service.With tcp_wrappers inetd is tricked into running tcpd instead of the servicethat would normally be called. Tcpd then checks it's rules in the /etc/hosts.allowand /etc/hosts.deny files. It either accepts the connection and runs theservice or denies the connection based on it's rules.<P><B>Installing TCP Wrappers:</B><BR>It's very possible the TCP Wrapper package is already installed onyour computer. Look in the directory "/usr/sbin" for a file named "tcpd",if it's there you most likely have it installed already and you can proceedto part 4.<P>The following instructions take you step by step through the installationprocess of tcp-wrappers from the source code...YES that's right...the source,no sissy-girl rpm's or deb's ;)<P><B>1: Download the tcp wrappers source code.</B><BR>&nbsp;&nbsp;&nbsp; <I>ftp://ftp.cert.org/pub/tools/tcp_wrappers/tcp_wrappers_7.6.tar.gz</I><P><B>2: Untar-gz&nbsp; tcp_wrappers_7.6.tar.gz</B><BR>&nbsp;&nbsp;&nbsp; <I>tar zxvf&nbsp;&nbsp;&nbsp; tcp_wrappers_7.6.tar.gz&nbsp;</I><P><B>3: Compile and Install the wrappers program.</B><BR><B>&nbsp;&nbsp;&nbsp; </B>Now we will build and install the program.<P>&nbsp;&nbsp;&nbsp; <I>cd tcp_wrappers_7.6</I><BR><I>&nbsp;&nbsp;&nbsp; make REAL_DAEMON_DIR=/usr/sbin linux</I><BR><I>&nbsp;&nbsp;&nbsp; make install&nbsp;&nbsp;&nbsp;&nbsp; </I>&lt;----you'llneed to be logged on as root to run this command !<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; At this point the tcp-wrapper program is installed, next we will configure our wrappers.<P><B>4: Set up our banners</B> (optional)<BR><B>&nbsp;&nbsp; </B>Banners contain the message displayed&nbsp; whentcpd is called for a particular service. Create the&nbsp;&nbsp;&nbsp; bannersdirectory if necessary.<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; <I>mkdir /usr/local/etc/banners</I><P>&nbsp;&nbsp;&nbsp; For every service you want a message for, you'llhave to edit a file in the banners directory.<BR>&nbsp;&nbsp;&nbsp; /usr/local/etc/banners/in.telnetd&nbsp;&nbsp; &lt;----forthe telnet banner<BR>&nbsp;&nbsp;&nbsp; /usr/local/etc/banners/in.ftpd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;----for the ftp banner<BR>&nbsp;<BR><B>5:&nbsp; Edit your /etc/hosts.allow&nbsp; and /etc/hosts.deny tolimit access to your computer's network services.</B><BR>&nbsp;&nbsp;&nbsp; One of the nice features of tcp-wrappers is theability to control access to your computers network services and log failedor sucessful attempts. You can also perform certain actions based on theusers hostname.<BR>&nbsp;&nbsp;&nbsp; When someone tries to connect to a network serviceon your computer the tcp-wrapper (tcpd) reads the file /etc/hosts.allow&nbsp;for a rule that matches the the hostname of the person trying to connect,if /etc/hosts.allow doesn't contain a rule allowing access tcpd reads /etc/hosts.denyfor a rule that would deny access to the hostname. If neither file containsan accept or deny rule, access is granted by default.<P>In the following examples we are going to&nbsp; deny all finger request,deny telnet access to all users from lamers.edu (access can be denied inthe hosts.allow file) and email a user called "auth" with details of everyconnection attempt...the format of the hosts.allow/hosts.deny files isas follows:<BR><B>service: hostname: banners if needed : options</B><P>Our example&nbsp;&nbsp; /etc/hosts.allow&nbsp; looks like the following----><BR>---------------------------------------------------------<BR>in.fingerd: ALL : banners /usr/local/etc/banners/ : spawn (echo "Accessfrom %u@%h using %d." | sendmail auth) : DENY<BR>in.telnetd: .lamers.edu : spawn (echo "Access from %u@%h using %d."| sendmail auth : DENY<BR>ALL: ALL : spawn (echo "Access from %u %h using %d." | sendmail auth)<P>---------------------------------------------------------<BR>In the first line "in.fingerd" is the service, the hostname is "ALL"which means the rule applies to all hosts , then we tell tcpd to displaythe banner to the user, and finally we tell tcpd to start(spawn) another&nbsp;program that emails&nbsp; the message "Access from some-user@some.host.comusing in.fingerd" to the user "auth"...finally it tells tcpd the "DENY"access. For this to work you will need a user on your system called "auth",many people send it to "root" but then you have to be logged in as rootto read it, also it clutters root's mailbox and makes it difficult to sortyour tcpd mail from other "root" mail.<P>The second rule follows the same format as the first, it denies accessto telnet to all users from "lamers.edu",&nbsp; and sends email to auth.<P>The third rule allows access to all users from everywhere but email's"auth" with details of the connection.<P>Each rule goes on it's own unbroken line.<P><I>"man 5 hosts_access"&nbsp; </I>for more information.<P><B>4. Edit your /etc/syslog.conf&nbsp; to use the syslog with tcpd.</B><P><U>Here are a few lines of a typical&nbsp; /etc/syslog.conf:</U><P>*.err;kern.debug;auth.notice;mail.crit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/console<BR>*.notice;kern.debug;lpr.info;mail.crit;news.err /var/log/messages<BR>mail.info&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/var/log/maillog<P><U>Here are a few lines of&nbsp; our edited /etc/syslog.conf:</U><P>*.err;kern.debug;auth.notice;mail.crit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/console<BR>*.notice;kern.debug;lpr.info;mail.crit;news.err;auth.info /var/log/messages<BR>mail.info&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/var/log/maillog<P>The difference is the added line for auth.info logging to /var/log/messages.<BR>&nbsp;<BR><B>5. Edit /etc/inetd.conf to point your services to tcpd.</B><P>The following example has the original lines commented (#) out and ourmodified tcpd lines inserted.<PRE>#ftp&nbsp;&nbsp;&nbsp; stream&nbsp; tcp&nbsp;&nbsp;&nbsp;&nbsp; nowait&nbsp; root&nbsp;&nbsp;&nbsp; /usr/sbin/ftpd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ftpd -l -aftp&nbsp;&nbsp;&nbsp;&nbsp; stream&nbsp; tcp&nbsp;&nbsp;&nbsp;&nbsp; nowait&nbsp; root&nbsp;&nbsp;&nbsp; /usr/sbin/tcpd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ftpd -l -a#telnet stream&nbsp; tcp&nbsp;&nbsp;&nbsp;&nbsp; nowait&nbsp; root&nbsp;&nbsp;&nbsp; /usr/sbin/telnetd&nbsp;&nbsp;&nbsp; telnetdtelnet&nbsp; stream&nbsp; tcp&nbsp;&nbsp;&nbsp;&nbsp; nowait&nbsp; root&nbsp;&nbsp;&nbsp; /usr/sbin/tcpd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; telnetd#finger stream&nbsp; tcp&nbsp;&nbsp;&nbsp;&nbsp; nowait&nbsp; nobody&nbsp; /usr/sbin/fingerd&nbsp;&nbsp;&nbsp; fingerd -sfinger&nbsp; stream&nbsp; tcp&nbsp;&nbsp;&nbsp;&nbsp; nowait&nbsp; nobody&nbsp; /usr/sbin/tcpd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; fingerd -s</PRE>Linux differs from some *unix's in that the file locations aren't quite"standard", so when you install tcp_wrappers the "tcpd" file may be inthe "/usr/libexec" directory, in which case you'll have to change "/usr/sbin/tcpd"to "/usr/libexec/tcpd" in the above example.<P>6. If everything above is correct you can reboot or restart inetd andsyslogd .<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; To restart rather that reboot you need the pid#of both inetd and syslogd...to get this info:<P>&nbsp;&nbsp;&nbsp;&nbsp; <I>ps -xa | grep inetd</I><BR><I>&nbsp;&nbsp;&nbsp; </I>the output --->"19086 ??&nbsp; IWs&nbsp;&nbsp;&nbsp;&nbsp;0:00.05 inetd "<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; 19086 is the pid of inetd...to restart inetd:<BR>&nbsp;&nbsp;&nbsp; <I>kill -1 19086</I><BR>&nbsp;&nbsp;&nbsp;&nbsp; The process&nbsp; is the same for the syslogdaemon and your done...<B>congratulations!</B><P>Comments, questions, suggestions, corrections? Drop me a line at <AHREF="mailto:fireman@shaw.wave.ca">fireman@shaw.wave.ca</A><BR>&nbsp;<P><B><FONT SIZE="-1">Copyright &copy; 1998 <AHREF="mailto:fireman@shaw.wave.ca">Rob Sellars (fireman@shaw.wave.ca)</A>. Allrights reserved. Permission to use, distribute, modify and copy this document ishereby granted provided credit to this document is included in the modifyed document.</FONT></B></P></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -