Press "Enter" to skip to content

作者: kiccleaf

CentOS 5.6 X86_64系统下Vsftpd.conf配置

安装方式可以直接用光盘安装时自带的vsftp或是采用yum,也可以采用源码编译。安装过程就不讲了。直接配置文件
首先操作备份文件及创建一个vsftpd.conf文件

[root@kiccleaf]# adduser leaf
[root@kiccleaf]# passwd leaf
Changing password for user leaf.
New UNIX password: #输入新密码
Retype new UNIX password: #输入重复密码
passwd: all authentication tokens updated successfully.

[root@kiccleaf]# mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak
[root@kiccleaf]# vim /etc/vsftpd/vsftpd.conf

vsftpd.conf配置文件内容如下:

anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
chroot_list_enable=Yes
userlist_enable=Yes
userlist_deny=No
pasv_enable=YES
pasv_min_port=65000
pasv_max_port=65100
use_localtime=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/user_list

添加leaf用户至user_list文件中,使leaf用户可以登陆ftp

[root@kiccleaf]# echo leaf >> /etc/vsftpd/user_list  #添加leaf用户可以登陆的ftp
[root@kiccleaf]#  service vsftpd restart  #重启vsftpd
Leave a Comment

FreeBSD8.2中用axel提高ports的安装速度

提升ports下载速度实现多线程。

首先到
cd /usr/ports/ftp/axel 之后 make install clean

安装完成后把/etc/make.conf文件编辑如下:

FETCH_CMD=axel
FETCH_BEFORE_ARGS= -n 10 -a
FETCH_AFTER_ARGS=
DISABLE_SIZE=yes

其次添加下载源地址,不用去国外下载

MASTER_SITE_FREEBSD_ORG= ftp://ftp.cn.FreeBSD.org/pub/FreeBSD/%SUBDIR%/
MASTER_SITE_GNOME=  http://mirrors.geekbone.org/gnome/%SUBDIR%/
MASTER_SITE_LOCAL=  ftp://ftp.cn.FreeBSD.org/pub/FreeBSD/ports/local-distfiles/%SUBDIR%/
MASTER_SITE_OVERRIDE=ftp://ftp.cn.freebsd.org/pub/FreeBSD/ports/distfiles/${DIST_SUBDIR}/
Leave a Comment

FreeBSD8.2下vsftp安装配置

由于涉及FTP到解决方案,特别在FreeBSD8.2下采用ports部署vsftp,配置如下:

先创建用户:leaf 密码:123456  采用adduser命令添加此用户,关于添加用户另一章中已经有介绍。

kiccleaf# cd /usr/ports/ftp/vsftpd
kiccleaf# make install clean

可以不用选择
Options for vsftpd 2.3.4 x

===> Compressing manual pages for vsftpd-2.3.4
===> Registering installation for vsftpd-2.3.4
===> SECURITY REPORT:
This port has installed the following files which may act as network
servers and may therefore pose a remote security risk to the system.
/usr/local/libexec/vsftpd

If there are vulnerabilities in these programs there may be a security
risk to the system. FreeBSD makes no guarantee about the security of
ports included in the Ports Collection. Please type 'make deinstall'
to deinstall the port if this is a concern.

For more information, and contact details about the security
status of this software, see the following webpage:
http://vsftpd.beasts.org/
kiccleaf#

防止修改错误先备份vsftpd.conf文件

kiccleaf# mv /usr/local/etc/vsftpd.conf /usr/local/etc/vsftpd.conf.bak
kiccleaf# ee/usr/local/etc/vsftpd.conf

在新建文件vsftpd.conf输入以下代码内容:

anonymous_enable=NO
write_enable=YES
local_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
data_connection_timeout=3
nopriv_user=nobody
listen=YES
secure_chroot_dir=/usr/local/share/vsftpd/empty
chroot_local_user=YES
tcp_wrappers=Yes
userlist_enable=Yes
userlist_deny=No
pasv_enable=Yes
pasv_min_port=65000
pasv_max_port=65100
userlist_file=/usr/local/etc/vsftpd.user_list

创建一个文件,添加可登陆的FTP用户

