2012年9月12日水曜日

"tcpdump"でPostfixとSESの間のSMTPをのぞいてみる

スズキです。

下記の設定ですが、実は、なかなかうまく行かず、
PostfixからSESにリレー(postfix編)
"tcpdump"を引っ張りだして、SMTPをのぞきながら試行錯誤してました。

実際に、下記のようなメールを送信すると、
# sendmail -t -f suzuki@suz-lab.com suzuki@suz-lab.com
FROM: suzuki@suz-lab.com
TO: suzuki@suz-lab.com
SUBJECT: test11

test11
.
"tcpdump"は下記のような結果になり、SMTPのコマンドやレスポンスが
飛び交っているのがわかると思います。

この方法で、PostfixからSESに送受信されるメッセージを確認しながら
調査することができ、非常に有用でした。

# tcpdump -i lo -X port 2525
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
04:27:53.779637 IP localhost.ms-v-worlds > localhost.54883: Flags [P.], seq 1:66, ack 1, win 256, options [nop,nop,TS val 209967181 ecr 209966469], length 65
 0x0000:  4500 0075 1682 4000 4006 25ff 7f00 0001  E..u..@.@.%.....
 0x0010:  7f00 0001 09dd d663 3268 c307 e123 ee39  .......c2h...#.9
 0x0020:  8018 0100 fe69 0000 0101 080a 0c83 d84d  .....i.........M
 0x0030:  0c83 d585 3232 3020 656d 6169 6c2d 736d  ....220.email-sm
 0x0040:  7470 2e61 6d61 7a6f 6e61 7773 2e63 6f6d  tp.amazonaws.com
 0x0050:  2045 534d 5450 2053 696d 706c 6545 6d61  .ESMTP.SimpleEma
 0x0060:  696c 5365 7276 6963 652d 3236 3338 3138  ilService-263818
 0x0070:  3131 390d 0a                             119..
04:27:53.779959 IP localhost.54883 > localhost.ms-v-worlds: Flags [P.], seq 1:33, ack 66, win 257, options [nop,nop,TS val 209967181 ecr 209967181], length 32
 0x0000:  4500 0054 3bc0 4000 4006 00e2 7f00 0001  E..T;.@.@.......
 0x0010:  7f00 0001 d663 09dd e123 ee39 3268 c348  .....c...#.92h.H
 0x0020:  8018 0101 fe48 0000 0101 080a 0c83 d84d  .....H.........M
 0x0030:  0c83 d84d 4548 4c4f 2069 702d 3130 2d30  ...MEHLO.ip-10-0
 0x0040:  2d30 2d31 3637 2e6c 6f63 616c 646f 6d61  -0-167.localdoma
 0x0050:  696e 0d0a                                in..
04:27:53.957541 IP localhost.ms-v-worlds > localhost.54883: Flags [P.], seq 66:159, ack 33, win 256, options [nop,nop,TS val 209967359 ecr 209967181], length 93
 0x0000:  4500 0091 1684 4000 4006 25e1 7f00 0001  E.....@.@.%.....
 0x0010:  7f00 0001 09dd d663 3268 c348 e123 ee59  .......c2h.H.#.Y
 0x0020:  8018 0100 fe85 0000 0101 080a 0c83 d8ff  ................
 0x0030:  0c83 d84d 3235 302d 656d 6169 6c2d 736d  ...M250-email-sm
 0x0040:  7470 2e61 6d61 7a6f 6e61 7773 2e63 6f6d  tp.amazonaws.com
 0x0050:  0d0a 3235 302d 3842 4954 4d49 4d45 0d0a  ..250-8BITMIME..
 0x0060:  3235 302d 5349 5a45 2031 3034 3835 3736  250-SIZE.1048576
 0x0070:  300d 0a32 3530 2d41 5554 4820 504c 4149  0..250-AUTH.PLAI
 0x0080:  4e20 4c4f 4749 4e0d 0a32 3530 204f 6b0d  N.LOGIN..250.Ok.
 0x0090:  0a                                       .
