Archive for 2009年五月月

ubuntu中退出Compiz

五月 23, 2009

metacity –replace  or  ‘kwin –replace &;’

Shifting the order of the titlebar buttons
The installation script will move the “traffic lights”, the minimize, maximize
and close buttons, on the left hand side of the titlebar in Metacity
(instructions for using the Emerald/Compiz Fusion theme appear in Section
3). If you want to make the change manually, press Alt+F2 and type in gconf-editor.
Press Enter or click Run and a new window should appear. In the sidebar, go to / →
apps → metacity → general. Back on the right hand side, double click on
button_layout. Delete the value that’s there and type in
menu:minimize,maximize,close. Then Click OK and close the application
Configuration Editor. The buttons will now be on the left side of titlebar. To restore
the buttons to the original layout, just replace the string with
close,minimize,maximize:menu.

PHP 开发工具

五月 18, 2009

编程工具

phpdesigner, Komodo IDE, PhpEdit, Netbeans, Eclipse PDT, ZendStudio,Emacs、KVIM、Arachnophilia、Bluefish、NEdit、Gedit、Kate、Quanta Plus

调试工具

zend debugger, xdebugger

Profiling 工具

Kcachegrind

ubuntu中安装PHP,Apache,MySQL

五月 18, 2009

1、安装Apache服务
sudo apt-get install apache2

然后按照提示即完成apahce的安装了。这里 可以打开http://127.0.0.1,即可看于是It works

首先我直接用apt-get安装了apache2,php5,pear以及mysql5, 为了方便后续的安装,还加上了make和libmysqlclient

sudo apt-get install apache2-mpm-prefork
sudo apt-get install php5 ,php-xml-parser php-fpdf php-image-graph

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl php5-xmlrpc

sudo apt-get install php-soap

sudo apt-get install php5-dev
sudo apt-get install php5-pear
sudo apt-get install mysql-server-5.0
sudo apt-get install make
sudo apt-get install libmysqlclient15-dev
pdo在ubuntu的apt里头似乎还找不到安装源,所以通过pecl来安装这个扩展,非常简单 —- 如果海底光纤能连通的话:

pecl install pdo

增加一行:

extension=pdo.so

到文件:

/etc/php/apache2/php.ini
/etc/php/cli/php.ini

接下来安装pdo_mysql碰到一些问题, 直接跑pecl install pecl_mysql会出现一些错误,搜索了一下发现是pecl本身的问题,下面是个比较简单的解决办法:

wgethttp://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz
tar xzvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2

注释掉configure里头判断是否已经安装pdo扩展的代码片段,继续跑:

phpize
./configure
make
make install

然后再次添加下面一行到前面提到的两个php.ini

extension=pdo_mysql.so

重启apache之后, php5 + pdo_mysql就在ubuntu上安装好了, documentroot是/var/www

后记
更简单的解决办法是运行:

PHP_PDO_SHARED=1 pecl install pdo_mysql

2、安装php5
sudo apt-get install php5 php5-gd php-pear

#apt-get install curl php5-url php5-mcrypt
sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart

OK之后,我们来查看一下是否生效了。
gksudo gedit /var/www/testphp.php

入探针
保存运行
http://127.0.0.1/testphp.php

3、安装mysql
sudo apt-get install mysql-server

安装完成按提示设置root密

4、让apache、php支持mysql
sudo apt-get install libapache2-mod-auth-mysql
sudo apt-get install php5-mysqlsudo /etc/init.d/apache2 restart

至此apache2+php 5.2.4.2+mysql5.0.51的环境就完成了。

1.Ubuntu 8.04下安装LAMP
系统->系统管理->新立得软件包管理器, 打开新立得,编辑 –> 使用任务分组标记软件包 –> 勾选 LAMP Server。

安装过程中会提示设置mysql的root用户的密码。

配置文件在/etc/apache2目录

在/etc/apache2/httpd.conf加入一行:ServerName 127.0.0.1

2.Ubuntu 8.04下安装phpmyadmin
sudo apt-get install phpmyadmin

安装后在/etc/apache2/conf.d目录自动创建虚拟目录配置文件phpmyadmin.conf

安装后直接输入http://localhost/phpmyadmin登录,创建一个wpmu数据库