kiccleaf# echo leaf >> /usr/local/etc/vsftpd.user_list
kiccleaf# cd /usr/local/etc/
kiccleaf# ll
total 32
-rw-r--r--  1 root  wheel  3770 Jul 12 17:39 axelrc
drwxr-xr-x  2 root  wheel   512 Jul 12 17:12 devd
drwxr-xr-x  2 root  wheel   512 Jul 12 17:12 man.d
drwxr-xr-x  2 root  wheel   512 Jul 12 17:12 pam.d
drwxr-xr-x  2 root  wheel   512 Jul 12 18:39 rc.d
-r--r--r--  1 root  wheel  5010 Jul 12 21:22 vsftpd.conf
-r--r--r--  1 root  wheel  4586 Jul 12 21:20 vsftpd.conf.dist
-rw-r--r--  1 root  wheel     1 Jul 12 21:23 vsftpd.user_list
-r--r--r--  1 root  wheel  4499 Jul 12 17:37 wgetrc.sample
kiccleaf# cat /usr/local/etc/vsftpd.user_list
leaf  #刚执行添加的用户leaf
kiccleaf# /usr/local/libexec/vsftpd &
[1] 1952

添加到随系统启动项中

kiccleaf# echo vsftp_ebable=YES >>/etc/rc.conf

回去Win下采用FlashFxp进行链接测试


链接成功后

Leave a Comment

FreeBSD直接可以用命令升级,比如将FreeBSD8.1升级成FreeBSD8.2[原创]

升级FreeBSD系统FreeBSD8.1升级成FreeBSD8.2的操作过程

kiccleaf# uname -a
FreeBSD qm.w 8.1-RELEASE FreeBSD 8.1-RELEASE #0: Fri Feb 18 02:24:46 UTC 2011     root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
kiccleaf# freebsd-update -r 8.2-RELEASE upgrade
Looking up update.FreeBSD.org mirrors... 4 mirrors found.
Fetching metadata signature for 8.1-RELEASE from update5.FreeBSD.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files... done.
Inspecting system... done.

The following components of FreeBSD seem to be installed:
kernel/generic world/base

The following components of FreeBSD do not seem to be installed:
src/base src/bin src/cddl src/contrib src/crypto src/etc src/games
src/gnu src/include src/krb5 src/lib src/libexec src/release src/rescue
src/sbin src/secure src/share src/sys src/tools src/ubin src/usbin
world/catpages world/dict world/doc world/games world/info
world/manpages world/proflibs

Does this look reasonable (y/n)? y

Fetching metadata signature for 8.2-RELEASE from update5.FreeBSD.org... done.
Fetching metadata index... done.
Fetching 1 metadata patches. done.
Applying metadata patches... done.
Fetching 1 metadata files... done.
Inspecting system... done.
Fetching files from 8.1-RELEASE for merging... done.
Preparing to download files... done.
Fetching 5591
60....5570....5580....5590 done.
Applying patches... done.
Fetching 47 files... done.
Attempting to automatically merge changes in files... done.
kiccleaf# freebsd-update install
Installing updates...
Kernel updates have been installed.  Please reboot and run
"/usr/sbin/freebsd-update install" again to finish installing updates.

记住以下这两步不可少,否则远程登陆不了就要跑机房咯
第一步:先更新一下ssh

kiccleaf# vi /etc/ssh/sshd_config

Port 22
PermitRootLogin no
PubkeyAuthentication yes
AuthorizedKeysFile    .ssh/id_dsa.pub
PasswordAuthentication no
PermitEmptyPasswords no

第二步:把配置ssh随系统启动

kiccleaf# cat /etc/rc.conf

sshd_enable="YES"

kiccleaf# shutdown -r now
kiccleaf# uname -a
FreeBSD qm.w 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Fri Feb 18 02:24:46 UTC 2011     root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
Leave a Comment

修改phpMyAdmin使其能够管理多台远程MySQL服务器[原创]

因为最近采用多数据维护和操作,每个数据库安装一个phpmyadmin不太现实也太繁琐。所以就对phpmyadmin进行修改实现了多mysql数据库管理的方法

经过测试版本:phpMyAdmin 3.3.5-rc1、phpMyAdmin3.4.3.1

修改方法:

第一步:打开/phpmyadmin/libraries 目录

第二步:修改config.default.php 文件(linux下可用vim编辑,FreeBSD下可用vi或是ee编辑)找到“AllowArbitraryServer
代码内容

$cfg['AllowArbitraryServer'] = false;
修改成:
$cfg['AllowArbitraryServer'] = true;

第三步:保存后去浏览器输入地址http://youdomain.com/phpmyadmin/
查看结果:

phpmyadmin登陆界面
phpmyadmin登陆界面
Leave a Comment

FreeBSD 8.2下SSH配置KEY登陆

首先我们找到系统下/etc/ssh/sshd_config 文件并用 ee /etc/ssh/sshd_config 打开内容如下:

# $OpenBSD: sshd_config,v 1.80 2008/07/02 02:24:18 djm Exp $
# $FreeBSD: src/crypto/openssh/sshd_config,v 1.49.2.1.2.1 2009/10/25 01:10:29 kensmith
Exp $
# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options change a
# default value.
# Note that some of FreeBSD's defaults differ from OpenBSD's, and
# FreeBSD has a few additional options.
#VersionAddendum FreeBSD-20090522
Port 222  #可修改端口号,防止攻击,默认为22端口
#Protocol 2
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
# Disable legacy (protocol version 1) support in the server for new
# installations. In future the default will change to require explicit
# activation of protocol 1
Protocol 2
# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024
# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO
# Authentication:
#LoginGraceTime 2m
PermitRootLogin no    #是否允许ROOT用户直接登陆系统 yes  是  no 否
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#RSAAuthentication yes
#PubkeyAuthentication yes
AuthorizedKeysFile .ssh/id_dsa.pub  #修改使用用户目录下KEY公共文件
# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes
# Change to yes to enable built-in password authentication.
#修改可以密码进行登陆
PasswordAuthentication no     # 不允许用户使用密码方式登录
PermitEmptyPasswords no       # 禁止空密码的用户进行登录
# Change to no to disable PAM authentication
#ChallengeResponseAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
# Set this to 'no' to disable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none
# no default banner path
#Banner none
# override default of no subsystems
Subsystem sftp /usr/libexec/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server
OK,以上SSH配置修改完成!进行重启SSH服务,
leaf# /etc/rc.d/sshd restart
Stopping sshd.
Starting sshd.
进入下一步生成Key
leaf# ssh-keygen -t dsa   输入生成语句
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):  # 默认回车即可,或是选择你要存放的位置
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):  #输入密匙的密码
Enter same passphrase again:     #再次输入密匙的密码
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
11:d6:63:26:84:fc:4f:6d:c3:9a:fa:50:ff:08:f4:0b root@leaf
The key's randomart image is:
+--[ DSA 1024]----+
|     . o+.       |
|      o...=      |
|       ..+ +     |
|        ... =    |
|        Soo+ .   |
|         o+o     |
|        ..E o    |
|        .. o +   |
|         .. o .  |
+-----------------+
leaf# ll /root/  #查看root目录是否生成了.ssh目录
total 16
-rw-r--r--  2 root  wheel   812 Mar  9 06:53 .cshrc
-rw-------  1 root  wheel  2369 Mar 10 07:26 .history
-rw-r--r--  1 root  wheel   155 Nov 21 22:57 .k5login
-rw-r--r--  1 root  wheel   303 Nov 21 22:57 .login
-rw-------  1 root  wheel   332 Feb  4 00:55 .mysql_history
-rw-r--r--  2 root  wheel   265 Nov 21 22:57 .profile
drwx------  2 root  wheel   512 Mar 12 06:37 .ssh
leaf# ll /root/.ssh/  #查看.ssh目录下是否有id_dsa 和id_dsa.pub 两个文件
total 4
-rw-------  1 root  wheel  736 Mar 12 06:37 id_dsa      #确认私钥已经建立
-rw-r--r--  1 root  wheel  603 Mar 12 06:37 id_dsa.pub  #确认公钥已经建立

接下去下载id_dsa 文件,并配置到相应的用户SSH登陆软件中。记住下载完id_dsa文件后,记得删除id_dsa文件!
执行以下操作:
leaf# rm -r id_dsa
Leave a Comment

防火墙日常操作记录

[root@kiccleaf home]# iptables -F 清除预设表filter 中的所有规则链的规则
[root@kiccleaf home]# iptables -X 清除预设表filter 中使用者自定链中的规则
[root@kiccleaf home]# /etc/rc.d/init.d/iptables save 保存当前操作
将当前规则保存到 /etc/sysconfig/iptables: [确定]
[root@kiccleaf home]# service iptables restart 重启防火墙
清除防火墙规则: [确定]
把 chains 设置为 ACCEPT 策略:filter [确定]
正在卸载 Iiptables 模块: [确定]
应用 iptables 防火墙规则: [确定]
载入额外 iptables 模块:ip_conntrack_netbios_ns [确定]
[root@kiccleaf home]# iptables -L -n 查看防火墙规则(已经全部清除)
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
远程SSH 登陆,我们要开启22 端口
[root@kiccleaf home]# iptables -A INPUT -p tcp --dport 22 -j ACCEPT
[root@kiccleaf home]# iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
如果做了WEB 服务器,开启80 端口
[root@kiccleaf home]# iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
[root@kiccleaf home]# iptables -A INPUT -p tcp --dport 80 -j ACCEPT
如果做了FTP 服务器,开启21 端口
[root@kiccleaf home]# iptables -A INPUT -p tcp --dport 21 -j ACCEPT
[root@kiccleaf home]# iptables -A INPUT -p tcp --dport 20 -j ACCEPT
允许icmp 包通过,也就是允许ping
[root@kiccleaf home]# iptables -A OUTPUT -p icmp -j ACCEPT
[root@kiccleaf home]# iptables -A INPUT -p icmp -j ACCEPT
允许loopback!(不然会导致DNS 无法正常关闭等问题)
[root@kiccleaf home]# iptables -A INPUT -i lo -p all -j ACCEPT
[root@kiccleaf home]# iptables -A OUTPUT -o lo -p all -j ACCEPT
减少不安全的端口连接
[root@kiccleaf home]# iptables -A OUTPUT -p tcp --sport 31337 -j DROP
[root@kiccleaf home]# iptables -A OUTPUT -p tcp --dport 31337 -j DROP
drop 非法连接
[root@kiccleaf home]# iptables -A INPUT -m state --state INVALID -j DROP
[root@kiccleaf home]# iptables -A OUTPUT -m state --state INVALID -j DROP
[root@kiccleaf home]# iptables -A FORWARD -m state --state INVALID -j DROP
允许所有已经建立的和相关的连接
[root@kiccleaf home]# iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
[root@kiccleaf home]# iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
[root@kiccleaf home]# /etc/rc.d/init.d/iptables save
将当前规则保存到 /etc/sysconfig/iptables: [确定]
[root@kiccleaf home]# service iptables restart
清除防火墙规则: [确定]
把 chains 设置为 ACCEPT 策略:filter [确定]
正在卸载 Iiptables 模块: [确定]
应用 iptables 防火墙规则: [确定]
载入额外 iptables 模块:ip_conntrack_netbios_ns [确定]

Leave a Comment

五种开源协议的比较(BSD,Apache,GPL,LGPL,MIT) – 整理

在查看开源发布需要选择的几种协议之后稍加整理了一些内容以供参考。