04:27:53.957918 IP localhost.54883 > localhost.ms-v-worlds: Flags [P.], seq 33:134, ack 159, win 257, options [nop,nop,TS val 209967359 ecr 209967359], length 101
 0x0000:  4500 0099 3bc1 4000 4006 009c 7f00 0001  E...;.@.@.......
 0x0010:  7f00 0001 d663 09dd e123 ee59 3268 c3a5  .....c...#.Y2h..
 0x0020:  8018 0101 fe8d 0000 0101 080a 0c83 d8ff  ................
 0x0030:  0c83 d8ff 4155 5448 2050 4c41 494e 2041  ....AUTH.PLAIN.X
 0x0040:  XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX  XXXXXXXXXXXXXXXX
 0x0050:  XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX  XXXXXXXXXXXXXXXX
 0x0060:  XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX  XXXXXXXXXXXXXXXX
 0x0070:  XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX  XXXXXXXXXXXXXXXX
 0x0080:  XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX  XXXXXXXXXXXXXXXX
 0x0090:  5456 5164 6e70 4a0d 0a                   XXXXXXX..
04:27:54.160231 IP localhost.ms-v-worlds > localhost.54883: Flags [P.], seq 159:191, ack 134, win 256, options [nop,nop,TS val 209967561 ecr 209967359], length 32
 0x0000:  4500 0054 1686 4000 4006 261c 7f00 0001  E..T..@.@.&.....
 0x0010:  7f00 0001 09dd d663 3268 c3a5 e123 eebe  .......c2h...#..
 0x0020:  8018 0100 fe48 0000 0101 080a 0c83 d9c9  .....H..........
 0x0030:  0c83 d8ff 3233 3520 4175 7468 656e 7469  ....235.Authenti
 0x0040:  6361 7469 6f6e 2073 7563 6365 7373 6675  cation.successfu
 0x0050:  6c2e 0d0a                                l...
04:27:54.160308 IP localhost.54883 > localhost.ms-v-worlds: Flags [P.], seq 134:183, ack 191, win 257, options [nop,nop,TS val 209967562 ecr 209967561], length 49
 0x0000:  4500 0065 3bc2 4000 4006 00cf 7f00 0001  E..e;.@.@.......
 0x0010:  7f00 0001 d663 09dd e123 eebe 3268 c3c5  .....c...#..2h..
 0x0020:  8018 0101 fe59 0000 0101 080a 0c83 d9ca  .....Y..........
 0x0030:  0c83 d9c9 4d41 494c 2046 524f 4d3a 3c73  ....MAIL.FROM:<s
 0x0040:  757a 756b 6940 7375 7a2d 6c61 622e 636f  uzuki@suz-lab.co
 0x0050:  6d3e 2053 495a 453d 3330 3520 4155 5448  m>.SIZE=305.AUTH
 0x0060:  3d3c 3e0d 0a                             =<>..