3.启动mod_rewrite模块
sudo a2enmod rewrite

4.Ubuntu 8.04下安装WPMU
(1)从官方主页下载WPMU,解压到~/blog目录(/home//blog)

(2)修改目录属性:chmod 755 /home//blog /home//blog/wp-content

(3)配置WPMU虚拟目录。修改/etc/apache2/httpd.conf或者在/etc/apache2/conf.d创建wpmu.conf文件,加入如下内容:

Alias /blog /home//blog
/blog>
Options Indexes FollowSymLinks
DirectoryIndex index.php
AllowOverride FileInfo Options
(4)修改/etc/hosts文件(因为wpmu必须采用域名格式)

修改127.0.0.1 localhost
127.0.0.1 www.my.com my.com localhost

(5)在firefox输入:http://my.com/blog。安装WPMU

OK。
(UMELINK原创)

Ubuntu php 环境简单配置备忘(二/成功)

一、安装apache2+php5+mysql
sudo apt-get install apache2 php5-mysql libapache2-mod-php5 mysql-server
二、设置mysql密码
mysqladmin -u root password 新密码

三、安装phpmyadmin
sudo apt-get install phpmyadmin
测试:http://localhost/phpmyadmin/

Installation in ubuntu 8.04 phpmyadmin

1)apt-get install phpmyadmin

2)sudo gedit /etc/apache2/apache2.conf

3)Add the following line of code inside apache2.conf:
Include /etc/phpmyadmin/apache.conf

4)Now restart Apache:
sudo /etc/init.d/apache2 restart

四、其它操作:
编辑测试页:()
sudo gedit /var/www/testphp.php

启动Apache
$ sudo /usr/sbin/apache2ctl start
停止Apache
$ sudo /usr/sbin/apache2ctl stop
重启Apache
$ sudo /etc/init.d/apache2 restart

如果只是用于本地开发,加强安全性,设置如下:
$ gksudo “gedit /etc/apache2/ports.conf”
$ password:
更改ports.conf
Listen 127.0.0.1:80
保存文件之后,并重启apache。这时,只有通过127.0.0.1才能访问Apache。

安装包

/etc/apt/sources.list file.

deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all
# apt-get update

install MySQL4

# apt-get install mysql-server-4.1 mysql-client-4.1 libmysqlclient14-dev

install MySQL5

# apt-get install mysql-server-5.0 mysql-client-5.0 libmysqlclient15-dev

Set a root MySQL password like this:

# mysqladmin -u root password yourrootsqlpassword

Debian provides a fastcgi enabled version of PHP.

# apt-get install php4-cgi
# apt-get install php5-cgi

Other php5 package

php5-curl php5-gd php5-imap php5-mhash, php5-xdebug
php5-pear php5-dev php5-ming php5-common
php5-cli php5-pspell php5-odbc php5-mcrypt
php5-tidy php5-ldap php5-gmp php5-snmp
php5-sybase php5-mysql php5-mysqli php5-pgsql
# apt-get install php5-cgi libgdmg1 php5-curl php5-gd

php.ini

Add cgi.fix_pathinfo = 1

ubuntu 中flash中文乱码的解决

五月 17, 2009

ubuntu/linux flash中文乱码 的解决
打开配置文件:
cd /etc/fonts/conf.d/
sudo gedit 49-sansserif.conf

修改edit节点,将<string>sans-serif</string>
改为 <string>sans</string>

<match target=”pattern”>
<test qual=”all” name=”family” compare=”not_eq”>
<string>sans-serif</string>
</test>
<test qual=”all” name=”family” compare=”not_eq”>
<string>serif</string>
</test>
<test qual=”all” name=”family” compare=”not_eq”>
<string>monospace</string>
</test>
<edit name=”family” mode=”append_last”>
<string>sans-serif</string> 这里改为<— <string>sans</string>
</edit>
</match>
ubuntu装好之后, 为浏览器firefox安装flash插件, 后来发现中文会变成方框。

如何解决?

输入:
cd /etc/fonts/conf.d/

为了安全,备份一下:

sudo cp 49-sansserif.conf 49-sansserif.conf_backup

输入如下指令:

sudo gedit ./49-sansserif.conf

此时文件显示内容。

将其中的第1、2、4个后面的sans-serif或者serif用你自己系统中支持中文的字体的名字代替,注意字体名字的大小写

比如:我的系统中安装了微软雅黑,我则用微软雅黑代替上述所说的字段,结果如下:

<match target=”pattern”>
<test qual=”all” name=”family” compare=”not_eq”>
<string>微软雅黑</string>
</test>
<test qual=”all” name=”family” compare=”not_eq”>
<string>微软雅黑</string>
</test>
<test qual=”all” name=”family” compare=”not_eq”>
<string>monospace</string>
</test>
<edit name=”family” mode=”append_last”>
<string>微软雅黑</string>
</edit>
</match>

Php Xdebug extension

五月 15, 2009

The Xdebug extension helps you debugging your script by providing a lot of valuable debug information. The debug information that Xdebug can provide includes the following:

  • stack traces and function traces in error messages with:
    • full parameter display for user defined functions
    • function name, file name and line indications
    • support for member functions
  • memory allocation
  • protection for infinite recursions

Xdebug also provides:

PECL Installation

As of Xdebug 0.9.0 you can install Xdebug through PEAR/PECL. This only works with with PEAR version 0.9.1-dev or higher and some UNIX.

Installing with PEAR/PECL is as easy as:

# pecl install xdebug

but you still need to add the correct line to your php.ini: (don’t forget to change the path and filename to the correct one — but make sure you use the full path)

zend_extension="/usr/local/php/modules/xdebug.so"Xdebug is incompatible with the Zend Optimizer and Zend Studio   Debugger extensions. If these extensions are enabled in   php.ini, they will not be imported into the copy created   by Komodo for debugging. When configuring Remote PHP Debugging, these extensions   should be manually commented out in php.ini.

Komodo 安装

五月 11, 2009

今年jolt获奖的软件,专攻动态语言,想要一个python IDE,于是开始感兴趣起来。

http://www.activestate.com/Products/Komodo/?tn=1下载试用版

在它的网页上注册得到一个20天的License文件。

将试用版解压缩到一个目录
tar zxvf komodo-professional-3.5.2-227956-linux-libcpp5-ix86.tar.gz

进入目录执行

sudo install.sh

缺省安装是/opt/Komodo

安装完成后执行
/opt/Komodo-3.5/bin/komodo -v

会提示段错误,无法运行。网上好多人都说有BUG.分析一下,还是SCIM捣乱。

sudo vi /opt/Komodo-3.5/bin/komodo

第二行加上:GTK_IM_MODULE=xim

存盘退出。

将邮件得到的License权限改为755
chmod chmod 755 EvalLicense-KomodoProfessional-Linux

执行一下。会在 ~/.ActiveState/下生成一个ActiveState.lic文件。

将~/.komodo 改成你当前用户:
sudo chown <user>:<group> -R .komodo

好了,现在进入 应用程序-》编程
发现有一个ActiveState Comodo 3.5
执行,就可以了。

这是个试用版的License.如果购买了正版的Lic文件。直接拷贝到~/.ActiveState/下即可。

功能很强大,尤其python GUI Builder.太舒服了。可惜太贵了。。。

备份KOMODO 的配置文件

KOMODO IDE是我使用的比较多的一款IDE开发工具,不过基本上除了用它编写PERL外,还没做过其它代码的编写。
通常的,当我们费力把一个开发工具的配置做到自己满意的时候,如果不能把这些配置文件导出或者备份,也就意味着如果你的机器重装或者想在两台机器上使用同样的配置话,你就不得不在花时间来处理这些重复的事。
IDE上我是没有找到导出配置的选项的,所以我只能寻找配置文件覆盖的方法来做。
KOMODO 的个人配置文件其实是放在C:\Documents and Settings\你安装KOMODO时所用的账户\Application Data\ActiveState下的。不过你在该目录下可能看到多个KOMODO的版本号目录,这些我们都不用管,你只需要找到你目前使用KOMODO 的版本,进入后会找到一个名为schemes的目录,如果你自己定义过配置文件的话,目录下会有相对应的文件,例如.kkf的文件是你的热键配置, 而.ksf则是你的风格配置。有了这些,下步你该知道怎么做了吧!
Good engoy !
将ActiveState.lic, bean.nfo. file_id.diz 拷贝到~/.ActiveState目录下面,重新启动Komodo IDE 5.

ubuntu 安装mac docker

五月 10, 2009
ubuntu已经蛮漂亮了。可还是喜欢上个dook换mac背影冲冲场面。
推荐大家几个常用的dock工具栏。
基本上如果要求3D特效的,在最小化时效果都还是很不错的。
所以看坛友们的个人爱号来自己决定罗。

1、Cairo Dock
地址:https://help.ubuntu.com/community/CairoDock
一个酷的工具栏,但是需要3D特效支持。(compositing effects)

2、Avant Window Navigator
地址:http://www.newlinuxuser.com/the-perfect-os-x-dock-for-linux/
最常用,功能强又漂亮还支持自定义的dock工具之一

3、Engage Dock
地址:http://pimpyourlinux.com/linux-feature-review/enlightenment-engage-dock/
个人认为很普通的一个dock工具

4、Kiba Dock
地址:http://www.kiba-dock.org/index.php?option=com_frontpage&Itemid=1
又小又好看而且还免费,最早是Akamaru的组件。可能是最流行的dock工具了。

5、Ksmoothdock
地址:http://theslack.files.wordpress.com/2007/06/kooldock.png?w=462&h=150
有平滑的大小变化,很低的要求。就是感觉不太像mac的dock

6、SimDock
地址:http://sourceforge.net/projects/simdock/
初学者的最爱,不要求3D特效。对机器要求低,而且提供deb包

[ 此帖被幸运星在2008-09-19 13:07重新编辑 ]

以上内容完全是复制粘贴,本人并不明白其意思,
故本人不对以上内容负法律责任,请不要跨省追捕。
要详查请自己联系原作者,谢谢!

ubuntu evolution 于 Google calendar 同步

五月 10, 2009

http://www.scheduleworld.com/sw2/index.html

SyncEvolution 0.8.1 Released

0.8.1 fixes issues which affected some (three?) users, details below. If 0.8 works for you, there’s no reason to upgrade. New binaries would also have been needed for Evolution 2.24, which was released two weeks ago and will be in major distributions soon. 0.8.1 supports all Evolution releases from 2.6.3 to 2.24 in the same binary. 2.6.1 in Ubuntu 6.06 LTS might also work now – in contrast to the other Evolution releases this has not been tested, though.

Available Packages

The following packages are available:

  • for Evolution (x86 and AMD64), both as .tar.gz and .deb
  • for Mac OS X (a fat binary for PPC and x86)
  • for Maemo (ITOS 2008, should work on Chinook and Diablo)
  • source code

The Evolution packages were renamed from syncevolution-evolution-2.6/8/12 to just syncevolution-evolution. When upgrading via apt, then you’ll notice that your old syncevolution-evolution-2.xx is “on hold”. Simply tell apt to install the new package and let it remove the old one:

# aptitude install syncevolution-evolution
Reading package lists... Done
...
Building tag database... Done
The following packages are BROKEN:
  syncevolution-evolution
The following packages have been kept back:
  syncevolution-evolution-2.12
0 packages upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 0B/380kB of archives. After unpacking 1102kB will be used.
The following packages have unmet dependencies:
  syncevolution-evolution: Conflicts: syncevolution which is a virtual package.
                           Conflicts: syncevolution-evolution-2.12 (< 1:0.8.1-2) but 1:0.8-2 is installed and it is kept back.
Resolving dependencies...
The following actions will resolve these dependencies:

Remove the following packages:
syncevolution-evolution-2.12

Score is 121

Accept this solution? [Y/n/q/?] Y
...

New installations can simply use “aptitude install syncevolution“.

For more installation instructions see the www.estamos.de installation page.

Changes

  • Evolution calendar: regression in 0.8: one-way sync of virtual birthday calendar (#2095433).“refresh-from-client” works again for the birthday calendar. Other modes are not supported. In contrast to previous releases SyncEvolution now does some sanity checks that the sync mode is right.
  • Mac OS X: removing old logdirs failed (#2087389). Fixed.
  • SyncML client library: “Expect: 100-continue” header resulted in 417 error with certain proxies (#2101015).Now this header is always disabled; it doesn’t make much sense with SyncML anyway.
  • The development of the Funambol C++ client library is now tracked in a git repository on github.com. Modifications and tags for SyncEvolution are checked in there. The configure script checks out the right sources from there automatically; can be controlled via --with-funambol-src parameter.
  • Evolution desktop: the version of the used Evolution libraries is included in the “--version” output and log files.
  • Cleaned up README. Kudos to Martin Wetterstedt for pointing out mistakes in the README and the web site.

ubuntu 打电话

五月 10, 2009

Ekiga 设置姓名:Voipstunt
注册商:sip.voipstunt.com
用户:随便
已验证用户:VoipStunt号

sip.voipzoom.com

Open a port on ubuntu

五月 10, 2009
netstat -an | grep "LISTEN "

this command is used for check the ports opened in ubuntu.介绍:
这篇文章是本人原创,向读者展示了如何一步一步建立静态防火墙来保护您的计算机,同时在每一步中,我力图向读者讲述清楚原理。在这篇教程之后,你将能理解到防火墙内在过滤机制,同时也能自己动手创建符合自己要求的防火墙。

版权所有,转载请注明来自www.linuxsir.org 并写明作者

1、iptables介绍

iptables是复杂的,它集成到linux内核中。用户通过iptables,可以对进出你的计算机的数据包进行过滤。通过iptables 命令设置你的规则,来把守你的计算机网络──哪些数据允许通过,哪些不能通过,哪些通过的数据进行记录(log)。接下来,我将告诉你如何设置自己的规 则,从现在就开始吧。

2、初始化工作

在shell提示符 # 下打入

iptables -F

iptables -X

iptables -t nat -F

iptables -t nat -X

以上每一个命令都有它确切的含义。一般设置你的iptables之前,首先要清除所有以前设置的规则,我们就把它叫做初始化好了。虽然很多情况下它什么也不做,但是保险起见,不妨小心一点吧! 如果你用的是redhat 或fedora,那么你有更简单的办法

service iptables stop

3、开始设置规则:

接下下开始设置你的规则了

iptables -P INPUT DROP

这一条命令将会为你构建一个非常“安全”的防火墙,我很难想象有哪个hacker能攻破这样的机器,因为它将所有从网络进入你机器的数据丢弃 (drop) 了。这当然是安全过头了,此时你的机器将相当于没有网络。如果你ping localhost,你就会发现屏幕一直停在那里,因为ping收不到任何回应。

4 、添加规则

接着上文继续输入命令:

iptables -A INPUT -i ! ppp0 -j ACCEPT

这条规则的意思是:接受所有的,来源不是网络接口ppp0的数据。

我们假设你有两个网络接口,eth0连接局域网,loop是回环网(localhost)。ppp0是一般的adsl上网的internet网络接口,如果你不是这种上网方式,那则有可能是eth1。在此我假设你是adsl上网,你的internet接口是ppp0

此时你即允许了局域网的访问,你也可以访问localhost

此时再输入命令 ping localhost,结果还会和刚才一样吗?

到此我们还不能访问www,也不能mail,接着看吧。

5、我想访问www

iptables -A INPUT -i ppp0 -p tcp -sport 80 -j ACCEPT

允许来自网络接口ppp0(internet接口),并且来源端口是80的数据进入你的计算机。
80端口正是www服务所使用的端口。

好了,现在可以看网页了。但是,你能看到吗?

如果你在浏览器的地址中输入www.baidu.com,能看到网页吗?

你得到的结果一定是:找不到主机www.baidu.com

但是,如果你再输入220.181.27.5,你仍然能够访问baidu的网页。

为什么?如果你了解dns的话就一定知道原因了。

因为如果你打入www.baidu.com,你的电脑无法取得www.baidu.com这个名称所能应的ip地址220.181.27.5。如 果你确实记得这个ip,那么你仍然能够访问www,你当然可以只用ip来访问www,如果你想挑战你的记忆的话^ _ ^,当然,我们要打开DNS。

6、打开dns端口

打开你的dns端口,输入如下命令:

iptables -A INPUT -i ppp0 -p udp -sport 53 -j ACCEPT

这条命令的含义是,接受所有来自网络接口ppp0,upd协议的53端口的数据。53也就是著名的dns端口。

此时测试一下,你能通过主机名称访问www吗?你能通过ip访问www吗?

当然,都可以!

7、查看防火墙

此时可以查看你的防火墙了

iptables -L

如果你只想访问www,那么就可以到此为止,你将只能访问www了。 不过先别急,将上面讲的内容总结一下,写成一个脚本。

#!/bin/bash

# This is a script

# Edit by liwei

# establish static firewall

iptables -F

iptables -X

iptables -t nat -F

iptables -t nat -X

iptables -P INPUT DROP

iptables -A INPUT -i ! ppp0 -j ACCEPT

iptables -A INPUT -i ppp0 -p tcp –sport 80 -j ACCEPT

iptables -A INPUT -i ppp0 -p udp –sport 53 -j ACCEPT

8、复杂吗?到此iptables可以按你的要求进行包过滤了。你可以再设定一些端口,允许你的机器访问这些端口。这样有可能,你不能访问QQ, 也可能不能打网络游戏,是好是坏,还是要看你自己而定了。顺便说一下,QQ这个东西还真是不好控制,用户与服务器连接使用的好像是8888端口,而QQ上 好友互发消息使用的又是udp的4444端口(具体是不是4444还不太清楚)。而且QQ还可以使用www的80端口进行登录并发消息,看来学无止境,你 真的想把这个家伙控制住还不容易呢?还是进入我们的正题吧。

如果你的机器是服务器,怎么办?

9、如果不巧你的机器是服务器,并且要提供www服务。显然,以上的脚本就不能符合我们的要求了。但只要你撑握了规则,稍作修改同样也能很好的工作。在最后面加上一句

iptables -A INPUT -i ppp0 -p tcp –dport 80 -j ACCEPT

这一句也就是将自己机器上的80端口对外开放了,这样internet上的其他人就能访问你的www了。当然,你的www服务器得工作才行。如果 你的机器同时是smtp和pop3服务器,同样的再加上两条语句,将–dport后面的80改成25和110就行了。如果你还有一个ftp服务器,呵 呵,如果你要打开100个端口呢……

我们的工作好像是重复性的打入类似的语句,你可能自己也想到了,我可以用一个循环语句来完成,对,此处可以有效的利用shell脚本的功能,也让你体验到了shell脚本语言的威力。看下文:

10、用脚本简化你的工作,阅读下面的脚本

#!/bin/bash

# This is a script

# Edit by liwei

# establish a static firewall

# define const here

Open_ports=”80 25 110 10″ # 自己机器对外开放的端口

Allow_ports=”53 80 20 21″ # internet的数据可以进入自己机器的端口

#init

iptables -F

iptables -X

iptables -t nat -F

iptables -t nat -X

iptables -P INPUT DROP #we can use another method to instead it

iptables -A INPUT -i ! ppp0 -j ACCEPT

# define ruler so that some data can come in.

for Port in “$Allow_ports” ; do

iptables -A INPUT -i ppp0 -p tcp -sport $Port -j ACCEPT

iptables -A INPUT -i ppp0 -p udp -sport $Port -j ACCEPT

done

for Port in “$Open_ports” ; do

iptables -A INPUT -i ppp0 -p tcp -dport $Port -j ACCEPT

iptables -A INPUT -i ppp0 -p udp -dport $Port -j ACCEPT

done

这个脚本有三个部分(最前面的一段是注释,不算在这三部分中)

第一部分是定义一些端口:访问你的机器”Open_ports”端口的数据,允许进入;来源是”Allow_ports”端口的数据,也能够进入。

第二部分是iptables的初始化,第三部分是对定义的端口具体的操作。

如果以后我们的要求发生了一些变化,比如,你给自己的机器加上了一个ftp服务器,那么只要在第一部分”Open_ports”的定义中,将ftp对应的20与21端口加上去就行了。呵呵,到此你也一定体会到了脚本功能的强大的伸缩性,但脚本的能力还远不止这些呢!

11、使你的防火墙更加完善

看上面的脚本init部分的倒数第二句

iptables -P INPUT DROP

这是给防火墙设置默认规则。当进入我们计算机的数据,不匹配我们的任何一个条件时,那么就由默认规则来处理这个数据—-drop掉,不给发送方任何应答。

也就是说,如果你从internet另外的一台计算机上ping你的主机的话,ping会一直停在那里,没有回应。

如果黑客用namp工具对你的电脑进行端口扫描,那么它会提示黑客,你的计算机处于防火墙的保护之中。我可不想让黑客对我的计算机了解太多,怎么办,如果我们把drop改成其他的动作,或许能够骗过这位刚出道的黑客呢。

怎么改呢?将刚才的那一句( iptables -P INPUT DROP )去掉,在脚本的最后面加上

iptables -A INPUT -i ppp0 -p tcp -j REJECT –reject-with tcp-reset

iptables -A INPUT -i ppp0 -p udp -j REJECT –reject-with icmp-port-unreachable

这样就好多了,黑客虽然能扫描出我们所开放的端口,但是他却很难知道,我们的机器处在防火墙的保护之中。如果你只运行了ftp并且仅仅对局域网内 部访问, 他很难知道你是否运行了ftp。在此我们给不应该进入我们机器的数据,一个欺骗性的回答,而不是丢弃(drop)后就不再理会。这一个功能,在我们设计有 状态的防火墙中(我这里讲的是静态的防火墙)特别有用。

你可以亲自操作一下,看一看修改前后用namp扫描得到的结果会有什么不同?

12、这个教程我想到此就结束了,其中有很多东西在这里没有提到,如ip伪装,端口转发,对数据包的记录功能。还有一个很重要的东西就是: iptables处理数据包的流程.在这里我想告诉你,你设置的过滤规则的顺序很重要,在此不宜详细介绍,因为这样一来,这个教程就会拘泥于细节。

iptables是复杂的,我在linuxsir上看过很多教程,它们往往多而全,反而让人望而生畏,希望我的这个教程,能够指导你入门。加油!

最后,我把完整的脚本写出来如下,你只要修改常量定义部分,就能表现出较大的伸缩性^_^

#!/bin/bash

# This is a script

# Edit by liwei

# establish a static firewall

# define const here

Open_ports=”80 25 110 10″ # 自己机器对外开放的端口

Allow_ports=”53 80 20 21″ # internet的数据可以进入自己机器的端口

#init

iptables -F

iptables -X

iptables -t nat -F

iptables -t nat -X

# The follow is comment , for make it better
# iptables -P INPUT DROP

iptables -A INPUT -i ! ppp0 -j ACCEPT

# define ruler so that some data can come in.

for Port in “$Allow_ports” ; do
ptables -A INPUT -i ppp0 -p tcp -sport $Port -j ACCEPT
iptables -A INPUT -i ppp0 -p udp -sport $Port -j ACCEPT
done

for Port in “$Open_ports” ; do
iptables -A INPUT -i ppp0 -p tcp -dport $Port -j ACCEPT
iptables -A INPUT -i ppp0 -p udp -dport $Port -j ACCEPT
done

# This is the last ruler , it can make you firewall better
iptables -A INPUT -i ppp0 -p tcp -j REJECT –reject-with tcp-reset
iptables -A INPUT -i ppp0 -p udp -j REJECT –reject-with icmp-port-unreachable

The Linux kernel in Ubuntu provides a packet filtering system called netfilter, and the traditional interface for manipulating netfilter are the iptables suite of commands. iptables provide a complete firewall solution that is both highly configurable and highly flexible.

Becoming proficient in iptables takes time, and getting started with netfilter firewalling using only iptables can be a daunting task. As a result, many frontends for iptables have been created over the years, each trying to achieve a different result and targeting a different audience.

The Uncomplicated Firewall (ufw) is a frontend for iptables and is particularly well-suited for host-based firewalls. ufw provides a framework for managing netfilter, as well as a command-line interface for manipulating the firewall. ufw aims to provide an easy to use interface for people unfamiliar with firewall concepts, while at the same time simplifies complicated iptables commands to help an adminstrator who knows what he or she is doing. ufw is an upstream for other distributions and graphical frontends.

Firestarter linux firewall