initramfs 和 initrd 的区别

Linux 2.6内核引入了一个新的feature叫做initramfs。与initrd相比,initramfs有几个好处。
initrd模拟一个磁盘(这就是它的名字的由来,initramdisk或initrd)。模拟磁盘也就同时引入了Linux的块IO子系统的开销,比如缓存(caching),而initramfs从根本上把cache也装载(mounted)成filesystem(因此叫做initramfs).

Initramfs建立在page cahce之上,和page cache一样,会动态地自动增长和缩减尺寸来减入内存的使用量,而initrd做不到这点。
另外,不像initrd需要文件系统驱动(filesystem driver)的支持,比如EXT2 driver,如果你的initrd使用ext2。而initramfs则不需要文件系统的支持,initramfs的实现代码很简单,只是基于page cache的简单一层。

copyright ykyi.net

Linux的开机启动顺序

对于x86机器的Linux的启动顺序,BIOS首先从启动设备载入MBR(Master Boot Record).存在MBR里的代码就去找分区表,从活动分区读入Linux的bootloader,最常用的像Grub,其它的有LILO,SYSLINUX。
Bootloader把压缩格式的内核映象载入并把控制权交给内核映像。
内核映像自解压,启动内核!

x86处理器有两种工作模式。实模式和保护模式。在实模式,你只能够寻址1M内存。保护模式下,就复杂得多,可以作到使用处理器的很多高级特性比如分页。CPU必须从实模式转到保护模式是一个单行通道(one-way street)。你不能从保护模式退入实模式。

内核第一阶段的内核初始化是在实模式中完成的。接下来从init/main.c 中定义的 start_kernel()函数进入你保护模式。start_kernel()先初始化CPU subsystem。接下来启动存储器和进程管理。然后启动外围总线和IO设备。启动序列的最后一个阶段便是init进程被启动。这个进程是所有的Linux进程的祖先。Init进程执行用户空间的脚本。这些脚本被用来启动必要的内核服务程序。Init最后spawn一个控制台给你。于是启动就完成了。

copyright ykyi.net

Diff, Patch, and Friends(diff, patch和他们的相关工具)(第二篇)

原文 http://www.linuxjournal.com/article/1237
翻译: www.ykyi.net zausiu
接上篇

Use the diff program to avoid eyestrain and insanity:
使用diff程序来避免会令人发疯的肉眼查找。

diff -u 1 2
— 1 Sat Apr 20 22:11:53 1996
+++ 2 Sat Apr 20 22:12:01 1996
-1,9 +1,9
Ecce Eduardus Ursus scalis nunc tump-tump-tump
occipite gradus pulsante post Christophorum
Robinum descendens. Est quod sciat unus et solus
-modus gradibus desendendi, non nunquam autem
+modus gradibus descendendi, nonnunquam autem
sentit, etiam alterum modum exstare, dummodo
-pulsationibus desinere et de no modo meditari
+pulsationibus desinere et de eo modo meditari
possit. Deinde censet alios modos non esse. En,
nunc ipse in imo est, vobis ostentari paratus.
Winnie ille Pu.

There are several things to notice here:
这里有几个东西要提一下:

*

The file names and last dates of modification are shown in a “header” at the top. The dates may not mean anything if you are comparing files that have been passed back and forth by e-mail, but they become very useful in other circumstances.
文件名和上交更新时间在输出中前面部分显示。如果你只是比较由电子邮件发来发去的文件的话,更新时间可能并不重要。但是在某些情况下,确实还是很有用的。
*

The file names (in this case, 1 and 2—are preceded by — and +++.
文件名(在这个例子中,有两个文件,一个名为1,另一个名为2)加上了 — 和 +++ 的前缀。
*

After the header comes a line that includes numbers. We will discuss that line later.
在头部之后有一行包括了一些数字。我们将在之后讨论它。
*

The lines that did not change between files are shown preceded by spaces; those that are different in the different files are shown preceded by a character which shows which file they came from. Lines which exist only in a file whose name is preceded by — in the header are preceded by a – character, and vice-versa for lines preceded by a + character. Another way to remember this is to see that the lines preceded by a – character were removed from the first (—) file, and those preceded by a + character were added to the second (+++) file.
所有没有更改的行显示出来时仅仅加上空格作前缀。如果是不同的行呢,则在每一行前加上指示它们出处的前缀。加上-前缀表示来自头部标志的 — 文件,如果加上 + 前缀则表示来自头部标志的 +++ 文件。另外你也可以理解成: 有 – 前缀的行表示从第一个文件(—)中删除了,而有 + 前缀的行表示是在(+++)文件中添加的。
*

Three spelling changes have been made: “desendendi” has been corrected to “descendendi”, “non nunquam” has been corrected to “nonnunquam”, and “no” has been corrected to “eo”.
发现三个拼写改动。

Perhaps the main thing to notice is that you didn't need this description of how to interpret diff's output in order to find the differences. It is rather easy to compare two adjacent lines and see the differences.
可能你最关心的不是怎么解析diff的输入来找到分别。比较两个相邻的行来找区别是相当容易的。

It's not always this easy
但事实上并不总是如此。

Unfortunately, if too many adjacent lines have been changed, interpretation isn't as immediately obvious; but by knowing that each marked line has been changed in some way, you can figure it out. For instance, in this comparison, where the file 3 contains the damaged contents, and file 4 (identical to file 2 in the previous example) contains the correct contents, three lines in a row are changed, and now each line with a difference is not shown directly above the corrected line:
很不幸的是。如果太多的相邻行有改动的话,就不是那么明显啦。但是如果知道每行是怎么改动的,你就被轻易找到区别。比如这个例子,文件3包含了受损的内容,而文件4(其实和上个例子中的文件2一模一样)包含了正确的内容,连续三行被改变了,现在每个有改动的行没有在正确的行上面直接显示出来。

diff -u 3 4
— 3 Sun Apr 21 18:57:08 1996
+++ 4 Sun Apr 21 18:56:45 1996
-1,9 +1,9
Ecce Eduardus Ursus scalis nunc tump-tump-tump
occipite gradus pulsante post Christophorum
Robinum descendens. Est quod sciat unus et solus
-modus gradibus desendendi, non nunquam autem
-sentit, etiam alterum nodum exitare, dummodo
-pulsationibus desinere et de no modo meditari
+modus gradibus descendendi, nonnunquam autem
+sentit, etiam alterum modum exstare, dummodo
+pulsationibus desinere et de eo modo meditari
possit. Deinde censet alios modos non esse. En,
nunc ipse in imo est, vobis ostentari paratus.
Winnie ille Pu.

It takes a little more work to find the added mistakes; “nodum” for “modum” and “exitare” for “exstare”. Imagine if 50 lines in a row had each had a one-character change, though. This begins to resemble the old job of going through the whole file, character-by-character, looking for changes. All we've done is (potentially) shrink the amount of comparison you have to do.
这就需要花费更多的工作来找到错误啦。“nodum” for “modum” and “exitare” for “exstare”。想象一下,如果连续50行,每行都有一个字母的改变,那么你要做的工作又和使用diff前一样嘞。逐字逐字的查找!diff仅仅帮你把更改范围限定了而已。

Fortunately, there are several tools for finding these kinds of differences more easily. GNU Emacs has “word diff” functionality. There is also a GNU “wdiff” program which helps you find these kinds of differences without using Emacs.
好有好些工具帮助你很容易定位到这些差异。GNU Emacs就有一个"word diff"的功能。还有一个叫wdiff的GNU工具也能帮助你查找这种类型的错误。

Let's look first at GNU Emacs. For this example, files 5 and 6 are exactly the same, respectively, as files 3 and 4 before. I bring up emacs under X (which provides me with colored text), and type:
让我们先看看GNU Emacs。

M-x ediff-files RET
5 RET
6 RET

In the new window which pops up, I press the space bar, which tells Emacs to highlight the differences. Look at Figure 1 and see how easy it is to find each changed word.

Figure 1. ediff-files 5 6

GNU wdiff is also very useful, especially if you aren't running X. A pager (such as less) is all that is required—and that is only required for large differences. The exact same set of files (5 and 6), compared with the command wdiff -t 5 6, is shown in Figure 2.
GNU wdiff也很有用,特别是你没有运行X服务的时候。一个分屏工具(比如 less)就足够用来查找大范围的差异了。

Figure 2. wdiff -t 5 6

///////
好辛苦。不想译了~~不译了。自己去看原文吧。累死哥了。

copyright ykyi.net

Syntax Highlight in DDD DDD的语法高亮

这几天用DDD调试linux下的程序.发现DDD没有语法高亮~
于是google了一下。悲剧地发现一个贴子:

Hello!

Is it possible to enable syntax highlighting in DDD?
I searched through the Google and found this answer:
可以在DDD里开启语法高亮吗?我用谷歌搜索后发现这个答案。

Sorry, no, this isn’t possible.
The biggest problem is that Motif’s text widget doesn’t
support multiple colours, and would have to be replaced.
That would be an enormous job.
不好意思。没有!这不可能.
最大的问题是Motif的文本控件不支持多彩显示,必须把motif替换掉.
这不是一个普通的/简单的任务.

/////////////////////
悲剧啊!!!在黑白的Linux世界。………..

Is it still impossible (post date is Thu, 10 Feb 2005)?
Are there any workarounds/patches/forks?

Diff, Patch, and Friends(diff, patch和他们的相关工具)(第一篇)

原文 http://www.linuxjournal.com/article/1237
翻译: ykyi.net

“Kernel patches” may sound like magic, but the two tools used to create and apply patches are simple and easy to use—if they weren't, some Linux developers would be too lazy to use them…
"内核补丁"听起来相当之神奇,但是有两个用来创建补丁和应用补丁的工具却简单易用。如果它们很难用的话,一些Linux开发者才懒得用它们呢。

Diff is designed to show you the differences between files, line by line. It is fundamentally simple to use, but takes a little practice. Don't let the length of this article scare you; you can get some use out of diff by reading only the first page or two. The rest of the article is for those who aren't satisfied with very basic uses.
diff这个工具设计成可以向你展示文件之间行与行的区别。它使用起来是相当的简单,但需要一点练习才习。你千万不要让长长的介绍文档把你吓住。你可以先只读前一两页文档,这样你就可以使用diff来开展一些工作了。余下的diff介绍文档是写给那些对基本用法非常不满的奇异人士的。 http://ykyi.net

While diff is often used by developers to show differences between different versions of a file of source code, it is useful for far more than source code. For example, diff comes in handy when editing a document which is passed back and forth between multiple people, perhaps via e-mail. At Linux Journal, we have experience with this. Often both the editor and an author are working on an article at the same time, and we need to make sure that each (correct) change made by each person makes its way into the final version of the article being edited. The changes can be found by looking at the differences between two files.
diff被开发者用来同一个源文件的比较不同版本之间的区别。这还可以有很多其它的用途。比如,当编辑一个在很多人之间通过email传递的文档时,diff工具非常方便。在Linux Journal网站,我们经历过这些。编辑和作者同时修改同一个文章的情况非常常 见,我们需要确保每个人所作的修改都被正确应用到这篇文章的正确位置。被修改的部分可以通过比较两个文件的区别得到。

However, it is hard to show off how helpful diff can be in finding these kinds of differences. To demonstrate with files large enough to really show off diff's capabilities would require that we devote the entire magazine to this one article. Instead, because few of our readers are likely to be fluent in Latin, at least compared to those fluent in English, we will give a Latin example from Winnie Ille Pu, a translation by Alexander Leonard of A. A. Milne's Winnie The Pooh (ISBN 0-525-48335-7). This will make it harder for the average reader to see differences at a glance and show how useful these tools can be in finding changes in much larger documents.
但是,要让你清楚的知道diff工具在查找文件之间的区别方面是多么有用是用点难度的。要向你清楚展示diff的所有所有功能,需要整个Linux Journal杂志这么大的篇幅来介绍(zausiu: 这句话我不太确定有没有译对)。我不这样做,由于比较少一部分人可以流利读懂拉丁文,至少同能够读英文的人数相比可以读拉丁文的是少数派,我给出一个用拉丁文的例子。这样一来,一般人就不太能一眼看出不同之处来,你就能够理解diff用来查找大文件之间的区间是多么有用了。http://ykyi.net

Quickly now, find the differences between these two passages:
废话少说,找找下面两段话的区别:

Ecce Eduardus Ursus scalis nunc tump-tump-tump
occipite gradus pulsante post Christophorum
Robinum descendens. Est quod sciat unus et solus
modus gradibus desendendi, non nunquam autem
sentit, etiam alterum modum exstare, dummodo
pulsationibus desinere et de no modo meditari
possit. Deinde censet alios modos non esse. En,
nunc ipse in imo est, vobis ostentari paratus.
Winnie ille Pu.

Ecce Eduardus Ursus scalis nunc tump-tump-tump
occipite gradus pulsante post Christophorum
Robinum descendens. Est quod sciat unus et solus
modus gradibus descendendi, nonnunquam autem
sentit, etiam alterum modum exstare, dummodo
pulsationibus desinere et de eo modo meditari
possit. Deinde censet alios modos non esse. En,
nunc ipse in imo est, vobis ostentari paratus.
Winnie ille Pu.

You may be able to find one or two changes after some careful comparison, but are you sure you have found every change? Probably not: tedious, character-by-character comparison of two files should be the computer's job, not yours.
如果你仔仔细细,认认真真地比较,你能够发现一到两个不同之处。但是你可以保证你找到了所有的不同之处了吗?不!逐字的比较文件之间的不同是电脑的专长,而不是你--humanbeing ! 

请看第二篇。

copyright ykyi.net

tcpdump基础教程

英文原文出自: A tcpdump Tutorial and Primer
翻译: ykyi.net

Tcpdump是信息安全专业人士最重要的一个网络分析工具。对这个工具有一个深入的理解对于每一个喜欢透彻理解tcp/ip协议栈的人来话都是必须的。但很多人选择一个更高级别的工级,比如Ethereal Wireshark,但是我认为这是一个错误!

不应该机械的反复记忆概念而应该做到真正的理解,因为对tcp/ip协议簇保持清醒的认知非常的重要。如果对该协议簇能够完全精通,那你调试网络的能力则能比同行们高出几个档次。但是,要学精神tcp/ip协议簇,只有不够的实践剖析它们才能做到。

当你使用某种工具来显示网络中的原始流量信息时,人类,而不是机器,就要承担起分析这些流量的重任了。用这种方法就可以不断地加深对tcp/ip的理解。并且,用这种学习方法的时候,我在任何可能的情况下都强烈主张使用tcpdump而不是其它工具。

选项
下面将列出一些用例子的选项,这样可以在你使用这个工具时对你有很大的帮助。这些选项很容易淡忘或与其它类型的滤镜(Filter,笔者认为这里的滤镜实际上指的是其它网络工具)混淆。比如, ethereal。所以,希望这篇文章可以作为一个参考文档,我就是这样使用它的。

首先,我要先介绍几个我认为很方便的tcpdump的选项。第一个是 -n, 这样的话域名就不会被解析了,而是用数字IP的形式显示地址(译者注: 同netstat的-n是一样的喔)。第二个是 -X, 这样就会同时把包的内容以ASCII码和十六制的形式显示。最后一个是 -S, 它个选项会显示绝对序号而不是相对序号。因为当包被隐藏起来的话,你也不会看到奇怪的序号。请谨记,tcpdump较之其它工具的优势之一就是可以与包(packets)手工交互。

值得注意的是,tcpdump默认只会从packet中取出前96个字节。如果你想要多一些的话,那就需要需要把 -s xxxx 加上。这里的xxxx是你确切想要抓取的总字节数。如果我使用这个选项的话,我通常会把这个数字设定为1514而得到所有的数据。下面是一个简短的列表列出我经常使用的选项。

-i any: 监听所有的介面。这样你就知道是不是有流量产生。
-n: 不要解决主机名,以IP数字形式显示主机。
-nn: 不要解析主机名或端口名字。

-A: 以ASCII字符显示包的数据。
-X: 同时以十六进制和ASCII字符显示包的数据。
-XX: 同-X,但也会显示 Ethernet头部。
-v, -vv, -vvv: 详细,更详细,再详细些! 冗余输出得到的包信息。
-c: 抓取 x 个包后就停下。
-S: 打印绝对序号。
-e: 同时得到Ethernet头部。
-q: 显示少一点协议信息。
-E: 用提供的密钥解密 IPSEC 流量。
-s: 设置显示前多少个字节的包内容(snaplength)。

tcpdump 4.0的snaplength的长度从68字节改成了96字节,这样你就可以看到多些内容了。但仍然看不到所有的内容,指定 -s 1514 得到包的所有内容。

http://ykyi.net
一些基本的应用
根据我要查看的不同流量,我使用不同的选项组合,如下:

1.Basic communication // see the basics without many options
tcpdump -nS

1.基本通讯,不用太多选项睇睇基本的
tcpdump -nS

2.基本通迅,冗余输出。可以看到好多流量,
tcpdump -nnvvS

3. 深入一点查看流量。
tcpdump -nnvvXS // -X 选项必不会使tcpdump输出更多.

4. 看size大一点的包.
tcpdump -nnvvXSs 1514 // -s 1514 选项设定显示所有包内容。

下面的例子使用我们上文提到的选项抓取两个( -c2 )ICMP包(一个ping和一个pong)。请注意每个包我们都能看到些什么。

ykyi.net# tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 1514 bytes
00:20:39.722393 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.111.128 > 173.83.123.7: ICMP echo request, id 10621, seq 1, length 64
0x0000: 4500 0054 0000 4000 4001 e225 c0a8 6f80 E..T..@.@..%..o.
0x0010: ad53 7b07 0800 64e6 297d 0001 d745 cc4c .S{…d.)}…E.L
0x0020: d005 0b00 0809 0a0b 0c0d 0e0f 1011 1213 …………….
0x0030: 1415 1617 1819 1a1b 1c1d 1e1f 2021 2223 ………….!"#
0x0040: 2425 2627 2829 2a2b 2c2d 2e2f 3031 3233 $%&'()*+,-./0123
0x0050: 3435 3637 4567
00:20:40.064096 IP (tos 0x0, ttl 128, id 25296, offset 0, flags [none], proto ICMP (1), length 84) 173.83.123.7 > 192.168.111.128: ICMP echo reply, id 10621, seq 1, length 64
0x0000: 4500 0054 62d0 0000 8001 7f55 ad53 7b07 E..Tb……U.S{.
0x0010: c0a8 6f80 0000 6ce6 297d 0001 d745 cc4c ..o…l.)}…E.L
0x0020: d005 0b00 0809 0a0b 0c0d 0e0f 1011 1213 …………….
0x0030: 1415 1617 1819 1a1b 1c1d 1e1f 2021 2223 ………….!"#
0x0040: 2425 2627 2829 2a2b 2c2d 2e2f 3031 3233 $%&'()*+,-./0123
0x0050: 3435 3637 4567
2 packets captured
2 packets received by filter
0 packets dropped by kernel
ykyi.net#

表达式(Expressions)
使用表达式可以让你略去各种各样的流量而只得到你真正关注的。掌握表达式并且会创造性地使用组合技巧才使你真正发挥tcpdump的力量。有三种主要的表达式: type, dir 和 proto.

Type选项是host, net, 和 port. 方向用 dir 指示。可以这样 src, dst; src 或者 dst; 而且 src 和 dst。下面是一些你应该熟练掌握的例子。

host: 只查看指定IP或者指定主机的流量(当你使用 -n 选项时不可以指定主机名)
ykyi.net# tcpdump host 1.2.3.4

src, dst: 查看从 src 发出的,或者目的地是 dst 的流量(忽略会话的另一端)
•src, dst // find traffic from only a source or destination (eliminates one side of a host conversation)
ykyi.net# tcpdump src 2.3.4.5
ykyi.net# tcpdump dst 3.4.5.6

net: 使用无类别域间路由(CIDR,Classless Inter-Domain Routing)指定要抓包的网络。
# tcpdump net 1.2.3.0/24

proto: 指定要抓取的包的协议类型,可以指定tcp,udp,或icmp。可以不用敲入proto
# tcpdump icmp

port: 只查看从指定端口进出的流量
# tcpdump port 3389

src, dst port: 指定的源地址和端口号,或者目的地址和端口号。只抓取匹配指定地址端口的流量。
# tcpdump src port 1025
# tcpdump dst port 389

src,dst port, protocal : 组合三种指定条件.
# tcpdump src port 1025 and tcp
# tcpdump udp and src port 53

还有一个选项可以让你指定一个端口地址的范围
•Port Ranges
tcpdump portrange 21-23

指定包的大小
•Packet Size Filter // only see packets below or above a certain size (in bytes)
tcpdump less 32
tcpdump greater 128
tcpdump equal 64

tcpdump > 32 // 也可以使用数学符号
tcpdump

写入文件
用 -w 选项可以指定一个文件,把抓取到的内容存入该文件内。以后还可以用 -r 指定文件,把以前存入的内容再读回来。这是一个相当不错的方法,可以先抓取包,以后再用各种工具分析。

以这种形式抓到的流量是以tcpdump的格式储存的。这种格式在网络分析的工具之间非常通用。这意味着,像 Wireshark, Snort, 等工具也可以读取它。

把出入80端口的所有流量记录到文件中
# tcpdump -s 1514 port 80 -w capture_file

然后,在将来某个时候,你就能够把存在文件中的流量读回,比如:
# tcpdump -r capture_file

创造性的使用tcpdump
表达式确实不错,但是要真正发挥tcpdump的威力来自于创造性地组合使用各种表达式。这样就可以把你想要关注的信息单独抽出来。tcpdump有三种组合方式,如果你稍微懂点计算机,这简直太容易理解了。
1.与操作
and 或者 &&
2.或操作
or 或者 ||
3.非操作
not 或者 !

比如检测来自10.5.2.3去到端口3389的流量
# tcpdump -nnvvS tcp and src 10.5.2.3 and dst port 3389

检测来自网络 192.168.0.0/16 去到网络 10.0.0.0/8 或者网络 172.16.0.0/16 的流量
# tcpdump -nvX src net 192.168.0.0/16 and dst net 10.0.0.0/8 or 172.16.0.0/16

来自网络 172.16.16.0.0/16 去到主机 1292.168.0.2的 ICMP 流量.
# tcpdump -nvvXSs 1514 dst 192.168.0.2 and src net 172.16.0.0/16 and not icmp

从主机名为 Mars(火星) 或者 Pluto(冥王星) 发出的,目的地不是SSH端口的流量
# tcpdump -vv src mars or pluto and not dst port 22

你已经看到了,你可以创建不同的组合来完成不同的需要。关键在于你知道自己需要怎样的数据,然后就可以使用恰当的语法把它们提炼出来。

同时需要牢记在心的是,当你创建复杂的组合时,你可能会需要用单引号把几个选项括起来。使用单引号是为了告诉 tcpdump 忽略特殊字符(译者注: 同BASH一样)。比如这种情况, 一对小括号"()"。同样的技术可以用来把几个表达式括起来,比如 host, port, net 等。看看下面的例子:

要抓取从10.0.2.4出发去到端口3389或端口22的流量。
# tcpdump src 10.0.2.4 and (dst port 3389 or 22) // 错误的写法!

本应该是一个很有用的组合,但是你运行它,你却得到一个错误,因为小括号!你可以用两种方式纠正这个错误。要么在小括号前加上转义字符 \ 或者把整个组合命令用单引号括起来。

# tcpdump 'src 10.0.2.4 and (dst port 3389 or 22)' // 现在就对了!

进阶部分
你还可以根据包里面的某些字段来组合各种条件指定你要关注的包。这个功能在你想要查看SYNs和RSTs非常有用。

Show me all URG packets:
查看所有的紧急包(URG包)
# tcpdump 'tcp[13] & 32 != 0'

查看所有的确认包(ACK包)
# tcpdump 'tcp[13] & 16 != 0'

查看所有的PSH包
# tcpdump 'tcp[13] & 8 != 0'

查看所有的RST包
# tcpdump 'tcp[13] & 4 != 0'

查看所有的SYN包
# tcpdump 'tcp[13] & 2 != 0'

查看所有的FIN包
# tcpdump 'tcp[13] & 1 != 0'

查看所有的SYN-ACK包
# tcpdump 'tcp[13] = 18'

注意:只有PSH, RST, SYN 和 FIN 标志显示在tcpdump的标志域输出中。URG和ACK也会被显示,但显示在其它的地方而不是在标志位中(Flags Field).

你应该明白为什么以上的命令的写法。tcp[13]表示在tcp头的偏移量13字节的位置,然后作了一个布尔判断。

在神奇的Unix世界,一件事通常可以用好几种方式做到。tcpdump也不例外。下面的例子是另一个通过指定tcp包的标志位来查看包的命令。

Capturing TCP Flags Using the tcpflags Option
用 tcpflags 选项来指定 tcp 标志位。

查看SYN包.
# tcpdump 'tcp[tcpflags] & tcp-syn != 0

特殊流量
查看所有IPv6的流量
# tcpdump ip6

查看所有同时设置了SYN和RST位的流量(仅仅举例,实际上并不可能发生):
# tcpdump 'tcp[13] = 6'

查看所有的 evil 位被设置的流量
# tcpdump 'ip[6] & 128 != 0'

总结:
嗯,这篇文章应该能让你的技术变得更好,当然man手册永远是高手们的必备物品。我真诚希望这篇文章能够帮到你。如果有什么问题,不要犹豫,可以联系我。

copyright ykyi.net