04:27:54.337986 IP localhost.ms-v-worlds > localhost.54883: Flags [P.], seq 191:199, ack 183, win 256, options [nop,nop,TS val 209967739 ecr 209967562], length 8
 0x0000:  4500 003c 1688 4000 4006 2632 7f00 0001  E..<..@.@.&2....
 0x0010:  7f00 0001 09dd d663 3268 c3c5 e123 eeef  .......c2h...#..
 0x0020:  8018 0100 fe30 0000 0101 080a 0c83 da7b  .....0.........{
 0x0030:  0c83 d9ca 3235 3020 4f6b 0d0a            ....250.Ok..
04:27:54.338028 IP localhost.54883 > localhost.ms-v-worlds: Flags [P.], seq 183:213, ack 199, win 257, options [nop,nop,TS val 209967739 ecr 209967739], length 30
 0x0000:  4500 0052 3bc3 4000 4006 00e1 7f00 0001  E..R;.@.@.......
 0x0010:  7f00 0001 d663 09dd e123 eeef 3268 c3cd  .....c...#..2h..
 0x0020:  8018 0101 fe46 0000 0101 080a 0c83 da7b  .....F.........{
 0x0030:  0c83 da7b 5243 5054 2054 4f3a 3c73 757a  ...{RCPT.TO:<suz
 0x0040:  756b 6940 7375 7a2d 6c61 622e 636f 6d3e  uki@suz-lab.com>
 0x0050:  0d0a                                     ..
04:27:54.516150 IP localhost.ms-v-worlds > localhost.54883: Flags [P.], seq 199:207, ack 213, win 256, options [nop,nop,TS val 209967917 ecr 209967739], length 8
 0x0000:  4500 003c 168a 4000 4006 2630 7f00 0001  E..<..@.@.&0....
 0x0010:  7f00 0001 09dd d663 3268 c3cd e123 ef0d  .......c2h...#..
 0x0020:  8018 0100 fe30 0000 0101 080a 0c83 db2d  .....0.........-
 0x0030:  0c83 da7b 3235 3020 4f6b 0d0a            ...{250.Ok..
04:27:54.516192 IP localhost.54883 > localhost.ms-v-worlds: Flags [P.], seq 213:219, ack 207, win 257, options [nop,nop,TS val 209967917 ecr 209967917], length 6
 0x0000:  4500 003a 3bc4 4000 4006 00f8 7f00 0001  E..:;.@.@.......
 0x0010:  7f00 0001 d663 09dd e123 ef0d 3268 c3d5  .....c...#..2h..
 0x0020:  8018 0101 fe2e 0000 0101 080a 0c83 db2d  ...............-
 0x0030:  0c83 db2d 4441 5441 0d0a                 ...-DATA..
04:27:54.516200 IP localhost.ms-v-worlds > localhost.54883: Flags [.], ack 219, win 256, options [nop,nop,TS val 209967917 ecr 209967917], length 0
 0x0000:  4500 0034 168b 4000 4006 2637 7f00 0001  E..4..@.@.&7....
 0x0010:  7f00 0001 09dd d663 3268 c3d5 e123 ef13  .......c2h...#..
 0x0020:  8010 0100 01a3 0000 0101 080a 0c83 db2d  ...............-
 0x0030:  0c83 db2d                                ...-
04:27:54.693809 IP localhost.ms-v-worlds > localhost.54883: Flags [P.], seq 207:244, ack 219, win 256, options [nop,nop,TS val 209968095 ecr 209967917], length 37
 0x0000:  4500 0059 168c 4000 4006 2611 7f00 0001  E..Y..@.@.&.....
 0x0010:  7f00 0001 09dd d663 3268 c3d5 e123 ef13  .......c2h...#..
 0x0020:  8018 0100 fe4d 0000 0101 080a 0c83 dbdf  .....M..........
 0x0030:  0c83 db2d 3335 3420 456e 6420 6461 7461  ...-354.End.data
 0x0040:  2077 6974 6820 3c43 523e 3c4c 463e 2e3c  .with.<CR><LF>.<
 0x0050:  4352 3e3c 4c46 3e0d 0a                   CR><LF>..
04:27:54.693897 IP localhost.54883 > localhost.ms-v-worlds: Flags [P.], seq 219:527, ack 244, win 257, options [nop,nop,TS val 209968095 ecr 209968095], length 308
 0x0000:  4500 0168 3bc5 4000 4006 ffc8 7f00 0001  E..h;.@.@.......
 0x0010:  7f00 0001 d663 09dd e123 ef13 3268 c3fa  .....c...#..2h..
 0x0020:  8018 0101 ff5c 0000 0101 080a 0c83 dbdf  .....\..........
 0x0030:  0c83 dbdf 5265 6365 6976 6564 3a20 6279  ....Received:.by
 0x0040:  2069 702d 3130 2d30 2d30 2d31 3637 2e6c  .ip-10-0-0-167.l
 0x0050:  6f63 616c 646f 6d61 696e 2028 506f 7374  ocaldomain.(Post
 0x0060:  6669 782c 2066 726f 6d20 7573 6572 6964  fix,.from.userid
 0x0070:  2030 290d 0a09 6964 2045 4543 3145 4243  .0)...id.EEC1EBC
 0x0080:  363b 2057 6564 2c20 3132 2053 6570 2032  6;.Wed,.12.Sep.2
 0x0090:  3031 3220 3034 3a32 373a 3532 202b 3039  012.04:27:52.+09
 0x00a0:  3030 2028 4a53 5429 0d0a 4652 4f4d 3a20  00.(JST)..FROM:.
 0x00b0:  7375 7a75 6b69 4073 757a 2d6c 6162 2e63  suzuki@suz-lab.c
 0x00c0:  6f6d 0d0a 544f 3a20 7375 7a75 6b69 4073  om..TO:.suzuki@s
 0x00d0:  757a 2d6c 6162 2e63 6f6d 0d0a 5355 424a  uz-lab.com..SUBJ
 0x00e0:  4543 543a 2074 6573 7431 310d 0a4d 6573  ECT:.test11..Mes
 0x00f0:  7361 6765 2d49 643a 203c 3230 3132 3039  sage-Id:.<201209
 0x0100:  3131 3139 3237 3532 2e45 4543 3145 4243  11192752.EEC1EBC
 0x0110:  3640 6970 2d31 302d 302d 302d 3136 372e  6@ip-10-0-0-167.
 0x0120:  6c6f 6361 6c64 6f6d 6169 6e3e 0d0a 4461  localdomain>..Da
 0x0130:  7465 3a20 5765 642c 2031 3220 5365 7020  te:.Wed,.12.Sep.
 0x0140:  3230 3132 2030 343a 3237 3a31 3520 2b30  2012.04:27:15.+0
 0x0150:  3930 3020 284a 5354 290d 0a0d 0a74 6573  900.(JST)....tes
 0x0160:  7431 310d 0a2e 0d0a                      t11.....
04:27:55.090844 IP localhost.ms-v-worlds > localhost.54883: Flags [P.], seq 244:313, ack 527, win 265, options [nop,nop,TS val 209968492 ecr 209968095], length 69
 0x0000:  4500 0079 168e 4000 4006 25ef 7f00 0001  E..y..@.@.%.....
 0x0010:  7f00 0001 09dd d663 3268 c3fa e123 f047  .......c2h...#.G
 0x0020:  8018 0109 fe6d 0000 0101 080a 0c83 dd6c  .....m.........l
 0x0030:  0c83 dbdf 3235 3020 4f6b 2030 3030 3030  ....250.Ok.00000
 0x0040:  3133 3962 3663 6435 3961 652d 6239 6332  139b6cd59ae-b9c2
 0x0050:  3433 6533 2d38 6433 382d 3466 3662 2d62  43e3-8d38-4f6b-b
 0x0060:  6239 642d 6231 3031 6365 3132 3536 6336  b9d-b101ce1256c6
 0x0070:  2d30 3030 3030 300d 0a                   -000000..
04:27:55.091017 IP localhost.54883 > localhost.ms-v-worlds: Flags [P.], seq 527:533, ack 313, win 257, options [nop,nop,TS val 209968492 ecr 209968492], length 6
 0x0000:  4500 003a 3bc6 4000 4006 00f6 7f00 0001  E..:;.@.@.......
 0x0010:  7f00 0001 d663 09dd e123 f047 3268 c43f  .....c...#.G2h.?
 0x0020:  8018 0101 fe2e 0000 0101 080a 0c83 dd6c  ...............l
 0x0030:  0c83 dd6c 5155 4954 0d0a                 ...lQUIT..
04:27:55.269588 IP localhost.ms-v-worlds > localhost.54883: Flags [P.], seq 313:322, ack 534, win 265, options [nop,nop,TS val 209968671 ecr 209968492], length 9
 0x0000:  4500 003d 1691 4000 4006 2628 7f00 0001  E..=..@.@.&(....
 0x0010:  7f00 0001 09dd d663 3268 c43f e123 f04e  .......c2h.?.#.N
 0x0020:  8018 0109 fe31 0000 0101 080a 0c83 de1f  .....1..........
 0x0030:  0c83 dd6c 3232 3120 4279 650d 0a         ...l221.Bye..

実はELB関連の調査でも重宝してました...
--------
http://www.suz-lab.com

0 コメント: