<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>半瓶 &#187; 主机及存储</title>
	<atom:link href="http://www.banping.com/category/hoststorage/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.banping.com</link>
	<description>一瓶子不满  半瓶子晃荡</description>
	<lastBuildDate>Fri, 27 Jan 2012 05:43:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>优化Linux服务器的一些参数</title>
		<link>http://www.banping.com/2011/11/21/optimize-linux-core-parameters/</link>
		<comments>http://www.banping.com/2011/11/21/optimize-linux-core-parameters/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 08:42:15 +0000</pubDate>
		<dc:creator>banping</dc:creator>
				<category><![CDATA[主机及存储]]></category>

		<guid isPermaLink="false">http://www.banping.com/?p=1009</guid>
		<description><![CDATA[<p>生产环境跑的Linux服务器，默认的一些参数有时候需要调整，以下是个小总结，大部分内容来源自网络上别人的经验。</p> <p>首先，调整网络方面的参数：</p> [root@banping conf]# vi /etc/sysctl.conf # add by banping net.ipv4.tcp_max_syn_backlog = 65536 net.core.netdev_max_backlog = 32768 net.core.somaxconn = 32768 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core.wmem_max = 16777216 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = 2 net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 2097152 3145728 4194304 net.ipv4.tcp_max_orphans [...]]]></description>
			<content:encoded><![CDATA[<p>生产环境跑的Linux服务器，默认的一些参数有时候需要调整，以下是个小总结，大部分内容来源自网络上别人的经验。</p>
<p>首先，调整网络方面的参数：</p>
<blockquote>
<pre>[root@banping conf]# vi /etc/sysctl.conf</pre>
<pre># add by banping
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog =  32768
net.core.somaxconn = 32768

net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216

net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2

net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_mem = 2097152 3145728 4194304
net.ipv4.tcp_max_orphans = 3276800

net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 1024  65535</pre>
</blockquote>
<p>查看网络连接状态：</p>
<blockquote>
<pre>[root@banping ~]# netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
SYN_RECV 3
CLOSE_WAIT 40
ESTABLISHED 73
FIN_WAIT1 6
FIN_WAIT2 2
TIME_WAIT 900</pre>
</blockquote>
<p>在OS级别设置打开文件的最大数目：</p>
<blockquote>
<pre>[root@banping conf]# vi /etc/security/limits.conf
#add by banping
* soft nofile 65536
* hard nofile 65536</pre>
</blockquote>
<p>设置单个进程能打开的句柄数：</p>
<blockquote>
<pre>[root@rtweb conf]# vi /etc/profile</pre>
<pre># add by banping
ulimit -SHn 65536</pre>
</blockquote>
<p>查看每个进程打开的句柄数：</p>
<blockquote>
<pre>[root@banping ~]# lsof -n |awk '{print $2}'|sort|uniq -c |sort -nr|more
    164 4522
    163 19230
    125 25142
    ......</pre>
</blockquote>
<p>前面是打开的句柄数，后面是进程ID，可以据此判断是什么进程。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.banping.com/2011/11/21/optimize-linux-core-parameters/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>RedHat的yum无法使用的解决办法</title>
		<link>http://www.banping.com/2011/11/11/change-redhat-yum-to-centos/</link>
		<comments>http://www.banping.com/2011/11/11/change-redhat-yum-to-centos/#comments</comments>
		<pubDate>Fri, 11 Nov 2011 02:37:04 +0000</pubDate>
		<dc:creator>banping</dc:creator>
				<category><![CDATA[主机及存储]]></category>

		<guid isPermaLink="false">http://www.banping.com/?p=1004</guid>
		<description><![CDATA[<p>最近弄了一台阿里云服务器，安装的是RedHat5.4 64位的系统。有点奇怪的是阿里云只提供CentOS 32位的系统，RH才有64位的。但是在使用yum的过程中报错：</p> <p>[root@banping mysql-5.5.10]# yum install libaio-devel</p> <p>Loaded plugins: rhnplugin, security</p> <p>This system is not registered with RHN.</p> <p>RHN support will be disabled.</p> <p>Setting up Install Process</p> <p>No package libaio-devel available.</p> <p>Nothing to do</p> <p>意思是这套RH没有在官网上注册，不能下载RH的软件包。后来我把yum替换成了CentOS的版本，过程如下：</p> <p>首先看看有哪些yum包，然后卸载掉：</p> <p>[root@banping mysql-5.5.10]# rpm -qa&#124;grep yum</p> <p>yum-rhn-plugin-0.5.4-13.el5</p> <p>yum-3.2.22-20.el5</p> <p>yum-metadata-parser-1.1.2-3.el5</p> <p>yum-security-1.1.16-13.el5</p> <p>yum-updatesd-0.9-2.el5</p> <p>卸载要使用nodeps参数，否则由于依赖关系是无法卸载成功的：</p> <p>rpm -e --nodeps yum-rhn-plugin-0.5.4-13.el5</p> <p>......</p> <p>然后可以从163的镜像下载CentOS的yum包：</p> <p>[root@banping [...]]]></description>
			<content:encoded><![CDATA[<p>最近弄了一台阿里云服务器，安装的是RedHat5.4 64位的系统。有点奇怪的是阿里云只提供CentOS 32位的系统，RH才有64位的。但是在使用yum的过程中报错：</p>
<blockquote><p>[root@banping mysql-5.5.10]# yum install libaio-devel</p>
<p>Loaded plugins: rhnplugin, security</p>
<p>This system is not registered with RHN.</p>
<p>RHN support will be disabled.</p>
<p>Setting up Install Process</p>
<p>No package libaio-devel available.</p>
<p>Nothing to do</p></blockquote>
<p>意思是这套RH没有在官网上注册，不能下载RH的软件包。后来我把yum替换成了CentOS的版本，过程如下：</p>
<p>首先看看有哪些yum包，然后卸载掉：</p>
<blockquote><p>[root@banping mysql-5.5.10]# rpm -qa|grep yum</p>
<p>yum-rhn-plugin-0.5.4-13.el5</p>
<p>yum-3.2.22-20.el5</p>
<p>yum-metadata-parser-1.1.2-3.el5</p>
<p>yum-security-1.1.16-13.el5</p>
<p>yum-updatesd-0.9-2.el5</p></blockquote>
<p>卸载要使用nodeps参数，否则由于依赖关系是无法卸载成功的：</p>
<blockquote><p>rpm -e --nodeps yum-rhn-plugin-0.5.4-13.el5</p>
<p>......</p></blockquote>
<p>然后可以从163的镜像下载CentOS的yum包：</p>
<blockquote><p>[root@banping centos]# wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-3.2.22-37.el5.centos.noarch.rpm</p>
<p>[root@banping centos]# wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-fastestmirror-1.1.16-16.el5.centos.noarch.rpm</p>
<p>[root@banping centos]# wget http://mirrors.163.com/centos/5/os/x86_64/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.x86_64.rpm</p></blockquote>
<p>安装新下载的包：</p>
<blockquote><p>[root@banping centos]# rpm -ivh yum-*</p></blockquote>
<p>找一个CentOS的包资源配置库,名为CentOS-Base.repo，放到/etc/yum.repos.d/路径：</p>
<blockquote><p>wget http://www.linuxidc.com/files/2011/05/06/CentOS-Base.repo</p></blockquote>
<p>生成缓存文件到/var/cache/yum路径：</p>
<blockquote><p>[root@banping yum.repos.d]# yum makecache</p></blockquote>
<p>这样就可以使用CentOS的yum了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.banping.com/2011/11/11/change-redhat-yum-to-centos/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>如何在Linux服务器之间ssh不需要密码？</title>
		<link>http://www.banping.com/2011/10/12/linux-ssh-not-need-password-rsa/</link>
		<comments>http://www.banping.com/2011/10/12/linux-ssh-not-need-password-rsa/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 03:25:09 +0000</pubDate>
		<dc:creator>banping</dc:creator>
				<category><![CDATA[主机及存储]]></category>

		<guid isPermaLink="false">http://www.banping.com/?p=1001</guid>
		<description><![CDATA[<p>要在一台Linux上ssh到另外一台Linux服务器，而不需要每次都输入密码，其实很简单。比如要从A服务器登录到B服务器，那么首先在A服务器上生成公钥和私钥，用RSA加密算法：</p> [root@test awstats]# ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: 9c:74:d0:05:48:c8:43:84:a8:44:8f:b6:a1:2f:8c:91 root@test.banping.com [root@test awstats]# cd /root/.ssh/ [...]]]></description>
			<content:encoded><![CDATA[<p>要在一台Linux上ssh到另外一台Linux服务器，而不需要每次都输入密码，其实很简单。比如要从A服务器登录到B服务器，那么首先在A服务器上生成公钥和私钥，用RSA加密算法：</p>
<blockquote>
<pre>[root@test awstats]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
9c:74:d0:05:48:c8:43:84:a8:44:8f:b6:a1:2f:8c:91 root@test.banping.com</pre>
<pre>[root@test awstats]# cd /root/.ssh/
[root@test .ssh]# ll
-rw------- 1 root root 1675 10-12 10:15 id_rsa
-rw-r--r-- 1 root root  397 10-12 10:15 id_rsa.pub
-rw-r--r-- 1 root root 1972 08-15 19:50 known_hosts</pre>
</blockquote>
<p>可见这里的id_rsa和id_rsa.pub就是私钥和公钥了，把公钥的内容放到B服务器的指定位置就可以了。</p>
<p>放到哪里呢？对应登录用户的home的.ssh目录下，文件名一般为authorized_keys，其实这个名字是任意的，是写在sshd_config文件里的：</p>
<blockquote><p>[root@web-04 .ssh]# cd /etc/ssh</p>
<p>[root@web-04 ssh]# vi sshd_config</p>
<p>AuthorizedKeysFile      .ssh/authorized_keys</p></blockquote>
<p>这个authorized_keys文件可以放置多个其他服务器的公钥，如果你想让多台服务器都能无需输入密码就登录上来，把它们的公钥放这里就行了。不过安全第一，切不可为了省事而忽略了安全的问题。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.banping.com/2011/10/12/linux-ssh-not-need-password-rsa/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SELinux给vsftpd配置带来的问题</title>
		<link>http://www.banping.com/2011/08/08/selinux-vsftpd-ftp/</link>
		<comments>http://www.banping.com/2011/08/08/selinux-vsftpd-ftp/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 11:19:49 +0000</pubDate>
		<dc:creator>banping</dc:creator>
				<category><![CDATA[主机及存储]]></category>

		<guid isPermaLink="false">http://www.banping.com/?p=924</guid>
		<description><![CDATA[<p>今天在centos 5.6 x86_64的服务器上配置一个vsftpd的时候碰到了一些波折，系统用户登录后死活都不能切换目录，也无法上传文件：</p> C:\Users\rt8&#62;ftp 192.168.0.26 连接到 192.168.0.26。 220 (vsFTPd 2.0.5) 用户(192.168.0.26:(none)): dev 331 Please specify the password. 密码: 230 Login successful. ftp&#62; ls 200 PORT command successful. Consider using PASV. 150 Here comes the directory listing. admins api_www backend_templates backend_templates_c bt.tar.gz command config home icon lib mobile mobile_templates mobile_templates_c rt.cn rtweb.tar.gz script site_api temp templates [...]]]></description>
			<content:encoded><![CDATA[<p>今天在centos 5.6 x86_64的服务器上配置一个vsftpd的时候碰到了一些波折，系统用户登录后死活都不能切换目录，也无法上传文件：</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">C:\Users\rt8&gt;ftp 192.168.0.26</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">连接到 192.168.0.26。</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">220 (vsFTPd 2.0.5)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">用户(192.168.0.26:(none)): dev</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">331 Please specify the password.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">密码:</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">230 Login successful.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ftp&gt; ls</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">200 PORT command successful. Consider using PASV.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">150 Here comes the directory listing.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">admins</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">api_www</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">backend_templates</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">backend_templates_c</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">bt.tar.gz</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">command</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">config</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">home</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">icon</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">lib</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mobile</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mobile_templates</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">mobile_templates_c</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">rt.cn</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">rtweb.tar.gz</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">script</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">site_api</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">temp</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">templates</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">templates_c</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">test</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">trunk</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">www</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">226 Directory send OK.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ftp: 收到 235 字节，用时 0.01秒 23.50千字节/秒。</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ftp&gt; cd test</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">550 Failed to change directory.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ftp&gt; bye</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">221 Goodbye.</div>
<blockquote><p>C:\Users\banping&gt;ftp 192.168.0.26</p>
<p>连接到 192.168.0.26。</p>
<p>220 (vsFTPd 2.0.5)</p>
<p>用户(192.168.0.26:(none)): banping</p>
<p>331 Please specify the password.</p>
<p>密码:</p>
<p>230 Login successful.</p>
<p>ftp&gt; ls</p>
<p>200 PORT command successful. Consider using PASV.</p>
<p>150 Here comes the directory listing.</p>
<p>temp</p>
<p>test</p>
<p>226 Directory send OK.</p>
<p>ftp: 收到 235 字节，用时 0.01秒 23.50千字节/秒。</p>
<p>ftp&gt; cd test</p>
<p>550 Failed to change directory.</p>
<p>ftp&gt; put d:/1.txt</p>
<p>200 PORT command successful. Consider using PASV.</p>
<p>553 Could not create file.</p>
<p>ftp&gt; bye</p>
<p>221 Goodbye.</p></blockquote>
<p>经确认不是配置的问题，后来才发现是SELinux导致的。SELinux全称是Security Enhanced Linux，是增强Linux安全性的一个软件包，默认配置在/etc/selinux目录，可以关掉它对FTP的安全审核功能来解决这个问题：</p>
<blockquote><p>[root@dev dev]# setsebool -P ftpd_disable_trans on</p>
<p>[root@dev dev]# service vsftpd restart</p></blockquote>
<p>然后再试就OK了。记录一下备忘。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.banping.com/2011/08/08/selinux-vsftpd-ftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>配置Linux防火墙的一些方法</title>
		<link>http://www.banping.com/2010/04/30/linux_iptables/</link>
		<comments>http://www.banping.com/2010/04/30/linux_iptables/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 09:07:55 +0000</pubDate>
		<dc:creator>banping</dc:creator>
				<category><![CDATA[主机及存储]]></category>

		<guid isPermaLink="false">http://www.banping.com/?p=694</guid>
		<description><![CDATA[<p>首先查看一下现有的防火墙配置：</p> <p>[root@localhost banping]# vi /etc/sysconfig/iptables</p> <p># Firewall configuration written by system-config-securitylevel<br /> # Manual customization of this file is not recommended.<br /> *filter<br /> :INPUT ACCEPT [0:0]<br /> :FORWARD ACCEPT [0:0]<br /> :OUTPUT ACCEPT [0:0]<br /> :RH-Firewall-1-INPUT - [0:0]<br /> -A INPUT -p tcp -m tcp --dport 8000 -j ACCEPT<br /> -A INPUT -j RH-Firewall-1-INPUT<br [...]]]></description>
			<content:encoded><![CDATA[<p>首先查看一下现有的防火墙配置：</p>
<blockquote><p>[root@localhost banping]# vi /etc/sysconfig/iptables</p>
<p># Firewall configuration written by system-config-securitylevel<br />
# Manual customization of this file is not recommended.<br />
*filter<br />
:INPUT ACCEPT [0:0]<br />
:FORWARD ACCEPT [0:0]<br />
:OUTPUT ACCEPT [0:0]<br />
:RH-Firewall-1-INPUT - [0:0]<br />
-A INPUT -p tcp -m tcp --dport 8000 -j ACCEPT<br />
-A INPUT -j RH-Firewall-1-INPUT<br />
-A FORWARD -j RH-Firewall-1-INPUT<br />
-A RH-Firewall-1-INPUT -i lo -j ACCEPT<br />
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT<br />
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT<br />
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT<br />
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT<br />
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT<br />
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT<br />
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT<br />
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT<br />
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT<br />
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited</p></blockquote>
<p>查看现有的策略：</p>
<blockquote><p>[root@localhost banping]# iptables -L -n<br />
Chain INPUT (policy ACCEPT)<br />
target     prot opt source               destination<br />
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8000<br />
RH-Firewall-1-INPUT  all  --  0.0.0.0/0            0.0.0.0/0</p>
<p>Chain FORWARD (policy ACCEPT)<br />
target     prot opt source               destination<br />
RH-Firewall-1-INPUT  all  --  0.0.0.0/0            0.0.0.0/0</p>
<p>Chain OUTPUT (policy ACCEPT)<br />
target     prot opt source               destination</p>
<p>Chain RH-Firewall-1-INPUT (2 references)<br />
target     prot opt source               destination<br />
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0<br />
ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           icmp type 255<br />
ACCEPT     esp  --  0.0.0.0/0            0.0.0.0/0<br />
ACCEPT     ah   --  0.0.0.0/0            0.0.0.0/0<br />
ACCEPT     udp  --  0.0.0.0/0            224.0.0.251         udp dpt:5353<br />
ACCEPT     udp  --  0.0.0.0/0            0.0.0.0/0           udp dpt:631<br />
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:631<br />
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED<br />
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22<br />
ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:23<br />
REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited</p></blockquote>
<p>如果要重新配置，先清空之前的策略：</p>
<blockquote><p>[root@localhost banping]# iptables -F<br />
[root@localhost banping]# iptables -X<br />
[root@localhost banping]# iptables -L -n<br />
Chain INPUT (policy ACCEPT)<br />
target     prot opt source               destination</p>
<p>Chain FORWARD (policy ACCEPT)<br />
target     prot opt source               destination</p>
<p>Chain OUTPUT (policy ACCEPT)<br />
target     prot opt source               destination</p></blockquote>
<p>先配置开放22端口，否则如果是远程登入的，会把自己关在外面：</p>
<blockquote><p>[root@localhost banping]# iptables -A INPUT -p tcp --dport 22 -j ACCEPT</p></blockquote>
<p>然后丢弃所有的input，根据需要配置开放的就行了：</p>
<blockquote><p>[root@localhost banping]# iptables -P INPUT DROP<br />
[root@localhost banping]# iptables -P OUTPUT ACCEPT<br />
[root@localhost banping]# iptables -P FORWARD ACCEPT</p></blockquote>
<p>然后要保存一下：</p>
<blockquote><p>[root@localhost banping]# /etc/rc.d/init.d/iptables save<br />
将当前规则保存到 /etc/sysconfig/iptables：[确定]</p></blockquote>
<p>重启防火墙服务：</p>
<blockquote><p>[root@localhost banping]# service iptables restart<br />
清除防火墙规则：[确定]<br />
把 chains 设置为 ACCEPT 策略：filter [确定]<br />
正在卸载 Iiptables 模块：[确定]<br />
应用 iptables 防火墙规则：[确定]<br />
载入额外 iptables 模块：ip_conntrack_netbios_ns [确定]</p></blockquote>
<p>除了用iptables命令，也可以直接编辑/etc/sysconfig/iptables文件，最终的配置结果可能如下，：</p>
<blockquote><p>[root@localhost banping]# vi /etc/sysconfig/iptables</p>
<p># Generated by iptables-save v1.3.5 on Thu Apr 29 17:28:08 2010<br />
*filter<br />
:INPUT DROP [3:349]<br />
:FORWARD ACCEPT [0:0]<br />
:OUTPUT ACCEPT [5585:947488]<br />
-A INPUT -i lo -j ACCEPT<br />
-A INPUT -s 172.16.0.1 -i eth0 -p tcp -m tcp --dport 22 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT<br />
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT<br />
-A INPUT -s 172.16.0.2 -i eth0 -j ACCEPT<br />
-A INPUT -s 172.16.0.3 -i eth0 -j ACCEPT<br />
COMMIT<br />
# Completed on Thu Apr 29 17:28:08 2010</p></blockquote>
<p>可见，这里的配置允许指定的IP访问22端口，开放80端口，不限制下边的两个IP进行连接。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.banping.com/2010/04/30/linux_iptables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在Linux下安装JDK和tomcat</title>
		<link>http://www.banping.com/2010/02/23/install_jdk_tomcat/</link>
		<comments>http://www.banping.com/2010/02/23/install_jdk_tomcat/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 09:03:00 +0000</pubDate>
		<dc:creator>banping</dc:creator>
				<category><![CDATA[主机及存储]]></category>

		<guid isPermaLink="false">http://www.banping.com/?p=617</guid>
		<description><![CDATA[<p>在Linux 安装JDK和Tomcat 很简单，简要介绍如下：</p> <p>首先去下载软件，地址分别是</p> <p><a href="http://java.sun.com/javase/downloads/index.jsp">http://java.sun.com/javase/downloads/index.jsp</a></p> <p>和</p> <p><a href="http://tomcat.apache.org/">http://tomcat.apache.org/</a></p> <p>注意选择自己需要的合适的版本，比如我下载的是apache-tomcat-5.5.23.tar.gz和jdk-6u18-linux-x64-rpm.bin.gz，然后上传到/tmp目录下。</p> <p>安装JDK：</p> <p>[root@tomcat1 tmp]# sh jdk-6u18-linux-x64-rpm.bin</p> <p>Sun Microsystems, Inc. Binary Code License Agreement</p> <p>for the JAVA SE DEVELOPMENT KIT (JDK), VERSION 6</p> <p>......</p> <p>Do you agree to the above license terms? [yes or no]<br />            yes<br /> Unpacking...<br /> Checksumming...<br /> Extracting...</p> <p>......</p> <p>Press Enter [...]]]></description>
			<content:encoded><![CDATA[<p>在Linux 安装JDK和Tomcat 很简单，简要介绍如下：</p>
<p>首先去下载软件，地址分别是</p>
<p><a href="http://java.sun.com/javase/downloads/index.jsp">http://java.sun.com/javase/downloads/index.jsp</a></p>
<p>和</p>
<p><a href="http://tomcat.apache.org/">http://tomcat.apache.org/</a></p>
<p>注意选择自己需要的合适的版本，比如我下载的是apache-tomcat-5.5.23.tar.gz和jdk-6u18-linux-x64-rpm.bin.gz，然后上传到/tmp目录下。</p>
<p>安装JDK：</p>
<blockquote><p>[root@tomcat1 tmp]# sh jdk-6u18-linux-x64-rpm.bin</p>
<p>Sun Microsystems, Inc. Binary Code License Agreement</p>
<p>for the JAVA SE DEVELOPMENT KIT (JDK), VERSION 6</p>
<p>......</p>
<p>Do you agree to the above license terms? [yes or no]<br />
           yes<br />
Unpacking...<br />
Checksumming...<br />
Extracting...</p>
<p>......</p>
<p>Press Enter to continue.....<br />
Done.</p></blockquote>
<p>安装完成后，JDK被安装在/usr/java目录下。这个版本会在当前路径下安装javaDB，以前的版本不会。</p>
<p>安装tomcat ：</p>
<blockquote><p>[root@tomcat1 tmp]# tar -zxvf apache-tomcat-5.5.23.tar.gz</p></blockquote>
<p>然后会在当前路径下生成apache-tomcat-5.5.23文件夹，把它mv或cp到你想要的路径即可。</p>
<blockquote><p>[root@tomcat1 tmp]# cp -a apache-tomcat-5.5.23 /usr/local/</p></blockquote>
<p>然后配置环境变量：</p>
<blockquote><p>[root@tomcat1 tmp]# vi /etc/profile</p>
<p>#set java environment<br />
JAVA_HOME=/usr/java/jdk1.6.0_18<br />
export TOMCAT_HOME=/usr/local/apache-tomcat-5.5.23</p>
<p>CLASSPATH=.:$JAVA_HOME/lib/tools.jar<br />
PATH=$JAVA_HOME/bin:$PATH<br />
export JAVA_HOME CLASSPATH PATH</p>
<p>[root@tomcat1 tmp]# source /etc/profile</p></blockquote>
<p>查看java的版本号已经生效了：</p>
<blockquote><p>[root@tomcat1 tmp]# java -version<br />
java version "1.6.0_18"<br />
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)<br />
Java HotSpot(TM) 64-Bit Server VM (build 16.0-b13, mixed mode)</p></blockquote>
<p>测试tomcat ：</p>
<blockquote><p>[root@tomcat1 tmp]# cd /usr/local/apache-tomcat-5.5.23/bin/</p>
<p>[root@tomcat1 bin]# ./startup.sh<br />
Using CATALINA_BASE:   /usr/local/apache-tomcat-5.5.23<br />
Using CATALINA_HOME:   /usr/local/apache-tomcat-5.5.23<br />
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-5.5.23/temp<br />
Using JRE_HOME:       /usr/java/jdk1.6.0_18</p></blockquote>
<p>打开网页查看8080端口就能看到可爱的猫了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.banping.com/2010/02/23/install_jdk_tomcat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>收集IBM小型机的snap信息</title>
		<link>http://www.banping.com/2010/01/20/collect_ibm_snap/</link>
		<comments>http://www.banping.com/2010/01/20/collect_ibm_snap/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 02:48:47 +0000</pubDate>
		<dc:creator>banping</dc:creator>
				<category><![CDATA[主机及存储]]></category>

		<guid isPermaLink="false">http://www.banping.com/?p=604</guid>
		<description><![CDATA[<p>用root用户登录，首先清除原来的snap信息：</p> <p>p5a1@/#snap -r</p> <p>The following directories and files will be deleted:<br /> -----------------------------------------------------------<br /> /tmp/ibmsupt/general (directory)<br /> /tmp/ibmsupt/other (directory)<br /> /tmp/ibmsupt/testcase (directory)<br /> /tmp/ibmsupt/ssa (directory)<br /> /tmp/ibmsupt/pcixscsi (directory)<br /> /tmp/ibmsupt/snap.pax.Z (file)</p> <p>Do you want me to remove these directories (y/n)? y<br /> Removing... done.</p> <p>如果以前未做过snap，会提示：</p> <p>nothing to clean up</p> <p>清理完成后可以开始收集：</p> <p>p5a1@/#snap -gbLc<br /> /var/adm/ras/trcfile: No [...]]]></description>
			<content:encoded><![CDATA[<p>用root用户登录，首先清除原来的snap信息：</p>
<blockquote><p>p5a1@/#snap -r</p>
<p>The following directories and files will be deleted:<br />
-----------------------------------------------------------<br />
/tmp/ibmsupt/general (directory)<br />
/tmp/ibmsupt/other (directory)<br />
/tmp/ibmsupt/testcase (directory)<br />
/tmp/ibmsupt/ssa (directory)<br />
/tmp/ibmsupt/pcixscsi (directory)<br />
/tmp/ibmsupt/snap.pax.Z (file)</p>
<p>Do you want me to remove these directories (y/n)? y<br />
Removing... done.</p></blockquote>
<p>如果以前未做过snap，会提示：</p>
<blockquote><p>nothing to clean up</p></blockquote>
<p>清理完成后可以开始收集：</p>
<blockquote><p>p5a1@/#snap -gbLc<br />
/var/adm/ras/trcfile: No such file or directory<br />
Checking space requirement for general information.... done.<br />
.********Checking and initializing directory structure<br />
Creating /tmp/ibmsupt/svCollect directory tree... done.<br />
Creating /tmp/ibmsupt/client_collect directory tree... done.<br />
Creating /tmp/ibmsupt/lvm directory tree... done.<br />
Creating /tmp/ibmsupt/ssa directory tree... done.<br />
Creating /tmp/ibmsupt/general directory tree... done.<br />
Creating /tmp/ibmsupt/general/diagnostics directory tree... done.<br />
Creating /tmp/ibmsupt/pcixscsi directory tree... done.<br />
Creating /tmp/ibmsupt/testcase directory tree... done.<br />
Creating /tmp/ibmsupt/other directory tree... done.<br />
********Finished setting up directory /tmp/ibmsupt</p>
<p>Checking Space requirement for svCollect<br />
The script svCollect is not executable in /usr/lib/ras/snapscripts<br />
Checking Space requirement for client_collect<br />
Checking space requirement for ssa information.......... done.<br />
Checking space requirement for logical volume manager information......<br />
Checking space requirement for Enhanced CLVM information..../tmp/ch.log.* not found<br />
done.<br />
Checking for enough free space in filesystem... done.</p>
<p>/var/adm/ras/trcfile: No such file or directory<br />
Gathering general system information............ done.<br />
Gathering platform/scanout information.done.<br />
Gathering svCollect data<br />
The script svCollect is not executable in /usr/lib/ras/snapscripts<br />
Gathering client_collect data<br />
Gathering pcixscsi system information........... done.<br />
Gathering ssa system information.......... done.<br />
Gathering logical volume manager information..........<br />
Gathering Enhanced CLVM information..../tmp/ch.log.* not found<br />
done.</p>
<p>Creating compressed pax file...<br />
Starting pax/compress process... Please wait... done.</p>
<p>-rw-------   1 0        0           1259857 Jan 20 09:24 snap.pax.Z</p></blockquote>
<p>可以根据需要指定不同的参数，<span style="font-family: Microsoft YaHei; color: #000000;">b是收集 SSA  信息，f是收集文件系统信息</span>：</p>
<blockquote><p>p5a1@/#snap -gLfc<br />
/var/adm/ras/trcfile: No such file or directory<br />
Checking space requirement for general information.................................. done.<br />
.********Checking and initializing directory structure<br />
Creating /tmp/ibmsupt/svCollect directory tree... done.<br />
Creating /tmp/ibmsupt/client_collect directory tree... done.<br />
Creating /tmp/ibmsupt/lvm directory tree... done.<br />
Creating /tmp/ibmsupt/filesys directory tree... done.<br />
Creating /tmp/ibmsupt/general directory tree... done.<br />
Creating /tmp/ibmsupt/general/diagnostics directory tree... done.<br />
Creating /tmp/ibmsupt/pcixscsi directory tree... done.<br />
Creating /tmp/ibmsupt/testcase directory tree... done.<br />
Creating /tmp/ibmsupt/other directory tree... done.<br />
********Finished setting up directory /tmp/ibmsupt</p>
<p>Checking Space requirement for svCollect<br />
The script svCollect is not executable in /usr/lib/ras/snapscripts<br />
Checking Space requirement for client_collect<br />
Checking space requirement for filesys information................done.<br />
Checking space requirement for logical volume manager information.....................<br />
Checking space requirement for Enhanced CLVM information..../tmp/ch.log.* not found<br />
done.<br />
Checking for enough free space in filesystem... done.</p>
<p>/var/adm/ras/trcfile: No such file or directory<br />
Gathering general system information......................done.<br />
Gathering platform/scanout information.done.<br />
Gathering svCollect data<br />
The script svCollect is not executable in /usr/lib/ras/snapscripts<br />
Gathering client_collect data<br />
Gathering pcixscsi system information...........................<br />
Gathering filesys system information........done.<br />
Gathering logical volume manager information...............<br />
Gathering Enhanced CLVM information..../tmp/ch.log.* not found<br />
done.</p>
<p>Creating compressed pax file...<br />
Starting pax/compress process... Please wait... done.</p>
<p>-rw-------   1 0        0           1383719 Jun 17 10:29 snap.pax.Z</p></blockquote>
<p>收集完成后，通过ftp就可以拿下这个文件了：</p>
<blockquote><p>Microsoft Windows XP [版本 5.1.2600]<br />
(C) 版权所有 1985-2001 Microsoft Corp.</p>
<p>C:\Documents and Settings\banping&gt;ftp 172.16.0.62<br />
Connected to 172.16.0.62.<br />
220 p5a1 FTP server (Version 4.2 Thu Jul 12 13:39:06 CDT 2007) ready.<br />
User (172.16.0.62:(none)): root<br />
331 Password required for root.<br />
Password:<br />
230-Last unsuccessful login: Sat Jan 16 09:43:39 BEIST 2010 on /dev/pts/0 from i<br />
user.banping.com<br />
230-Last login: Tue Jan 19 09:10:37 BEIST 2010 on ftp from user.banping.com<br />
230 User root logged in.<br />
ftp&gt; bin<br />
200 Type set to I.<br />
ftp&gt; get /tmp/ibmsupt/snap.pax.Z<br />
200 PORT command successful.<br />
150 Opening data connection for /tmp/ibmsupt/snap.pax.Z (1259857 bytes).<br />
226 Transfer complete.<br />
ftp: 收到 1259857 字节，用时 0.09Seconds 13402.73Kbytes/sec.</p></blockquote>
<p>去user用户的document目录下就能拿到这个文件了。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.banping.com/2010/01/20/collect_ibm_snap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用Linux自带的gssftp服务</title>
		<link>http://www.banping.com/2010/01/12/linux_gssftp/</link>
		<comments>http://www.banping.com/2010/01/12/linux_gssftp/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 09:03:40 +0000</pubDate>
		<dc:creator>banping</dc:creator>
				<category><![CDATA[主机及存储]]></category>

		<guid isPermaLink="false">http://www.banping.com/?p=586</guid>
		<description><![CDATA[<p>RedHat和CentOS都自带了一个gssftp服务，使用方式如下：</p> <p>[root@linux local]# cd /etc/xinetd.d<br /> [root@linux xinetd.d]# ls<br /> chargen cups-lpd daytime-udp echo-udp gssftp krb5-telnet rsync time-udp<br /> chargen-udp daytime echo eklogin klogin kshell time</p> <p>编辑gssftp文件，将server_args改为-l，将disable改为no：</p> <p>[root@linux xinetd.d]# vi gssftp</p> <p># default: off<br /> # description: The kerberized FTP server accepts FTP connections \<br /> # that can be authenticated with Kerberos 5.<br /> [...]]]></description>
			<content:encoded><![CDATA[<p>RedHat和CentOS都自带了一个gssftp服务，使用方式如下：</p>
<blockquote><p>[root@linux local]# cd /etc/xinetd.d<br />
[root@linux xinetd.d]# ls<br />
chargen      cups-lpd  daytime-udp  echo-udp  gssftp  krb5-telnet  rsync  time-udp<br />
chargen-udp  daytime   echo         eklogin   klogin  kshell       time</p></blockquote>
<p>编辑gssftp文件，将server_args改为-l，将disable改为no：</p>
<blockquote><p>[root@linux xinetd.d]# vi gssftp</p>
<p># default: off<br />
# description: The kerberized FTP server accepts FTP connections \<br />
#              that can be authenticated with Kerberos 5.<br />
service ftp<br />
{<br />
flags           = REUSE<br />
socket_type     = stream<br />
wait            = no<br />
user            = root<br />
server          = /usr/kerberos/sbin/ftpd<br />
#server_args    = -l -a<br />
server_args     = -l<br />
log_on_failure  += USERID<br />
#disable                = yes<br />
disable         = no<br />
}</p></blockquote>
<p>重启xinetd服务：</p>
<blockquote><p>[root@linux xinetd.d]# service xinetd restart<br />
Stopping xinetd: [  OK  ]<br />
Starting xinetd: [  OK  ]</p></blockquote>
<p>这时查看21端口已经打开：</p>
<blockquote><p>[root@linux xinetd.d]# netstat -tnlp<br />
Active Internet connections (only servers)<br />
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name<br />
tcp        0      0 0.0.0.0:21                  0.0.0.0:*                   LISTEN      22543/xinetd</p></blockquote>
<p>如果防火墙没有打开端口，则开放21端口并重启防火墙服务：</p>
<blockquote><p>[root@linux xinetd.d]# vi /etc/sysconfig/iptables</p>
<p>[root@linux xinetd.d]# service iptables restart<br />
Flushing firewall rules: [  OK  ]<br />
Setting chains to policy ACCEPT: filter [  OK  ]<br />
Unloading iptables modules: [  OK  ]<br />
Applying iptables firewall rules: [  OK  ]</p></blockquote>
<p>这样ftp服务就可用了，可以使用linux系统用户登录，不过gssftp不够安全，临时应急或内部使用可以，稳定的FTP服务还是建议使用<a href="http://www.banping.com/2009/06/23/linux_64_vsftpd/">vsftp</a>来搭建。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.banping.com/2010/01/12/linux_gssftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用script记录Linux用户的操作记录</title>
		<link>http://www.banping.com/2009/12/17/script_linux_log/</link>
		<comments>http://www.banping.com/2009/12/17/script_linux_log/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 13:54:34 +0000</pubDate>
		<dc:creator>banping</dc:creator>
				<category><![CDATA[主机及存储]]></category>

		<guid isPermaLink="false">http://www.banping.com/?p=570</guid>
		<description><![CDATA[<p>有时候我们需要记录Linux用户的操作记录用于审计，因此就要避免用户可以自行清除操作日志，一个简单的方式是使用script功能。</p> <p>首先在用户的profile文件中开启记录功能：</p> <p>[banping@linux ~]$ cd /home/banping/<br /> [banping@linux ~]$ vi .bash_profile<br /> # write log<br /> exec /usr/bin/script -a -f -q /tmp/test/script-`date +%Y%m%d%k%M`.lst</p> <p>这行脚本的意思是在/tmp/test目录下以时间为文件名来记录操作信息，由于是写在了.bash_profile文件中，用户登入到Linux系统的时候就会触发执行。</p> <p>然后我们在/tmp下建立test目录存放操作日志信息即可：</p> <p>[banping@linux tmp]# mkdir test</p> <p>这样就实现了记录的功能，而要防止用户自行修改，我们可以设置这些文件只能被附加，不能被修改或删除：</p> <p>[root@linux banping]# chattr +a .bash_profile</p> <p>[root@linux tmp]# chattr +a -R test</p> <p>这样登录用户就无法修改这些信息了，以下是一个简单的测试：</p> <p>[root@tomcat tmp]# cd test<br /> [root@tomcat test]# touch 1.txt<br /> [root@tomcat test]# rm [...]]]></description>
			<content:encoded><![CDATA[<p>有时候我们需要记录Linux用户的操作记录用于审计，因此就要避免用户可以自行清除操作日志，一个简单的方式是使用script功能。</p>
<p>首先在用户的profile文件中开启记录功能：</p>
<blockquote><p>[banping@linux ~]$ cd /home/banping/<br />
[banping@linux ~]$ vi .bash_profile<br />
# write log<br />
exec /usr/bin/script -a -f -q /tmp/test/script-`date +%Y%m%d%k%M`.lst</p></blockquote>
<p>这行脚本的意思是在/tmp/test目录下以时间为文件名来记录操作信息，由于是写在了.bash_profile文件中，用户登入到Linux系统的时候就会触发执行。</p>
<p>然后我们在/tmp下建立test目录存放操作日志信息即可：</p>
<blockquote><p>[banping@linux tmp]# mkdir test</p></blockquote>
<p>这样就实现了记录的功能，而要防止用户自行修改，我们可以设置这些文件只能被附加，不能被修改或删除：</p>
<blockquote><p>[root@linux banping]# chattr +a .bash_profile</p>
<p>[root@linux tmp]# chattr +a -R test</p></blockquote>
<p>这样登录用户就无法修改这些信息了，以下是一个简单的测试：</p>
<blockquote><p>[root@tomcat tmp]# cd test<br />
[root@tomcat test]# touch 1.txt<br />
[root@tomcat test]# rm 1.txt<br />
rm: remove regular empty file `1.txt'? y<br />
rm: cannot remove `1.txt': Operation not permitted<br />
[root@tomcat test]# cd ..<br />
[root@tomcat tmp]# chattr -a -R test<br />
[root@tomcat tmp]# cd test<br />
[root@tomcat test]# rm 1.txt<br />
rm: remove regular empty file `1.txt'? y</p></blockquote>
<p>结合<a href="http://www.banping.com/2009/11/16/linux_remote_logfile/" target="_blank">登录文件的安全保存</a>和防火墙功能，可以实现一个简单而完整的安全审计解决方案。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.banping.com/2009/12/17/script_linux_log/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Linux与网络相关的一些文件</title>
		<link>http://www.banping.com/2009/11/18/linux_network_file/</link>
		<comments>http://www.banping.com/2009/11/18/linux_network_file/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 08:31:57 +0000</pubDate>
		<dc:creator>banping</dc:creator>
				<category><![CDATA[主机及存储]]></category>

		<guid isPermaLink="false">http://www.banping.com/?p=556</guid>
		<description><![CDATA[<p>Linux的网络相关配置记录在了很多文件中，记录一下。</p> <p>查看网卡是否被内核识别：</p> <p>[root@linux ~]# dmesg&#124;grep -in eth<br /> 150:divert: not allocating divert_blk for non-ethernet device lo<br /> 239:divert: allocating divert_blk for eth0<br /> 240:e1000: eth0: e1000_probe: Intel(R) PRO/1000 Network Connection<br /> 366:divert: not allocating divert_blk for non-ethernet device sit0<br /> 389:ADDRCONF(NETDEV_UP): eth0: link is not ready<br /> 390:e1000: eth0: e1000_watchdog_task: NIC Link is Up 1000 [...]]]></description>
			<content:encoded><![CDATA[<p>Linux的网络相关配置记录在了很多文件中，记录一下。</p>
<p>查看网卡是否被内核识别：</p>
<blockquote><p>[root@linux ~]# dmesg|grep -in eth<br />
150:divert: not allocating divert_blk for non-ethernet device lo<br />
239:divert: allocating divert_blk for eth0<br />
240:e1000: eth0: e1000_probe: Intel(R) PRO/1000 Network Connection<br />
366:divert: not allocating divert_blk for non-ethernet device sit0<br />
389:ADDRCONF(NETDEV_UP): eth0: link is not ready<br />
390:e1000: eth0: e1000_watchdog_task: NIC Link is Up 1000 Mbps Full Duplex, Flow Control: None<br />
391:ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready<br />
394:eth0: no IPv6 routers present</p></blockquote>
<p>主机名称：</p>
<blockquote><p>[root@linux ~]# cat /etc/sysconfig/network<br />
NETWORKING=yes<br />
HOSTNAME=linux.banping.com</p></blockquote>
<p>网卡参数：</p>
<blockquote><p>[root@linux ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0<br />
DEVICE=eth0<br />
BOOTPROTO=none<br />
BROADCAST=172.16.0.255<br />
HWADDR=00:50:56:82:2F:49<br />
IPADDR=172.16.0.157<br />
NETMASK=255.255.255.0<br />
NETWORK=172.16.0.0<br />
ONBOOT=yes<br />
TYPE=Ethernet<br />
USERCTL=no<br />
IPV6INIT=no<br />
PEERDNS=yes<br />
GATEWAY=172.16.0.254</p></blockquote>
<p>开机加载网卡模块：</p>
<blockquote><p>[root@linux ~]# cat /etc/modprobe.conf<br />
alias eth0 e1000<br />
alias scsi_hostadapter mptbase<br />
alias scsi_hostadapter1 mptscsi<br />
alias scsi_hostadapter2 mptspi<br />
alias scsi_hostadapter3 mptsas<br />
alias scsi_hostadapter4 mptscsih<br />
alias scsi_hostadapter5 ata_piix</p></blockquote>
<p>DNS服务器：</p>
<blockquote><p>[root@linux ~]# cat /etc/resolv.conf<br />
search banping.com<br />
nameserver 172.16.0.1<br />
nameserver 172.16.0.3<br />
nameserver 172.16.0.5</p></blockquote>
<p>IP与主机对应：</p>
<blockquote><p>[root@linux ~]# cat /etc/hosts<br />
# Do not remove the following line, or various programs<br />
# that require network functionality will fail.<br />
172.16.0.157    linux.banping.com      localhost</p></blockquote>
<p>TCP/IP协议与端口的对应</p>
<blockquote><p>[root@linux ~]# cat /etc/services</p></blockquote>
<p>重启所有网络参数：</p>
<blockquote><p>[root@linux ~]# /etc/init.d/network restart<br />
Shutting down interface eth0:  [  OK  ]<br />
Shutting down loopback interface:  [  OK  ]<br />
Setting network parameters:  [  OK  ]<br />
Bringing up loopback interface:  [  OK  ]<br />
Bringing up interface eth0:  [  OK  ]</p></blockquote>
<p>启用网卡：</p>
<blockquote><p>[root@linux ~]# ifup eth0</p></blockquote>
<p>停用网卡（慎用，否则可能导致你再也连不上了）：</p>
<blockquote><p>[root@linux ~]# ifdown eth0</p></blockquote>
<p>测试网卡：</p>
<blockquote><p>[root@linux ~]# ifconfig eth0<br />
eth0      Link encap:Ethernet  HWaddr 00:50:56:82:2F:49<br />
inet addr:172.16.0.157  Bcast:172.16.0.255  Mask:255.255.255.0<br />
inet6 addr: fe80::250:56ff:fe82:2f49/64 Scope:Link<br />
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1<br />
RX packets:506414 errors:0 dropped:0 overruns:0 frame:0<br />
TX packets:1691 errors:0 dropped:0 overruns:0 carrier:0<br />
collisions:0 txqueuelen:1000<br />
RX bytes:140448492 (133.9 MiB)  TX bytes:200009 (195.3 KiB)</p></blockquote>
<p>设置IP地址：</p>
<blockquote><p>[root@linux ~]# ifconfig eth0 172.16.0.157</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.banping.com/2009/11/18/linux_network_file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

