How DNSSEC works

How DNSSEC works

Like other Internet services, DNS (DNS – Domain Name System) was created in times when only a small number of nodes were connected to the Internet and operators of these nodes knew each other. As the numbers of people and computers connected grew later, it was necessary to start dealing with security of the services. All those Internet users no longer know one another and sadly not all of them connect to the network with good intentions.

DNSSEC is an extension to the DNS system, increasing the domain name service security. The principle of DNS is the translation of name-based Internet addresses such as www.nic.cz or www.nicedomain.cz to numeric addresses that can be understood by computers and used to display specific web pages, send e-mail, make phone calls over the Internet and provide other common Internet services. DNSSEC enhances the security when using DNS by preventing insertion of fake, altered or incomplete domain name data.

The DNS service provides potential attackers several spots where the communication can be disrupted and fake data inserted while not secured by DNSSEC. By altering the domain name data, the attacker modifies behavior of other Internet services which can be misused in this way. Attackers can achieve the following effects, for example:

  • Read other people’s e-mail
  • Use fake websites to obtain passwords, access codes or payment card data etc. (known as phishing)
  • Bypass anti-spam protection in DNS and spread spam
  • Counterfeit messages and information displayed on websites
  • Redirect or wiretap on phone calls routed through Internet

Users have mostly no chance to recognize that something wrong is happening. However, deployment of DNSSEC lets users rest reassured that the information they obtain from DNS came from the correct source, was complete and its integrity was not compromised during the transfer. DNSSEC ensures that the DNS data can be trusted.

How Does DNSSEC Work?

DNSSEC introduces asymmetric cryptography to DNS – i.e. one key is used for content encryption while a different key allows to decrypt the content. A similar principle forms the basis of the more widely known encryption of e-mail messages using PGP or signing of messages using electronic signatures. In the case of DNSSEC a domain user generates a pair of keys – private key and public key. The user then electronically signs all technical data he/she is entering to DNS for the given domain with the private key. The public key allows to verify the validity of such signature. To provide access to the public key for all other users, the key is published for the domain at the superior authority. For all .CZ domains the keys are published in the .CZ domain registry. The technical data in DNS are signed even on the .CZ domain registry level while the public key for this signature is handed over to the superior authority by the registry administrator. This creates a chain of trust ensuring that we can rely on the data as long as all links of the chain remain intact and all electronic signatures match. See the following scheme.

DNSSEC scheme

What Will Change When DNSSEC Is Implemented?

DNSSEC provides backward compatibility with the existing DNS, meaning that both version work simultaneously. It is therefore likely that common users will face no changes at all when DNSSEC is implemented for .CZ domains. This will be true until users start using DNSSEC on a specific DNS server. This can apply directly to users’ computers in the case of experts, to company servers in the case of companies or to ISP servers in the case of home users. Service and content providers can take advantage of DNSSEC to increase the security and trustworthiness of their services. Once DNSSEC is in place, the providers will need to enable and maintain digital signatures of their data in DNS as well as publish respective encryption keys in the .CZ domains registry.

相关网站

http://www.root-dnssec.org/

https://www.iana.org/dnssec/

Studying Normal Traffic, Part Three: TCP Headers

Studying Normal Traffic, Part Three: TCP Headers

Anonymous's picture
13 May 2001

by Karen Kent Frederick

Studying Normal Traffic, Part Three: TCP Headers
by Karen Kent Frederick
last updated May 14, 2001


This is the final article in a three-part series devoted to studying normal traffic. As was explained in Studying Normal Traffic, Part One and Studying Normal Traffic,Part Two: Studying FTP Traffic, we often focus our attention on the characteristics of suspicious packets without first becoming familiar with the characteristics of normal traffic. A good and easy way of doing this is to generate, capture and examine your own normal traffic. The first two articles in this series showed how to capture packets using WinDump and reviewed some of the basics of normal TCP/IP traffic. In this article, we will be looking at two other aspects of normal TCP traffic: the structure of TCP packets, and the use of TCP options. Note that in order to understand this material, you should already know the fundamentals of TCP/IP.

TCP Packet Structure

If you’ve read the previous articles in this series or worked with tcpdump or WinDump, you are probably familiar with the format of their output for TCP traffic. If not, here’s a quick review of the meaning of the fields:

13:10:30.134481 [timestamp] my.win98.box.2172 [source address and port ] > anon.ftp.box.21: [destination address and port] S [TCP flags] 71870464:71870464 [sequence numbers] (0) [bytes of data] win 65535 [TCP window size] [TCP options] (DF) [don't fragment flag is set] (ttl 128, id 44644) [time to live value, and IP identification number]

Let’s start by looking at an example that shows the first packet (SYN) of a TCP three-way handshake. It was initiated by a Windows 98 computer and the destination machine is an anonymous FTP server.

13:10:30.134481 my.win98.box.2172 > anon.ftp.box.21: S 71870464:71870464(0) win 65535  (DF) (ttl 128, id 44644)

Most of the fields shown in this entry have been discussed in the previous articles in this series. One field that we haven’t discussed at all are the TCP options; in this example, they are: . So what do they mean, and are they normal or not?

Before we can answer that, we need to know more about the structure of TCP packets themselves. The log entry shown above is actually a text representation of the values of some of the bits and bytes in the packet; the log snippet below shows the actual values of the entire packet in hex. Each pair of numbers (such as “45″) constitutes a byte. You can view packets in this way by running tcpdump or WinDump with the -x option.

 4500 0030 ae17 4000 8006 f398 xxxx xxxx yyyy yyyy 0c37 0015 0526 a98f 0000 0000 7002 ffff 6f06 0000 0204 05b4 0101 0402

The first part of the packet, shown here in italics, is the IP header. It contains several values, including the source and destination IP addresses, the IP identification number, the type of service (TOS), fragmentation information, and the time to live (TTL). The basic IP header is 20 bytes long; if IP options were present, they would add additional bytes to the header. Examples of IP options include loose source routing, strict source routing, timestamps and record route.

Because the use of IP options changes the length of the IP header, a value is set in the header to indicate how many bytes long the header is. It’s important to note that the length of the IP header must be a multiple of 4 bytes. In the example shown above, the second hex digit is 5; this indicates that the length of the IP header is five 4-byte chunks, or 20 bytes total. Since this is the minimum length of the IP header, this tells us that no IP options have been set.

An IP packet is composed of the IP header (with or without options) and the data. In this case, the data section contains TCP; in the above example, the bolded values are the regular portion of a TCP header, which is 20 bytes long without options. The TCP header contains various fields including the source and destination ports, sequence and acknowledgment numbers, window size, TCP flags, urgent pointer, and reserved bits.

Like the IP header, the TCP header may also contain options. And like the IP header, the TCP header’s length must be a multiple of 4 bytes. The final 8 bytes in the example, shown in plain text, are the TCP options. (Note that TCP options and IP options are two different things.) Because the TCP options change the length of the TCP header, the length is set in the header. In this case, the value of the first half of the 13th byte – in this case, 7 – means that the TCP header is made of seven 4-byte chunks, or a total of 28 bytes: 20 bytes of standard TCP header and 8 bytes of TCP options.

Because only one hex value is set aside for indicating the TCP header length, the maximum value that can be set is hex F, which is decimal 15. That means that fifteen 4-byte chunks, or 60 bytes, is the maximum length for the entire TCP header, including TCP options.

TCP Options

Let’s take a look at some commonly used TCP options:

Maximum Segment Size (MSS): The Maximum Segment Size (MSS) was defined in RFC 793; it is used to exchange Maximum Transfer Unit (MTU) / Maximum Receive Unit (MRU) sizes during the TCP three-way handshake. Basically, both ends of the connection will state the maximum IP datagram size that they can handle without using fragmentation, and the lower of the two values will be used by both ends. If the MSS option is omitted by one or both ends of the connection, the value 536 bytes will be used (per RFC 1122). The MSS is only negotiated during the SYN and SYN/ACK packets in the TCP three-way handshake, so the MSS option should only be seen in those packets.

Window Scale (WSCALE): Don’t confuse the TCP option called Window Scale with the standard TCP header field called Window Size. The window size is used to record how many bytes of buffer space the host has available for receiving data. Because the window size field is only 16 bits long, this limits the maximum window size to 65,535 bytes. At one time, this was sufficient, but it no longer is. In RFC 1072, the Window Scale (WSCALE) option was defined; it was redefined in RFC 1323. The Window Scale value is used to shift the window size field’s value up to a maximum value of approximately a gigabyte. Like the MSS option, the WSCALE option should only appear in SYN and SYN/ACK packets during the handshake. However, if both ends of the connection do not use the WSCALE option, the window sizes will remain unchanged.

Timestamp: The Timestamp option was first defined in its current form in RFC 1323. Its purpose is to track the round-trip delivery time for data in order to identify changes in latency that may require acknowledgment timer adjustments. Timestamps can only be used if both ends of the connection agree to use them, as you’ll see shortly. Unlike the MSS and WSCALE options, Timestamp options are typically used throughout a TCP session, so if they are being used, you should see them in most of the packets.

The Timestamp option has two timestamp fields: the Timestamp Value and the Timestamp Echo Reply. When a host first timestamps a packet in a connection, it puts the timestamp in the Timestamp Value field and leaves the Timestamp Echo Reply field set to 0 (generally). When the second host receives that packet and prepares to acknowledge it, it transfers the timestamp from the old packet’s Timestamp Value field to the new packet’s Timestamp Echo Reply field, and it puts a new timestamp in the Timestamp Value field. So the Timestamp Value field always contains the latest timestamp, while the Timestamp Echo Reply field contains the previous timestamp.

No Operation (NOP): The No Operation (NOP) TCP option, defined in RFC 793, is used to provide padding around other options. The length of the TCP header must be a multiple of 4 bytes; however, most of the options are not 4 bytes long. If the total length of the options is not a 4-byte multiple, one or more 1-byte NOPs will be added to the options in order to adjust the overall length. For example, if there were 6 bytes of options, two NOPs would be added. NOPs are sometimes used between options, particularly if an option needs to start on a certain byte boundary, so it is not unusual to see several NOPs throughout a set of TCP options.

Selective Acknowledgments: The concept of selective acknowledgments was defined in RFC 1072 and redefined in RFC 2018. Normally, when a host acknowledges data, it can only acknowledge the packets up to and including the sequence number immediately before a missing packet. This means that if a thousand packets are received but the second one is missing, the host can only acknowledge the receipt of the first packet, so the sender would have to resend all packets from number 2 through 1000. By using selective acknowledgments, the receiver could acknowledge the receipt of the packets from 3 through 1000, so the sender would only have to resend packet 2.

There are two TCP options for selective acknowledgments:

Selective Acknowledgment Permitted (SackOK): This option simply says that selective acknowledgments are permitted for this connection. SackOK must be included in the TCP options in both the SYN and SYN/ACK packets during the TCP three-way handshake, or it cannot be used. SackOK should not appear in any other packets.

Selective Acknowledgment Data: This option contains the actual acknowledgment information for a selective acknowledgment. It lists one or more pairs of sequence numbers, which define ranges of packets that are being acknowledged.

Analyzing Examples of TCP Options

Now we’ll return to the question that I asked at the beginning of the article. The TCP options in the example, a SYN packet from a Windows 98 system, are . What does that mean, and is it normal or not?

Here are the number of bytes that each of the options described above uses in a packet:

  • Maximum Segment Size (MSS): 4 bytes
  • Window Scale (WSCALE): 3 bytes
  • Timestamp (TS): 10 bytes
  • No Operation (NOP): 1 byte
  • Selective Acknowledgment Permitted (SackOK): 2 bytes
  • Selective Acknowledgment Data: 10 bytes (plus 8 bytes for each additional pair of sequence numbers)

Putting together all the items we’ve discussed, the options appear to be normal:

  • specifies a Maximum Segment size of 1460 bytes; it uses 4 bytes of the options. It is appropriate to see MSS used in a SYN packet.
  • is filler to provide padding between the mss 1460 and sackOK options. Each NOP takes up 1 byte of the header.
  • specifies that selective acknowledgments are permitted. This takes up 2 bytes of the header, and it is also appropriate to use in a SYN packet.

Here’s another example from a SYN packet sent by an OpenBSD 2.7 box: . Notice that it starts out with the same four options as the previous example (mss 1460,nop,nop,sackOK) but then adds several more. Here is the meaning of each of the additional fields, which total 16 bytes:

  • provides 1 byte of filler.
  • says that the Window Scale option is supported by the operating system but that it does not wish to use it. This takes up 3 bytes.
  • provides 2 bytes of filler.
  • is an initial timestamp. The Timestamp Value field is set to 50473, which is the time that the packet was sent. Since this is the first packet, the Timestamp Echo Reply field is set to 0, as there is no previous timestamp to place there. The timestamp option takes 10 bytes.

Another example of a SYN packet comes from a RedHat Linux 7.0 system: . Compare this example to the previous one; you’ll notice that both list the same 4 options: mss, sackOK, timestamp and wscale. But they list them in a different order, and they use nop instructions quite differently. Yet both are examples of normal traffic. The RFCs do not state what order the TCP options should be placed in, so each operating system is free to arrange them in whatever order they please.

The final example comes from a FreeBSD 4.0 box: for a SYN packet, the only option that it supplied was . This is quite different from the earlier examples, but it is perfectly acceptable; it just does not use the same options by default as the other operating systems did.

Conclusion

We have examined the normal use of TCP options. Various operating systems not only use different TCP options by default, but they list the options in different sequences, and they also use NOP’s for padding in different ways. This is not abnormal behavior, as long as the length of the options totals a multiple of 4 bytes, and the options make sense. For example, options such as MSS and Window Scale shouldn’t be set more than once in a packet, nor should they appear in packets that don’t have the SYN flag set.

Because most operating systems use a unique default TCP option combination, TCP options can be used to do “passive fingerprinting” of the operating system of a host that sends you a SYN packet. Also, systems can be fingerprinted based on what options they return in response to a set of options sent from another system. For example, if I send a SYN packet with the SackOK option set, and your system sends a SYN/ACK response without the SackOK option set, I know that your operating system does not support selective acknowledgments. By sending a SYN packet with many different options set and examining the options listed in the SYN/ACK response, I may be able to identify the operating system of the other host.

For more information on TCP options, two great references are TCP/IP Illustrated, Volume 1, by W. Richard Stevens, and Internet Core Protocols, by Eric A. Hall. More information on passive fingerprinting in general is available in Know Your Enemy: Passive Fingerprinting by Lance Spitzner, and information on fingerprinting using TCP options is available from Remote OS Detection Via TCP/IP Stack Fingerprinting by Fyodor.

Much thanks to Toby Miller for his suggestion to examine default TCP options.

Karen Kent Frederick is a senior security engineer for the Rapid Response Team at NFR Security. Karen has a B.S. in Computer Science and is currently completing her Master’s thesis in intrusion detection through the University of Idaho. She holds several certifications, including Microsoft Certified Systems Engineer + Internet, Check Point Certified Security Administrator, SANS GIAC Certified Intrusion Analyst, GIAC Certified Unix Security Administrator, and GIAC Certified Incident Handler. Karen is one of the authors and editors of “Intrusion Signatures and Analysis”, a new book on intrusion detection that was published in January 2001.

Relevant Links

Studying Normal Traffic, Part One
Karen Kent Frederick, SecurityFocus

Studying Normal Traffic, Part Two: Studying FTP Traffic
Karen Kent Frederick, SecurityFocus

Abnormal Traffic
Karen Kent Frederick, SecurityFocus

tcpdump
Tcpdump Group

WinDump
NetGroup

关于Kerberos认证原理的对话

安全知识:关于Kerberos认证原理的对话
 
作者:MIT出处:foxlog.net[ 2005-07-19 13:30 ]
摘要:这是为了帮助人们理解Kerberos的原理而写的一篇对话集。里面有两个虚构的人物:Athena和Euripides,通过Athena不断的构思和Euripides不断的寻找其中的漏洞,使大家明白了Kerberos协议的原理
——————————————————————————–
文章导读 1、第一幕 2、第二幕 3、第三幕 4、第四幕 5、后记

  Athena: 雅典娜,智慧与技艺的女神。

 
  Euripides:欧里庇得斯, 希腊的悲剧诗人。
 
  译文如下:
 
  第一幕
 
  在一个小工作间里。Athena和Euripides正在相邻的终端上工作。
 
  Athena: 嗨,这个分时操作系统实在太慢了。我根本无法工作,因为每个人都登上去了。
 
  Euripides: 不要对我报怨。我只是在这工作。
 
  Athena: 你知道我们需要什么吗?我们需要给每一个人一台工作,这样大家就不会担心计算机的速度了。并且,我们需要一个网络把所有的计算机都联起来。
 
  Euripides: 好。那么我们差不多要一千台工作站?
 
  Athena: 差不多吧。
 
  Euripides: 你知道一台普通的工作站的硬盘有多大吗?那里放不下所有的软件。
 
  Athena: 我已经有主意了。我们可以把系统软件放到服务器上。当你登录到工作站的时候,工作站会通过网络与其中一台服务器上的系统软件联系。这样的设置让一组工作站都使用同一份系统软件,并且利于系统软件的升級。只需改动服务器就可以了。
 
  Euripides: 好的。个人的文件怎到办呢?在分时操作系统上,我可以登录并从终端上取走我的文件。我能到工作站上取我的文件吗?我要象PC用户一样把我的文件放到磁盘上去吗?我希望不。
 
  Athena: 我想我们可以其它机器来存文件。你可以到任何一台机器上登录去取你的文件。
 
  Euripides: 打印怎么办呢?每个工作站都要有自已的打印机吗?谁来付钱?电子邮件呢?你怎么把邮件送到所有的工作站上去呢?
 
  Athena: 啊…..很明显我们没钱为每个人配一台打印机,但我们有专门的机器做打印服务。你把请求送到服务器,它就为你打印。邮件也可以这样做。专门有一台邮件服务器。你如果想要你的邮件,就联系邮件服务器,取走你的邮件。
 
  Euripides: 你的工作站系统听起来很不错。如果我有一台,你知道我要做什么吗?我要找出你的用户名,让我的工作站认为我就是你。然后我就去邮件服务器取走你的邮件。我会联上你的文件服务器,移走你的文件,然后–
 
  Athena: 你能做得到吗?
 
  Euripides: 当然!这些网络服务器怎么会知道我不是你?
 
  Athena: 嗯,我不知道.我想我需要认真思考一下.
 
  Euripides: 好吧。你想出来后告诉我.
 
  第二幕
 
  Euripides的办公室,第二天早上。Euripides坐在他的桌子旁边,读着他的邮件。Athena来敲门.
 
  Athena: 我已经想出怎样保护一个开放的网络系统,使象你那样不道德的人不能用别人的名字使用网络服务。
 
  Euripides: 真的吗?坐吧。
 
  她坐下了。
 
  Athena: 在我开始描述之前,我可以为我们的讨论先做一个约定吗?
 
  Euripides: 什么约定?
 
  Athena: 好,假设我这样说:"我想要我的邮件,于是我与邮件服务器联系,请求它把邮件送到我的工作站上来。"实际上我并没有联系服务器。我用一个程序来与服务器联系并取得我的邮件,这个程序就是这个服务的客户端。 但我不想每次与服务器交互的时侯说:"客户端怎样怎样".我只想说:"我怎样怎样,"记住,客户端在代表我做所有的事。这样可以吗?
 
  Euripides: 当然。没问题.
 
  Athena: 好。那么我要开始阐述我所解决的问题了。在一个开放的网络环境中,提供服务的机器必须能够识别请求服务的实体的身份。如果我去邮件服务器申请我的邮件,服务程序必须能够验证我就是我所申明的那个人。
 
  Euripides: 没错.
 
  Athena: 你可以用一个笨办法解决这个问题:服务器让你输入你的口令。通过输口令的办法我可以证明我是谁。
 
  Euripides: 那确实很笨拙。在像那样的系统里面,每一个服务器必须知道你的口令。如果网络有一千个用户,那每个服务器就要知道一千个口令。如果你想改变口令,你就必须联系所有服务器,通知它们修改口令。我想你的系统不会那么笨。
 
  Athena: 我的系统没那么笨。它是象这样工作的:不光人有口令,服务也有口令。每个用户知道他们自已的口令,每个服务也知道它自已的口令。有一个认证服务知道所有的口令,用户的和服务的。认证服务把口令保存在一个单独的中央数据库中。
 
  Euripides: 这个认证服务有一个名字吗?
 
  Athena: 我还没想好。你想一个吧?
 
  Euripides: 把死人送过冥河的人是谁?
 
  Athena: Charon?
 
  Euripides: 对,就是他。如果他不能证实你的身份的话,他就不会把你送过河。
 
  Athena: 你瞎编,是不是想重写希腊神话。Charon不关心你的身份,他只是确定你死了没有。
 
  Euripides: 你有更好的名字吗?
 
  停了一下。
 
  Athena: 没有,真的没有。
 
  Euripides: 好,那我们就把这个认证服务“Charon”。
 
  Athena: 好,我猜我该描述一下这个系统了吧,嗯?
 
  比如说我们想要一种服务:邮件。在我的系统里面你无法使用一种服务,除非Charon告诉服务你确实是你所申明的人。也就是说你必须得到Charon的认证才能使用服务。当你向Charon请求认证的时候,你必须告诉Charon你要使用哪一个服务。如果你想用邮件,你要告诉Charon。 Charon请你证明你的身份。于是你送给它你的密码。Charon把你的密码和它数据库中的密码相比较。如果相等,Charon就认为你通过了验证。 Charon现在就要让邮件服务知道你通过了验证。既然Charon知道所有服务的密码,它也知道邮件服务的密码。Charon把邮件服务的密码给你,你就可以使用这个密码使邮件服务相信你已通过验证。 问题是,Charon不能直接给你密码,因为你会知道它。下次你想要邮件服务的时候,你就会绕过Charon使用邮件服务而不需要认证。你也可以假装某人来使用邮件服务。 所以不是直

接给你邮件服务的

【原】用tcpdump抓取txt chaos的DNS解析请求

过滤条件:

dst port 53 and (udp[36:2]=3)

目的端口是53 且 UDP的第36字节向后偏移2个字节,如果值=3 说明是class为chaos的DNS解析请求。原理分析:

一 首先抓取一个正常的txt chaos dns请求,例如

dig @202.106.0.20 txt ch authors.bind 

从上图中观察,我们只要过滤到class=ch即可,class:ch 位于包的最后,占2个字节。

udp包头占了8个字节(0-7),UDP包中的有效负载部分才是实际的DNS请求数据,因此udp[8]表示DNS实际部分的开始,根据上图DNS包格式:

query id占2个字节 + flags部分2个字节 + questions 2个字节 + answer RRS 2个字节 + authority RRS 2个字节 + additional RRS 2个字节

因而当到达实际的 queries 部分时是udp[20]即第20个字节,从udp[20]开始,authors.bind占去了14个字节, type:txt占去2个字节,因此udp[36]表示class:ch位置的开始,而class:ch占用2个字节,因此

udp[36:2]=3 即为class:ch

所以 dst port 53 and (udp[36:2]=3) 表示对chaos class的dns请求。

同理,对于dig @202.106.0.20 txt ch version.bind

其他没有变化,且version占用的字节和authors占用字节一样,因此 dst port 53 and (udp[36:2]=3)  也对其成立。

但是!

dig @202.106.0.20 txt ch hostname.bind 这个由于hostname多了一个字母而导致多占用一个字节,所以 dst port 53 and (udp[37:2]=3)  即可。

对于测试抓包,这样就可以了,但是实际要对上面几种请求都能过滤的话,就必须绕过由于请求的域名不同而导致的class:ch位置的变化,由于对这种请求,class:ch都在最后2位,因此利用UDP包的长度减去-2 就可以绕过上述问题:

dst port 53 and udp[((udp[4:2])-2):2]=3

udp[4:2] 表示的是取UDP包头中的UDP包长度的值,减去2  就表示class:ch的位置

www.myf5.net

实际效果:

 对于任意的*.bind查询都可以过滤。

 

【原】tcpdump的 proto [ expr : size ] 用法

proto [ expr : size ]

proto指定一个协议,expr表示从哪个字节开始(1个字节是8位,因此就表示第多少个8位组),size是偏移几个字节(8位组) 例如

ip[9]==1表示抓icmp协议,因为IP包中的第9个字节是表示的协议类型,1是icmp协议。

tcp[0:2]=80 表示源端口为80,因为tcp包中第0个字节开始并偏移2个字节,即表示tcp包的开始前16位,正好是源端口

tcp[2:2]=80表示目的端口为80,因为从第2字节(实际就是第三个字节开始,因为从0开始数)并偏移2个字节,正好是目的端口所占用的16位。

icmp[0]=8 表示echo request,因为icmp的第一个字节正好表示icmp的type,type=8表示回显请求

【原】tcpdump抓取TCP标识位

按每8位组算,TCP的标志位位于第13个8位组中,如下,第一行一共32位是0 – 3个8位组,第二行是4-7八位组,第三行是8-11八位组,data offset +reserved的前四个是第12个8位组,reserved中的后2位+6个标志位是第13个八位组. 

因此第13个八位组结构为

- – + + + + + +

前面2个是保留的,都为0,后面的6个根据不同情况有不同值,例如syn 包 则为

00 0 0 0 0 1 0

这是二进制转化为十进制就是2

因此 tcpdump -ni eth0 tcp[13]==2 就表示syn包

同理,syn+ack包为

00 0 1 0 0 1 0

化为十进制就是18,因此tcpdump -ni eth0 tcp[13]==18 表示syn+ack包

如果想同时抓syn和syn+ack包,则进行tcp[13]位值与掩码进行与运算:

tcp[13] & 2 == 2

原理:

既然希望同时抓syn和syn+ack,说明syn位是我们要关心的位置,因此仿照网络掩码的与运算,只关心syn位的掩码是00 0 0 0 0 1 0,将

         00010010 SYN-ACK                                        00000010 SYN
AND 00000010 (we want SYN)                     AND 00000010 (we want SYN)
         ——–                                                                   ——–
      = 00000010                                                       = 00000010

与运算的结果都是2,因此

tcp[13] & 2的结果应等于2, 即tcp[13] & 2 == 2

———

如果觉得记忆和计算这些很难,则可以利用

tcp[tcpflags]=tcp-syn 这种格式来写,后面的值可以为tcp-fin, tcp-syn, tcp-rst, tcppush,
tcp-ack, tcp-urg任意一种

FTP 控制信道如果断开了,那么正在传送的数据信道会断开麽?

 ftp与F5分析.docx

Clientcuteftp3.0

Server: server-u9.0

F5: v 9.3.1.HF4

 

一、FTPforward VS(FASTL4)

使用一个全0forwarding VSfastl4 缺省值),FTP连接均通过该VS,发现:

FTP能够正常建立连接(pasv模式)和传输数据,控制连接的idle时间在不停的增大,数据传输连接的idle时间在自动刷新。但当控制连接超时后,数据连接也随之被F5删除:

[root@bigip:Active] config # b conn show all

VIRTUAL any:any <-> NODE 1.1.1.100:ftp

    CLIENTSIDE 10.0.0.100:3129 <-> 1.1.1.100:ftp

        (pkts,bits) in = (11, 5392), out = (9, 6568)

    SERVERSIDE 10.0.0.100:3129 <-> 1.1.1.100:ftp

        (pkts,bits) in = (9, 6568), out = (11, 5392)

    PROTOCOL tcp   UNIT 1   IDLE 285 (300)   LASTHOP 4093 00:17:a4:e4:86:39

VIRTUAL any:any <-> NODE 1.1.1.100:1665

    CLIENTSIDE 10.0.0.100:3131 <-> 1.1.1.100:1665

        (pkts,bits) in = (1550, 669664), out = (2813, 27.23M)

    SERVERSIDE 10.0.0.100:3131 <-> 1.1.1.100:1665

="margin: 0cm 0cm 0pt" cla
ss="MsoNormal">        (pkts,bits) in = (2813, 27.23M), out = (1550, 669664)

PROTOCOL tcp   UNIT 1   IDLE 0 (300)   LASTHOP 4093 00:17:a4:e4:86:39

 