现今存在的开源协议很多,而经过Open Source Initiative组织通过批准的开源协议目前有58种(http://www.opensource.org/licenses/alphabetical)。我们在常见的开源协议如BSD, GPL, LGPL,MIT等都是OSI批准的协议。如果要开源自己的代码,最好也是选择这些被批准的开源协议。

这里我们来看四种最常用的开源协议及它们的适用范围,供那些准备开源或者使用开源产品的开发人员/厂家参考。

BSD开源协议(original BSD licenseFreeBSD licenseOriginal BSD license

BSD开源协议是一个给于使用者很大自由的协议。基本上使用者可以”为所欲为”,可以自由的使用,修改源代码,也可以将修改后的代码作为开源或者专有软件再发布。

但”为所欲为”的前提当你发布使用了BSD协议的代码,或则以BSD协议代码为基础做二次开发自己的产品时,需要满足三个条件:

  1. 如果再发布的产品中包含源代码,则在源代码中必须带有原来代码中的BSD协议。
  2. 如果再发布的只是二进制类库/软件,则需要在类库/软件的文档和版权声明中包含原来代码中的BSD协议。
  3. 不可以用开源代码的作者/机构名字和原来产品的名字做市场推广。

BSD 代码鼓励代码共享,但需要尊重代码作者的著作权。BSD由于允许使用者修改和重新发布代码,也允许使用或在BSD代码上开发商业软件发布和销售,因此是对 商业集成很友好的协议。而很多的公司企业在选用开源产品的时候都首选BSD协议,因为可以完全控制这些第三方的代码,在必要的时候可以修改或者二次开发。

Apache Licence 2.0(Apache License, Version 2.0Apache License, Version 1.1Apache License, Version 1.0

Apache Licence是著名的非盈利开源组织Apache采用的协议。该协议和BSD类似,同样鼓励代码共享和尊重原作者的著作权,同样允许代码修改,再发布(作为开源或商业软件)。需要满足的条件也和BSD类似:

  1. 需要给代码的用户一份Apache Licence
  2. 如果你修改了代码,需要再被修改的文件中说明。
  3. 在延伸的代码中(修改和有源代码衍生的代码中)需要带有原来代码中的协议,商标,专利声明和其他原来作者规定需要包含的说明。
  4. 如果再发布的产品中包含一个Notice文件,则在Notice文件中需要带有Apache Licence。你可以在Notice中增加自己的许可,但不可以表现为对Apache Licence构成更改。

Apache Licence也是对商业应用友好的许可。使用者也可以在需要的时候修改代码来满足需要并作为开源或商业产品发布/销售。

GPL(GNU General Public License

我们很熟悉的Linux就是采用了GPL。GPL协议和BSD, Apache Licence等鼓励代码重用的许可很不一样。GPL的出发点是代码的开源/免费使用和引用/修改/衍生代码的开源/免费使用,但不允许修改后和衍生的代 码做为闭源的商业软件发布和销售。这也就是为什么我们能用免费的各种linux,包括商业公司的linux和linux上各种各样的由个人,组织,以及商 业软件公司开发的免费软件了。

GPL协议的主要内容是只要在一个软件中使用(“使用”指类库引用,修改后的代码或者衍生代码)GPL 协议的产品,则该软件产品必须也采用GPL协议,既必须也是开源和免费。这就是所谓的”传染性”。GPL协议的产品作为一个单独的产品使用没有任何问题,还可以享受免费的优势。

由于GPL严格要求使用了GPL类库的软件产品必须使用GPL协议,对于使用GPL协议的开源代码,商业软件或者对代码有保密要求的部门就不适合集成/采用作为类库和二次开发的基础。

其它细节如再发布的时候需要伴随GPL协议等和BSD/Apache等类似。

LGPL(GNU Lesser General Public License

LGPL是GPL的一个为主要为类库使用设计的开源协议。和GPL要求任何使用/修改/衍生之GPL类库的的软件必须采用GPL协议不同。LGPL 允许商业软件通过类库引用(link)方式使用LGPL类库而不需要开源商业软件的代码。这使得采用LGPL协议的开源代码可以被商业软件作为类库引用并 发布和销售。

但是如果修改LGPL协议的代码或者衍生,则所有修改的代码,涉及修改部分的额外代码和衍生的代码都必须采用LGPL协议。因此LGPL协议的开源 代码很适合作为第三方类库被商业软件引用,但不适合希望以LGPL协议代码为基础,通过修改和衍生的方式做二次开发的商业软件采用。

GPL/LGPL都保障原作者的知识产权,避免有人利用开源代码复制并开发类似的产品

MIT(MIT

MIT是和BSD一样宽范的许可协议,作者只想保留版权,而无任何其他了限制.也就是说,你必须在你的发行版里包含原许可协议的声明,无论你是以二进制发布的还是以源代码发布的.

Leave a Comment

iptables防火墙配置脚本

本人日常使用的防火墙规则,为了方便部署,特意写成了一个脚本。有需要的朋友可以复制下面的内容保存成如 iptable_install.sh 文件然后再执行。
代码:

#!/bin/bash
# Check if user is root
if [ $(id -u) != "0" ]; then
echo "Error: You must be root to run this script, use sudo sh $0"
exit 1
fi
echo "过虑蠕虫病毒"
/sbin/iptables -A FORWARD -p tcp --dport 4444 -j DROP
/sbin/iptables -A FORWARD -p udp --dport 4444 -j DROP
/sbin/iptables -A FORWARD -p tcp --dport 445 -j DROP
/sbin/iptables -A FORWARD -p udp --dport 445 -j DROP
/sbin/iptables -A FORWARD -p tcp --dport 69 -j DROP
/sbin/iptables -A FORWARD -p udp --dport 69 -j DROP
/sbin/iptables -A FORWARD -p tcp --dport 135 -j DROP
/sbin/iptables -A FORWARD -p udp --dport 135 -j DROP
/sbin/iptables -A FORWARD -p tcp --dport 139 -j DROP
/sbin/iptables -A FORWARD -p udp --dport 139 -j DROP
echo "远程SSH,WEB,FTP"
/sbin/iptables -A INPUT -p tcp --dport 22 -j ACCEPT
/sbin/iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT
/sbin/iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 21 -j ACCEPT
/sbin/iptables -A INPUT -p tcp --dport 20 -j ACCEPT
/sbin/iptables -A OUTPUT -p icmp -j ACCEPT
/sbin/iptables -A INPUT -p icmp -j ACCEPT
/sbin/iptables -A INPUT -i lo -p all -j ACCEPT
/sbin/iptables -A INPUT -i lo -p all -j ACCEPT
/sbin/iptables -A OUTPUT -o lo -p all -j ACCEPT
#关闭木马程序BO2000的默认服务端口
#禁止31337端口发送TCP包
/sbin/iptables -A OUTPUT -p tcp --sport 31337 -j DROP
#禁止朝其他机器的31337发送包
/sbin/iptables -A OUTPUT -p tcp --dport 31337 -j DROP
/sbin/iptables -A INPUT -m state --state INVALID -j DROP
/sbin/iptables -A OUTPUT -m state --state INVALID -j DROP
/sbin/iptables -A FORWARD -m state --state INVALID -j DROP
/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
/sbin/iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#不转发不正常的包
/sbin/iptables -A FORWARD -m conntrack --ctstate INVALID -j DROP
#连续接受10个PING包以后,限制每秒只接受1个PING包
/sbin/iptables -A INPUT -p icmp -m limit --limit 1/sec --limit-burst 10 -j ACCEPT
#连续转发10个PING包以后,限制每秒只转发1个PING包
/sbin/iptables -A FORWARD -p icmp -m limit --limit 1/sec --limit-burst 10 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables restart
有需要脚本的请点下面链接下载

我的sh脚本

Leave a Comment

IPTABLES配置过虑蠕虫病毒

我的配置清单

#444/445/69/135/139
iptables -A FORWARD -p tcp --dport 4444 -j DROP
iptables -A FORWARD -p udp --dport 4444 -j DROP
iptables -A FORWARD -p tcp --dport 445 -j DROP
iptables -A FORWARD -p udp --dport 445 -j DROP
iptables -A FORWARD -p tcp --dport 69 -j DROP
iptables -A FORWARD -p udp --dport 69 -j DROP
iptables -A FORWARD -p tcp --dport 135 -j DROP
iptables -A FORWARD -p udp --dport 135 -j DROP
iptables -A FORWARD -p tcp --dport 139 -j DROP
iptables -A FORWARD -p udp --dport 139 -j DROP
最后不要忘记保存
/etc/rc.d/init.d/iptables save
重启生效
/etc/init.d/iptables restart

Leave a Comment