接着再显示

[root@bigip:Active] config # b conn show all

No connections were found.

 

正常情况下,控制信道断开后,数据信道也应该继续传输数据,怀疑为fastl4reset on idletimeout导致,关闭该功能,测试发现:

[root@bigip:Active] config # b conn show all

VIRTUAL any:any <-> NODE 1.1.1.100:ftp

    CLIENTSIDE 10.0.0.100:3253 <-> 1.1.1.100:ftp

        (pkts,bits) in = (10, 4912), out = (9, 6496)

    SERVERSIDE 10.0.0.100:3253 <-> 1.1.1.100:ftp

        (pkts,bits) in = (9, 6496), out = (10, 4912)

    PROTOCOL tcp   UNIT 1   IDLE 86 (120)   LASTHOP 4093 00:17:a4:e4:86:39

VIRTUAL any:any <-> NODE 1.1.1.100:2314

    CLIENTSIDE 10.0.0.100:3255 <-> 1.1.1.100:2314

        (pkts,bits) in = (489, 211312), out = (872, 8.548M)

    SERVERSIDE 10.0.0.100:3255 <-> 1.1.1.100:2314

        (pkts,bits) in = (872, 8.548M), out = (489, 211312)

PROTOCOL tcp   UNIT 1   IDLE 0 (120)   LASTHOP 4093 00:17:a4:e4:86:39

 

等待控制连接超时后

[root@bigip:Active] config # b conn show all

VIRTUAL any:any <-> NODE 1.1.1.100:2314

    CLIENTSIDE 10.0.0.100:3255 <-> 1.1.1.100:2314

        (pkts,bits) in = (747, 322768), out = (1327, 12.97M)

    SERVERSIDE 10.0.0.100:3255 <-> 1.1.1.100:2314

        (pkts,bits) in = (1327, 12.97M), out = (747, 322768)

PROTOCOL tcp   UNIT 1   IDLE 1 (120)   LASTHOP 4093 00:17:a4:e4:86:39

 

数据连接依然在传输。

 

分析:缺省fastl4情况下,F5ftp控制连接超时后,自动发送RST包,该reset包导致了客户端程序和服务器主动关闭控制连接,而客户端或服务器如果关闭了控制则将不再传输数据。关闭了profileRST功能后,F5只是默默删除F5上的控制连接,不影响客户端和服务器,因此Ftp传输能够继续。

 

(删除一个VS,VS上当前活动的连接是不会被删除的!!)

 

二、FTPperformance l4 VSVS端口为0

PASV模式无法建立连接,ftp clientVS建立控制信道正常,随后client从控制信道中得知client应该用自己的随机端口与实际的serverpool中的成员)随机端口连接,而此时F5是不容许直接访问后台的ftp服务器的:

[root@bigip:Active] config # tcpdump -ni 0.0 tcp

tcpdump: listening on 0.0

11:16:46.805107 802.1Q vlan#4093 P0 10.0.0.99.3587 > 10.0.0.200.ftp: S 988707591:988707591(0) win 65535 <mss 1260,nop,nop,sackOK> (DF)

11:16:46.805135 802.1Q vlan#4094 P0 10.0.0.99.3587 > 1.1.1.100.ftp: S 988707591:988707591(0) win 65535 <mss 1260,nop,nop,sackOK> (DF)

11:16:46.806044 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3587: S 3239389612:3239389612(0) ack 988707592 win 16384 <mss 1460,nop,nop,sackOK>

11:16:46.806048 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3587: S 3239389612:3239389612(0) ack 988707592 win 16384 <mss 1460,nop,nop,sackOK>

11:16:46.806425 802.1Q vlan#4093 P0 10.0.0.99.3587 > 10.0.0.200.ftp: . ack 1 win 65535 (DF)

11:16:46.806428 802.1Q vlan#4094 P0 10.0.0.99.3587 > 1.1.1.100.ftp: . ack 1 win 65535 (DF)

11:16:46.857245 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3587: P 1:38(37) ack 1 win 17640 (DF)

11:16:46.857247 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3587: P 1:38(37) ack 1 win 17640 (DF)

11:16:46.858942 802.1Q vlan#4093 P0 10.0.0.99.3587 > 10.0.0.200.ftp: P 1:12(11) ack 38 win 65498 (DF)

11:16:46.858944 802.1Q vlan#4094 P0 10.0.0.99.3587 > 1.1.1.100.ftp: P 1:12(11) ack 38 win 65498 (DF)

11:16:46.873190 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3587: P 38:74(36) ack 12 win 17629 (DF)

11:16:46.873193 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3587: P 38:74(36) ack 12 win 17629 (DF)

11:16:46.874450 802.1Q vlan#4093 P0 10.0.0.99.3587 > 10.0.0.200.ftp: P 12:23(11) ack 74 win 65462 (DF)

11:16:46.874452 802.1Q vlan#4094 P0 10.0.0.99.3587 > 1.1.1.100.ftp: P 12:23(11) ack 74 win 65462 (DF)

11:16:46.878751 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3587: P 74:104(30) ack 23 win 17618 (DF)

11:16:46.878753 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3587: P 74:104(30) ack 23 win 17618 (DF)

11:16:46.879571 802.1Q vlan#4093 P0 10.0.0.99.3587 > 10.0.0.200.ftp: P 23:28(5) ack 104 win 65432 (DF)

11:16:46.879573 802.1Q vlan#4094 P0 10.0.0.99.3587 > 1.1.1.100.ftp: P 23:28(5) ack 104 win 65432 (DF)

11:16:46.881240 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3587: P 104:135(31) ack 28 win 17613 (DF)

11:16:46.881241 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3587: P 104:135(31) ack 28 win 17613 (DF)

11:16:46.882498 802.1Q vlan#4093 P0 10.0.0.99.3587 > 10.0.0.200.ftp: P 28:34(6) ack 135 win 65401 (DF)

11:16:46.882500 802.1Q vlan#4094 P0 10.0.0.99.3587 > 1.1.1.100.ftp: P 28:34(6) ack 135 win 65401 (DF)

11:16:46.890896 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3587: P 135:708(573) ack 34 win 17607 (DF)

11:16:46.890899 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3587: P 135:708(573) ack 34 win 17607 (DF)

11:16:46.892301 802.1Q vlan#4093 P0 10.0.0.99.3587 > 10.0.0.200.ftp: P 34:42(8) ack 708 win 64828 (DF)

11:16:46.892303 802.1Q vlan#4094 P0 10.0.0.99.3587 > 1.1.1.100.ftp: P 34:42(8) ack 708 win 64828 (DF)

11

:16:46.893677 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3587: P 708:754(46) ack 42 win 17599 (DF)

11:16:46.893679 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3587: P 708:754(46) ack 42 win 17599 (DF)

11:16:46.894644 802.1Q vlan#4093 P0 10.0.0.99.3587 > 10.0.0.200.ftp: P 42:48(6) ack 754 win 64782 (DF)

11:16:46.894646 802.1Q vlan#4094 P0 10.0.0.99.3587 > 1.1.1.100.ftp: P 42:48(6) ack 754 win 64782 (DF)

11:16:46.912110 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3587: P 754:799(45) ack 48 win 17593 (DF)

11:16:46.912113 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3587: P 754:799(45) ack 48 win 17593 (DF)

11:16:46.912931 802.1Q vlan#4093 P0 10.0.0.99.3587 > 10.0.0.200.ftp: P 48:54(6) ack 799 win 64737 (DF)

11:16:46.912933 802.1Q vlan#4094 P0 10.0.0.99.3587 > 1.1.1.100.ftp: P 48:54(6) ack 799 win 64737 (DF)

11:16:46.916647 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3587: P 799:852(53) ack 54 win 17587 (DF)

11:16:46.916649 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3587: P 799:852(53) ack 54 win 17587 (DF)

11:16:46.925132 802.1Q vlan#4093 P0 10.0.0.99.3589 > 1.1.1.100.3635: S 1989479398:1989479398(0) win 65535 <mss 1260,nop,nop,sackOK> (DF)

11:16:47.154148 802.1Q vlan#4093 P0 10.0.0.99.3587 > 10.0.0.200.ftp: . ack 852 win 64684 (DF)

11:16:47.154150 802.1Q vlan#4094 P0 10.0.0.99.3587 > 1.1.1.100.ftp: . ack 852 win 64684 (DF)

11:16:49.896926 802.1Q vlan#4093 P0 10.0.0.99.3589 > 1.1.1.100.3635: S 1989479398:1989479398(0) win 65535 <mss 1260,nop,nop,sackOK> (DF)

11:16:55.891851 802.1Q vlan#4093 P0 10.0.0.99.3589 > 1.1.1.100.3635: S 1989479398:1989479398(0) win 65535 <mss 1260,nop,nop,sackOK> (DF)

 

此时改用port模式,也是无法连接,FTP 实际的server用其20端口主动向client发起连接,而此时F5上是不可能让这个链接通过的,没有相关的VS

[root@bigip:Active] config # tcpdump -ni 0.0 tcp

tcpdump: listening on 0.0

11:23:32.298007 802.1Q vlan#4093 P0 10.0.0.99.3601 > 10.0.0.200.ftp: S 1781995993:1781995993(0) win 65535 <mss 1260,nop,nop,sackOK> (DF)

11:23:32.298033 802.1Q vlan#4094 P0 10.0.0.99.3601 > 1.1.1.100.ftp: S 1781995993:1781995993(0) win 65535 <mss 1260,nop,nop,sackOK> (DF)

11:23:32.298716 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3601: S 1449994149:1449994149(0) ack 1781995994 win 16384 <mss 1460,nop,nop,sackOK>

11:23:32.298719 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3601: S 1449994149:1449994149(0) ack 1781995994 win 16384 <mss 1460,nop,nop,sackOK>

11:23:32.298886 802.1Q vlan#4093 P0 10.0.0.99.3601 > 10.0.0.200.ftp: . ack 1 win 65535 (DF)

11:23:32.298888 802.1Q vlan#4094 P0 10.0.0.99.3601 > 1.1.1.100.ftp: . ack 1 win 65535 (DF)

11:23:32.307934 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3601: P 1:38(37) ack 1 win 17640 (DF)

11:23:32.307937 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3601: P 1:38(37) ack 1 win 17640 (DF)

11:23:32.310590 802.1Q vlan#4093 P0 10.0.0.99.3601 > 10.0.0.200.ftp: P 1:12(11) ack 38 win 65498 (DF)

11:23:32.310592 802.1Q vlan#4094 P0 10.0.0.99.3601 > 1.1.1.100.ftp: P 1:12(11) ack 38 win 65498 (DF)

11:23:32.315542 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3601: P 38:74(36) ack 12 win 17629 (DF)

11:23:32.315543 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3601: P 38:74(36) ack 12 win 17629 (DF)

11:23:32.316150 802.1Q vlan#4093 P0 10.0.0.99.3601 > 10.0.0.200.ftp: P 12:23(11) ack 74 win 65462 (DF)

11:23:32.316152 802.1Q vlan#4094 P0 10.0.0.99.3601 > 1.1.1.100.ftp: P 12:23(11) ack 74 win 65462 (DF)

11:23:32.320077 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3601: P 74:104(30) ack 23 win 17618 (DF)

11:23:32.320080 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3601: P 74:104(30) ack 23 win 17618 (DF)

11:23:32.320687 802.1Q vlan#4093 P0 10.0.0.99.3601 > 10.0.0.200.ftp: P 23:28(5) ack 104 win 65432 (DF)

11:23:32.320689 802.1Q vlan#4094 P0 10.0.0.99.3601 > 1.1.1.100.ftp: P 23:28(5) ack 104 win 65432 (DF)

11:23:32.322126 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3601: P 104:135(31) ack 28 win 17613 (DF)

11:23:32.322128 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3601: P 104:135(31) ack 28 win 17613 (DF)

11:23:32.322737 802.1Q vlan#4093 P0 10.0.0.99.3601 > 10.0.0.200.ftp: P 28:34(6) ack 135 win 65401 (DF)

11:23:32.322739 802.1Q vlan#4094 P0 10.0.0.99.3601 > 1.1.1.100.ftp: P 28:34(6) ack 135 win 65401 (DF)

11:23:32.332513 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3601: P 135:708(573) ack 34 win 17607 (DF)

11:23:32.332516 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3601: P 135:708(573) ack 34 win 17607 (DF)

11:23:32.333563 802.1Q vlan#4093 P0 10.0.0.99.3601 > 10.0.0.200.ftp: P 34:42(8) ack 708 win 64828 (DF)

11:23:32.333565 802.1Q vlan#4094 P0 10.0.0.99.3601 > 1.1.1.100.ftp: P 34:42(8) ack 708 win 64828 (DF)

11:23:32.336463 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3601: P 708:754(46) ack 42 win 17599 (DF)

11:23:32.336465 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3601: P 708:754(46) ack 42 win 17599 (DF)

11:23:32.339270 802.1Q vlan#4093 P0 10.0.0.99.3601 > 10.0.0.200.ftp: P 42:64(22) ack 754 win 64782 (DF)

11:23:32.339272 802.1Q vlan#4094 P0 10.0.0.99.3601 > 1.1.1.100.ftp: P 42:64(22) ack 754 win 64782 (DF)

11:23:32.340706 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3601: P 754:784(30) ack 64 win 17577 (DF)

11:23:32.340709 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3601: P 754:784(30) ack 64 win 17577 (DF)

11:23:32.341174 802.1Q vlan#4093 P0 10.0.0.99.3601 > 10.0.0.200.ftp: P 64:70(6) ack 784 win 64752 (DF)

11:23:32.341175 802.1Q vlan#4094 P0 10.0.0.99.3601 > 1.1.1.100.ftp: P 64:70(6) ack 784 win 64752 (DF)

11:23:32.346119 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3601: P 784:837(53) ack 70 win 17571 (DF)

11:23:32.346121 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3601: P 784:837(53) ack 70 win 17571 (DF)

11:23:32.348753 802.1Q vlan#4094 P0 1.1.1.100.ftp-data > 10.0.0.99.3602: S 1621272327:1621272327(0) win 16384 <mss 1460,nop,nop,sackOK> (DF)

11:23:32.461857 802.1Q vlan#4093 P0 10.0.0.99.3601 > 10.0.0.200.ftp: . ack 837 win 64699 (DF)

11:23:32.461859 802.1Q vlan#4094 P0 10.0.0.99.3601 > 1.1.1.100.ftp: . ack 837 win 64699 (DF)

11:23:34.186597 802.1Q vlan#4094 P0 1.1.1.100.ftp-data > 10.0.0.99.3602: S 1621272327:1621272327(0) win 16384 <mss 1460,nop,nop,sackOK> (DF)

11:23:38.995204 802.1Q vlan#4094 P0 1.1.1.100.ftp-data > 10.0.0.99.3602: S 1621272327:1621272327(0) win 16384 <mss 1460,nop,nop,sackOK> (DF)

11:23:48.862992 802.1Q vlan#4094 P0 1.1.1.100.ftp > 10.0.0.99.3601: P 837:871(34) ack 70 win 17571 (DF)

nt>

11:23:48.862999 802.1Q vlan#4093 P0 10.0.0.200.ftp > 10.0.0.99.3601: P 837:871(34) ack 70 win 17571 (DF)

11:23:49.019578 802.1Q vlan#4093 P0 10.0.0.99.3601 > 10.0.0.200.ftp: . ack 871 win 64665 (DF)

11:23:49.019582 802.1Q vlan#4094 P0 10.0.0.99.3601 > 1.1.1.100.ftp: . ack 871 win 64665 (DF)

 

 

三、FTP和标准VS(使用ftp profileVS端口21

PASV模式,传输过程中,控制连接和数据连接,都能不断刷新:

[root@bigip:Active] config # b conn show all

VIRTUAL 10.0.0.200:ftp <-> NODE 1.1.1.100:ftp

    CLIENTSIDE 10.0.0.99:3653 <-> 10.0.0.200:ftp

        (pkts,bits) in = (10, 4912), out = (9, 6520)

    SERVERSIDE 10.0.0.99:3653 <-> 1.1.1.100:ftp

        (pkts,bits) in = (9, 6544), out = (10, 4944)

    PROTOCOL tcp   UNIT 1   IDLE 1 (300)   LASTHOP 4093 00:17:a4:e4:86:39

VIRTUAL 10.0.0.200:4461 <-> NODE 1.1.1.100:4461

    CLIENTSIDE 10.0.0.99:3655 <-> 10.0.0.200:4461

        (pkts,bits) in = (536, 231616), out = (974, 9.515M)

    SERVERSIDE 10.0.0.99:3655 <-> 1.1.1.100:4461

        (pkts,bits) in = (974, 9.515M), out = (536, 231616)

    PROTOCOL tcp   UNIT 1   IDLE 1 (300)   LASTHOP 4093 00:17:a4:e4:86:39

[root@bigip:Active] config #

[root@bigip:Active] config #

[root@bigip:Active] config # b conn show all

VIRTUAL 10.0.0.200:ftp <-> NODE 1.1.1.100:ftp

    CLIENTSIDE 10.0.0.99:3653 <-> 10.0.0.200:ftp

        (pkts,bits) in = (10, 4912), out = (9, 6520)

    SERVERSIDE 10.0.0.99:3653 <-> 1.1.1.100:ftp

        (pkts,bits) in = (9, 6544), out = (10, 4944)

    PROTOCOL tcp   UNIT 1   IDLE 0 (300)   LASTHOP 4093 00:17:a4:e4:86:39

VIRTUAL 10.0.0.200:4461 <-> NODE 1.1.1.100:4461

    CLIENTSIDE 10.0.0.99:3655 <-> 10.0.0.200:4461

        (pkts,bits) in = (1072, 463168), out = (1936, 18.83M)

    SERVERSIDE 10.0.0.99:3655 <-> 1.1.1.100:4461

        (pkts,bits) in = (1936, 18.83M), out = (1072, 463168)

PROTOCOL tcp   UNIT 1   IDLE 0 (300)   LASTHOP 4093 00:17:a4:e4:86:39

 

Port模式,控制连接和数据连接也都能正常刷新空闲计时器:

[root@bigip:Active] config # b conn show all

VIRTUAL 10.0.0.200:ftp <-> NODE 1.1.1.100:ftp

    CLIENTSIDE 10.0.0.99:3942 <-> 10.0.0.200:ftp

        (pkts,bits) in = (17, 8264), out = (14, 14792)

    SERVERSIDE 10.0.0.99:3942 <-> 1.1.1.100:ftp

        (pkts,bits) in = (14, 14824), out = (17, 8296)

    PROTOCOL tcp   UNIT 1   IDLE 19 (300)   LASTHOP 4093 00:17:a4:e4:86:39

VIRTUAL 10.0.0.200:ftp <-> NODE 1.1.1.100:ftp

    CLIENTSIDE 10.0.0.99:3947 <-> 10.0.0.200:ftp

        (pkts,bits) in = (11, 5480), out = (9, 6384)

    SERVERSIDE 10.0.0.99:3947 <-> 1.1.1.100:ftp

        (pkts,bits) in = (9, 6416), out = (11, 5512)

    PROTOCOL tcp   UNIT 1   IDLE 5 (300)   LASTHOP 4093 00:17:a4:e4:86:39

VIRTUAL 10.0.0.200:ftp <-> NODE 10.0.0.99:3948

    CLIENTSIDE 1.1.1.100:ftp-data <-> 10.0.0.99:3948

        (pkts,bits) in = (169, 1.716M), out = (86, 37216)

    SERVERSIDE 10.0.0.200:ftp-data <-> 10.0.0.99:3948

        (pkts,bits) in = (86, 37216), out = (169, 1.716M)

    PROTOCOL tcp   UNIT 1   IDLE 5 (300)   LASTHOP 4094 00:0c:29:1d:4a:37

[root@bigip:Active] config #

[root@bigip:Active] config #

pan lang="EN-US">[root@bigip:Active] config # b conn show all

VIRTUAL 10.0.0.200:ftp <-> NODE 1.1.1.100:ftp

    CLIENTSIDE 10.0.0.99:3942 <-> 10.0.0.200:ftp

        (pkts,bits) in = (19, 9168), out = (15, 15472)

    SERVERSIDE 10.0.0.99:3942 <-> 1.1.1.100:ftp

        (pkts,bits) in = (15, 15504), out = (19, 9200)

    PROTOCOL tcp   UNIT 1   IDLE 2 (300)   LASTHOP 4093 00:17:a4:e4:86:39

VIRTUAL 10.0.0.200:ftp <-> NODE 1.1.1.100:ftp

    CLIENTSIDE 10.0.0.99:3947 <-> 10.0.0.200:ftp

        (pkts,bits) in = (11, 5480), out = (9, 6384)

    SERVERSIDE 10.0.0.99:3947 <-> 1.1.1.100:ftp

        (pkts,bits) in = (9, 6416), out = (11, 5512)

    PROTOCOL tcp   UNIT 1   IDLE 0 (300)   LASTHOP 4093 00:17:a4:e4:86:39

VIRTUAL 10.0.0.200:ftp <-> NODE 10.0.0.99:3948

    CLIENTSIDE 1.1.1.100:ftp-data <-> 10.0.0.99:3948

        (pkts,bits) in = (250, 2.492M), out = (130, 56224)

    SERVERSIDE 10.0.0.200:ftp-data <-> 10.0.0.99:3948

        (pkts,bits) in = (130, 56224), out = (250, 2.492M)

    PROTOCOL tcp   UNIT 1   IDLE 0 (300)   LASTHOP 4094 00:0c:29:1d:4a:37

注:windows FTP 客户端效果同上。

 

另:ftp客户端传输期间,自己是不会主动关闭控制连接的,除非收到外部的关闭指示。当客户端上的控制连接被关闭时,客户端也会主动关闭数据连接。理论上,传输过程中,如果中间设备是默默关闭连接的(中间设备不主动发RST包给客户端或者服务器)应不影响数据连接的传输。但当F5使用了ftp profile后,如果强制delete掉控制连接,则数据连接也会被F5删除,如果不使用ftp profile(例如forward VS)则强制删除控制连接时候F5不会主动删除数据连接(此时如果F5向客户端或服务器发送RST包,则客户端或服务器又会主动关闭数据连接,从而导致F5上的数据连接也会被清除)

SOAP 协议1

SOAP 是基于 XML 的简易协议,可使应用程序在 HTTP 之上进行信息交换。

或者更简单地说:SOAP 是用于访问网络服务的协议。

什么是 SOAP?
SOAP 指简易对象访问协议
SOAP 是一种通信协议
SOAP 用于应用程序之间的通信
SOAP 是一种用于发送消息的格式
SOAP 被设计用来通过因特网进行通信
SOAP 独立于平台
SOAP 独立于语言
SOAP 基于 XML
SOAP 很简单并可扩展
SOAP 运许您绕过防火墙
SOAP 将被作为 W3C 标准来发展
Why SOAP?
对于应用程序开发来说,使程序之间进行因特网通信是很重要的。

目前的应用程序通过使用远程过程调用(RPC)在诸如 DCOM 与 CORBA 等对象之间进行通信,但是 HTTP 不是为此设计的。RPC 会产生兼容性以及安全问题;防火墙和代理服务器通常会阻止此类流量。

是通过 HTTP 在应用程序间通信的更好的方法,因为 HTTP 被所有的因特网浏览器及服务器支持。SOAP 就是被创造出来完成这个任务的。 SOAP 提供了一种标准的方法,使得运行在不同的操作系统并使用不同的技术和编程语言的应用程序可以互相进行通信。

Microsoft 和 SOAP
SOAP 是微软 .net 架构的关键元素,用于未来的因特网应用程序开发。

SOAP 1.1 被提交到 W3C
在 2000 年 5 月,UserLand、Ariba、Commerce One、Compaq、Developmentor、HP、IBM、IONA、Lotus、Microsoft 以及 SAP 向 W3C 提交了 SOAP 因特网协议,这些公司期望此协议能够通过使用因特网标准(HTTP 以及 XML)把图形用户界面桌面应用程序连接到强大的因特网服务器,以此来彻底变革应用程序的开发。

W3C 正在发展 SOAP 1.2
首个关于 SOAP 的公共工作草案由 W3C 在 2001 年 12 月发布。如需阅读更多有关在 W3C 的 SOAP 活动的内容,请访问我们的《W3C 教程》。

SOAP 构建模块
一条 SOAP 消息就是一个普通的 XML 文档,包含下列元素:

必需的 Envelope 元素,可把此 XML 文档标识为一条 SOAP 消息
可选的 Header 元素,包含头部信息
必需的 Body 元素,包含所有的调用和响应信息
可选的 Fault 元素,提供有关在处理此消息所发生错误的信息
所有以上的元素均被声明于针对 SOAP 封装的默认命名空间中:

http://www.w3.org/2001/12/soap-envelope

以及针对 SOAP 编码和数据类型的默认命名空间:

http://www.w3.org/2001/12/soap-encoding

语法规则
这里是一些重要的语法规则:

SOAP 消息必须用 XML 来编码
SOAP 消息必须使用 SOAP Envelope 命名空间
SOAP 消息必须使用 SOAP Encoding 命名空间
SOAP 消息不能包含 DTD 引用
SOAP 消息不能包含 XML 处理指令
SOAP 消息的基本结构
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Header>
  …
  …
</soap:Header>

<soap:Body>
  …
  …
  <soap:Fault>
    …
    …
  </soap:Fault>
</soap:Body>

</soap:Envelope>
强制使用的 SOAP 的 Envelope 元素是 SOAP 消息的根元素。
SOAP Envelope 元素
必需的 SOAP 的 Envelope 元素是 SOAP 消息的根元素。它可把 XML 文档定义为 SOAP 消息。
请注意 xmlns:soap 命名空间的使用。它的值应当始终是:http://www.w3.org/2001/12/soap-envelope
并且它可把封装定义为 SOAP 封装:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
  …
  Message information goes here
  …
</soap:Envelope>

xmlns:soap 命名空间
SOAP 消息必须拥有与命名空间 "http://www.w3.org/2001/12/soap-envelope" 相关联的一个 Envelope
元素。
如果使用了不同的命名空间,应用程序会发生错误,并抛弃此消息。

encodingStyle 属性
SOAP 的 encodingStyle 属性用于定义在文档中使用的数据类型。此属性可出现在任何 SOAP
元素中,并会被应用到元素的内容及元素的所有子元素上。SOAP 消息没有默认的编码方式。
语法
soap:encodingStyle="URI"
实例
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

Message information goes here

</soap:Envelope>

可选的 SOAP Header 元素包含头部信息。
SOAP Header 元素
可选的 SOAP Header 元素可包含有关 SOAP 消息的应用程序专用信息(比如认证、支付等)。如果 Header 元素被提供,则它必须是
Envelope 元素的第一个子元素。
注释:所有 Header 元素的直接子元素必须是合格的命名空间。<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Header>
<m:Trans
xmlns:m="http://www.w3schools.com/transaction/"
soap:mustUnderstand="1">234</m:Trans>
</soap:Header>


</soap:Envelope>
上面的例子包含了一个带有一个 "Trans" 元素的头部,它的值是 234,此元素的 "mustUnderstand" 属性的值是 "1"。
SOAP 在默认的命名空间中 ("http://www.w3.org/2001/12/soap-envelope")
定义了三个属性。这三个属性是:actor、 mustUnderstand 以及 encodingStyle。这些被定义在 SOAP 头部的属性可定义容器如何对
SOAP 消息进行处理。

actor 属性
通过沿着消息路径经过不同的端点,SOAP 消息可从某个发送者传播到某个接收者。并非 SOAP 消息的所有部分均打算传送到 SOAP
消息的最终端点,不过,另一个方面,也许打算传送给消息路径上的一个或多个端点。
SOAP 的 actor 属性可被用于将 Header 元素寻址到一个特定的端点。
语法
soap:actor="URI"
实例
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Header>
<m:Trans
xmlns:m="http://www.w3schools.com/transaction/"
soap:actor=&quo

t;http://www.w3schools.com/appml/">
234
</m:Trans>
</soap:Header>


</soap:Envelope>

mustUnderstand 属性
SOAP 的 mustUnderstand 属性可用于标识标题项对于要对其进行处理的接收者来说是强制的还是可选的。
假如您向 Header 元素的某个子元素添加了
"mustUnderstand="1",则它可指示处理此头部的接收者必须认可此元素。假如此接收者无法认可此元素,则在处理此头部时必须失效。
语法
soap:mustUnderstand="0|1"
实例
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Header>
<m:Trans
xmlns:m="http://www.w3schools.com/transaction/"
soap:mustUnderstand="1">
234
</m:Trans>
</soap:Header>


</soap:Envelope>

encodingStyle 属性
SOAP 的 encodingStyle 属性在上一节中已解释过了。

强制使用的 SOAP Body 元素包含实际的 SOAP 消息。

SOAP Body 元素
必需的 SOAP Body 元素可包含打算传送到消息最终端点的实际 SOAP 消息。
SOAP Body 元素的直接子元素可以是合格的命名空间。SOAP
在默认的命名空间中("http://www.w3.org/2001/12/soap-envelope")定义了 Body 元素内部的一个元素。即 SOAP 的
Fault 元素,用于指示错误消息。
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body>
   <m:GetPrice xmlns:m="http://www.w3schools.com/prices">
      <m:Item>Apples</m:Item>
   </m:GetPrice>
</soap:Body>

</soap:Envelope>
上面的例子请求苹果的价格。请注意,上面的 m:GetPrice 和 Item 元素是应用程序专用的元素。它们并不是 SOAP 标准的一部分。
而一个 SOAP 响应应该类似这样:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body>
   <m:GetPriceResponse xmlns:m="http://www.w3schools.com/prices">
      <m:Price>1.90</m:Price>
   </m:GetPriceResponse>
</soap:Body>

</soap:Envelope>

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xrt95050/archive/2008/04/06/2254682.aspx

soap 协议 2

可选的 SOAP Fault 元素用于存留 SOAP 消息的错误和状态信息。

SOAP Fault 元素
来自 SOAP 消息的错误消息被携带于 Fault 元素内部。

如果已提供了 Fault 元素,则它必须是 Body 元素的子元素。在一条 SOAP 消息中,Fault 元素只能出现一次。

SOAP 的 Fault 元素用于下列子元素:

子元素 描述
<faultcode> 供识别故障的代码
<faultstring> 可供人阅读的有关故障的说明
<faultactor> 有关是谁引发故障的信息
<detail> 存留涉及 Body 元素的应用程序专用错误信息

SOAP Fault Codes
在下面定义的 faultcode 值必须用于描述故障时的 faultcode 元素中:

错误 描述
VersionMismatch SOAP Envelope 元素的无效命名空间被发现
MustUnderstand Header 元素的一个直接子元素(带有设置为 "1" 的 mustUnderstand 属性)无法被理解。
Client 消息被不正确地构成,或包含了不正确的信息。
Server 服务器有问题,因此无法处理进行下去。

HTTP 协议
HTTP 在 TCP/IP 之上进行通信。HTTP 客户机使用 TCP 连接到 HTTP 服务器。在建立连接之后,客户机可向服务器发送 HTTP 请求消息:

POST /item HTTP/1.1
Host: 189.123.345.239
Content-Type: text/plain
Content-Length: 200
随后服务器会处理此请求,然后向客户机发送一个 HTTP 响应。此响应包含了可指示请求状态的状态代码:

200 OK
Content-Type: text/plain
Content-Length: 200
在上面的例子中,服务器返回了一个 200 的状态代码。这是 HTTP 的标准成功代码。

假如服务器无法对请求进行解码,它可能会返回类似这样的信息:

400 Bad Request
Content-Length: 0
SOAP HTTP Binding
SOAP 方法指的是遵守 SOAP 编码规则的 HTTP 请求/响应。

HTTP + XML = SOAP

SOAP 请求可能是 HTTP POST 或 HTTP GET 请求。

HTTP POST 请求规定至少两个 HTTP 头:Content-Type 和 Content-Length。

Content-Type
SOAP 的请求和响应的 Content-Type 头可定义消息的 MIME 类型,以及用于请求或响应的 XML 主体的字符编码(可选)。

语法
Content-Type: MIMEType; charset=character-encoding 例子
POST /item HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8Content-Length
SOAP 的请求和响应的 Content-Length 头规定请求或响应主体的字节数。

语法
Content-Length: bytes 例子
POST /item HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 250一个 SOAP 实例在下面的例子中,一个 GetStockPrice 请求被发送到了服务器。此请求有一个 StockName 参数,而在响应中则会返回一个 Price
参数。此功能的命名空间被定义在此地址中: "http://www.example.org/stock"SOAP 请求:POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

  <soap:Body xmlns:m="http://www.example.org/stock">
    <m:GetStockPrice>
      <m:StockName>IBM</m:StockName>
    </m:GetStockPrice>
  </soap:Body>
 
</soap:Envelope>
SOAP 响应:
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

  <soap:Body xmlns:m="http://www.example.org/stock">
    <m:GetStockPriceResponse>
      <m:Price>34.5</m:Price>
    </m:GetStockPriceResponse>
  </soap:Body>
 
</soap:Envelope>

SOAP 概要此教程已向您讲解了如何透过 HTTP 使用 SOAP 在应用程序之间交换信息。您已经学习了有关 SOAP 消息中不同元素和属性的知识。您也学习了如何把 SOAP 作为一种协议来使用以访问 web service。

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/xrt95050/archive/2008/04/06/2254694.aspx

DNS关于递归的一些学习记录[更新中]

缺省配置情况下local DNS(BIND开启递归,如果关闭递归或关闭缓存呢??待测试)在将请求进行递归时时携带的查询包是包含不期望其递归服务器进行再次递归的:


但是本机发送的DNS查询请求是期望local dns进行递归的:

从nslookup的debug信息也可以看出
> www.myf5.net
Server: [192.168.0.189]
Address: 192.168.0.189

————
Got answer:
HEADER:
opcode = QUERY, id = 3, rcode = NOERROR
header flags: response, want recursion, recursion avail.
questions = 1, answers = 1, authority records = 6, additional = 6

QUESTIONS:
www.myf5.net, type = A, class = IN

want recursion:表示本机发出的查询请求携带有期望递归的标记
recursion avail.:表示local dns服务器支持递归
local DNS返回给客户机的响应内容flag部分:



一种环境测试(两级DNS-下级设置上级为根.cap):
local DNS—192.168.0.107 另一个DNS—192.168.0.189 客户机IP 192.168.0.185
其中 local dns修改根列表文件,使其在递归时只递归给192.168.0.189。保持192.168.0.189配置不变即容许递归且根列表正常。
客户机查询www.myf5.cn结果:
> server 192.168.0.107
Default Server: [192.168.0.107]
Address: 192.168.0.107

> www.myf5.cn
Server: [192.168.0.107]
Address: 192.168.0.107

DNS request timed out.
timeout was 2 seconds.
DNS request timed out.
timeout was 2 seconds.
*** Request to [192.168.0.107] timed-out
抓包结果:

解析不了的原因是:
local dns接到解析请求后,发现自己不是myf5.cn的授权,于是执行递归,在本环境中将会把请求递归给192.168.0.189(上图第2个包),在这个转发的递归请求包中包含不希望192.168.0.189再次递归的标记:

所以0.189不会执行递归查询(即使189是打开递归的),0.189此时将直接进行迭代(即把自己所知道的根服务器列表告诉local dns—192.168.0.107):

Local dns接到返回的响应后无法继续处理,因为在它的系统里关于根始终认为是0.189这台服务器,抓包结果也表明local dns没有继续发出其他包到0.189上:

图文全文:DNS记录1.docx