TCPIP 28 Send Mail Transfer Protocol Computer Network

  • Slides: 45
Download presentation
TCP/IP 통신망 특론 제 28장 Send Mail Transfer Protocol Computer Network Lab. 1

TCP/IP 통신망 특론 제 28장 Send Mail Transfer Protocol Computer Network Lab. 1

목차 n Introduction n SMTP Protocol n SMTP Examples n SMTP Futures n Summary

목차 n Introduction n SMTP Protocol n SMTP Examples n SMTP Futures n Summary Computer Network Lab. 2

Introduction 인터넷에서 가장 많이 사용되는 응용 프로그램 n TCP 연결의 약 1/2가 SMTP에 관한

Introduction 인터넷에서 가장 많이 사용되는 응용 프로그램 n TCP 연결의 약 1/2가 SMTP에 관한 것 [Caceres et al. 1991] n n user agent : MH, Berkely Mail, Elm, Mush n MTA(message transfer agent) : Sendmail Computer Network Lab. 3

Introduction (계속) user at a terminal user agent queue of mail to be sent

Introduction (계속) user at a terminal user agent queue of mail to be sent 송신자 message transter agent client TCP 연결 TCP port 25 user at a terminal 수신자 Computer Network Lab. user agent queue of mail to be sent message transter agent server 4

Introduction (계속) n n RFC 821 [Postel 1982] l SMTP 프로토콜 규정 l 양측

Introduction (계속) n n RFC 821 [Postel 1982] l SMTP 프로토콜 규정 l 양측 MTA가 단일 TCP 연결을 통해 어떻게 통신할 것 인가를 기술 RFC 822 [Crocker 1982] l MTA 간의 RFC 821을 이용한 전자 메일 메시지의 format을 정의 Computer Network Lab. 5

SMTP Protocol - Example sun % mail -v rstevens@noao. edu To: rstevens@noao. edu Subject:

SMTP Protocol - Example sun % mail -v rstevens@noao. edu To: rstevens@noao. edu Subject: testing 1, 2, 3. . Sending letter. . . rstevens@noao. edu… user agent를 invoke user agent 의 출력 제목입력 대기 user agent가 추가하는 빈 라인 본문 마침표만 있는줄: 본문의 끝임을 알림 user agent의 출력 다음부터 MAT(Sendmail)의 출력이다. Connecting to mailhost via ether. . . Trying 140. 252. 1. 54. . . connected. 220 noao. edu Sendmail 4. 1/SAG-Noao. G 89 ready at Mon, 19 Jul 93 12: 47: 34 MST >>> HELO sun. tuc. noao. edu. 250 noao. edu HELLO sun. tuc. noao. edu. , pleased to meet you >>> MAIL From: <rstevens@sun. tuc. noao. edu> 250 <rstevens@sun. tuc. noao. edu>. . . Sender ok >>> RCPT To: <rstevens@noao. edu> 250 <rstevens@noao. edu>. . . Recipient ok >>>로 시작되는 줄: SMTP 클라이언트가 보내는 명령어 3자리 응답코드로 시작되는 줄: SMTP 서버로부터의 응답 >>> DATA 354 Enter mail, end with ". " on a line by itself >>>. 250 Mail accepted >>> QUIT 221 noao. edu delivering mail rstevens@noao. edu. . . Sent sent. Computer Network Lab. user agent의 출력 7

sun. 1064 2 4 6 8 11 12 14 16 PSH 1: 78(77) ack

sun. 1064 2 4 6 8 11 12 14 16 PSH 1: 78(77) ack 1 4. 1 / … rn 220 noao. edu Sendmail PSH 1: 25(24) ack 78 HELO sun. tuc. noao. edu. rn k 25 PSH 78: 137(59) ac LO … rn 250 noao. edu HEL PSH 25: 64(39) ack 137 MAIL From: <rstevens@sun. tuc. noao. edu>rn PSH 137: 183(46) ack 64 ao. edu>. . . rn 250 <rstevens@sun. tuc. no PSH 64: 93(29) ack 183 RCPT To: <rstevens@noao. edu>rn PSH 183: 224(41) ack 93 rn stevens@noao. edu> … 250 <r. PSH 93: 99(6) ack 224 DATA rn ack 99 PSH 224: 274(50) ack 99 … rn 354 Enter mail, end with ack 274 PSH 99: 492(393) ack 274 (body of mail message) ack 492 PSH 492: 495(3) ack 274. rn : 29 PSH 274 3(19) ack 495 250 Mail accepted rn PSH 495: 501(6) ack 293 QUIT rn ack 501 PSH 293: 323(30) ering mail rn 221 noao. edu deliv 1 noao. edu 3 5 7 9 10 13 15 17 9

SMTP Protocol - Example (계속) n 세그먼트 12에서 393 byte 전송 내용 Received: by

SMTP Protocol - Example (계속) n 세그먼트 12에서 393 byte 전송 내용 Received: by sun. tuc. noao. edu. (4. 1/SMT-4. 1) id AA 00502; Mon, 19 Jul 93 12: 47: 32 MST Message-Id: <9307191947. AA 00502@sun. tuc. noao. edu. > From: rstevens@sun. tuc. noao. edu (Richard Stevens) Date: Mon, 19 Jul 1993 12: 47: 31 -0700 Reply-To: rstevens@noao. edu X-Phone: +1 602 676 1676 X-Mailer: Mail User's Shell (7. 2. 5 10/14/92) To: rstevens@noao. edu Subject: testing MTA user agent 1, 2, 3. n 앞의 3줄은 MTA가, 그 다음 9줄은 user agent가 첨가. Computer Network Lab. 10

SMTP Protocol - Envelope, Header, Body n 봉투(Envelope) l 배달을 위해 MTA가 사용 l

SMTP Protocol - Envelope, Header, Body n 봉투(Envelope) l 배달을 위해 MTA가 사용 l 예에서 두개의 SMTP 명령에 의해 기술됨 MAIL From: <rstevens@sun. tuc. noao. edu> RCPT To: <rstevens@noao. edu> l RFC 821 ä 봉투의 내용과 해석을 기술 ä TCP 연결을 통한 우편 교환을 위해 사용되는 프로토콜을 기 술 Computer Network Lab. 14

SMTP Protocol -Envelope, Header, Body(계속) n Header l user agent가 사용 l 예에서 ä

SMTP Protocol -Envelope, Header, Body(계속) n Header l user agent가 사용 l 예에서 ä Received, Message-Id, From, Date, Reply-To, X-Phone, XMailer, To, Subject l 형태 ä l 헤더이름 : 필드값 RFC 822 ä 헤더 필드 형식과 설명을 기술 ä X로 시작하는 필드는 사용자가, 나머지는 RFC 822가 정의 Computer Network Lab. 15

SMTP Protocol -Relay Agents n Relay Agent 중계 시스템 이외의 시스템의 MTA 구성을 단순화하

SMTP Protocol -Relay Agents n Relay Agent 중계 시스템 이외의 시스템의 MTA 구성을 단순화하 기 위함 l 개개의 시스템을 감추고(hiding), 메일 hub로 동작하는 하나의 시스템을 허용 l sun % host mailhost. tuc. noao. edu l CNAME A noao. edu 140. 252. 1. 54 canonical name its real IP address 호스트가 변경되어도 DNS이름만 변경하면 됨. Computer Network Lab. 18

user at a terminal user agent sending host queue of mail to be sent

user at a terminal user agent sending host queue of mail to be sent local MTA queue of mail relay MTA local MTA one orgnization across the Internet queue of mail relay MTA local MTA one orgnization user agent user at a terminal queue of mail to be sent receiving host 19 19

SMTP Examples - MX Records n 인터넷에 직접 연결되지 않은 호스트 l RFC 974

SMTP Examples - MX Records n 인터넷에 직접 연결되지 않은 호스트 l RFC 974 [Partrige 1986]: MTA에 의한 MX 레코드 제어 l mlfarm. com은 인터넷에 직접 연결되어 있지 않고 우편 전송자로 연결하는 MX 레코드를 갖는다. sun % host -a -v -t mx mlfarm. com The following answer is not autoritative: mlfarm. com 86388 Additional information: mecury. hsi. com 86388 hsi 86. hsi. com 172762 l IN IN MX 10 mercury. hsi. com MX 15 hsi 86. hsi. com IN IN A A 143. 122. 1. 91 143. 122. 1. 6 다른 우선순위를 가진 2개의 MX 레코드가 있음 Computer Network Lab. 21

SMTP Examples - MX Records (계속) sun % mail -v ron@mlfarm. com To: ron@mlfarm.

SMTP Examples - MX Records (계속) sun % mail -v ron@mlfarm. com To: ron@mlfarm. com Subject: MX test message. Sending letter. . . ron@mlfarm. com. . . Connecting to mlfarm. com via tcp. . . mail exchanger is mercury. hsi. com Trying 143. 122. 1. 91. . . connected. 220 mercury. hsi. com … l -v flag to see what the MTA does the body of the message is typed here (not shown) period on a line by itself to terminate message the MX records are found first tries one with lower preference remainder is normal SMTP mail transfer MTA는 낮은 우선순위부터 시작 Computer Network Lab. 22

SMTP Examples - MX Records (계속) recursion-desired flag is set 1 sun. 1624 >

SMTP Examples - MX Records (계속) recursion-desired flag is set 1 sun. 1624 > noao. edu. 53: 2+ MX? mlfarm. com. (28) 2 noao. edu. 53 > sun. 1624: 2* 2/0/2 MX mercury. hsi. com. 10 (113) 3 sun. 1143 > mercury. hsi. com. 25: S 1617536000: 1617536000(0) win 4096 4 mercury. hsi. com. 25 > sun. 1143: S 1832064000: 1832064000(0) ack 1617536001 win 16384 5 sun. 1143 > mercury. hsi. com. 25: . ack 1 win 4096 6 mercury. hsi. com. 25 > sun. 1143: P 1: 90(89) ack 1 win 16384 Computer Network Lab. authoritative bit set 23

SMTP Examples - MX Records (계속) l 줄 2의 2/0/2 ä 첫번째 2: 2

SMTP Examples - MX Records (계속) l 줄 2의 2/0/2 ä 첫번째 2: 2 answer RRs (2 MX host name) ä 두번째 0: 0 authority RRs ä 세번째 2: 2 additional RRs (the IP address of the 2 hosts) l 줄 3 -5: mercury. his. com의SMTP 서버와의 TCP 연결설정 l mercury. his. com은 메일을 받은 후에 mlfarm. com에 전달해 야한다. (UUCP 를 많이 이용) RFC 974는 MTA는 MX 레코드를 요구해야하고, 찾지 못하면 목적지 호스트로 배달을 시도해야한다고 기술 l MTA는 또한 반드시 CNAME 레코드도 다뤄야한다. l Computer Network Lab. 24

SMTP Examples - MX Records (계속) l BSD/386 rstevens@mailhost. tuc. noao. edu에서 MTA(Sendmail)의 수행단계

SMTP Examples - MX Records (계속) l BSD/386 rstevens@mailhost. tuc. noao. edu에서 MTA(Sendmail)의 수행단계 ä 1. Sendmail은 DNS에게 mailhost. tuc. noao. edu에 대한 CNAME레코드 요구 sun % host - t cname mailhost. tuc. noao. edu CNAME noao. edu ä 2. DNS 질의는 noao. edu에 대한 CNAME 레코드를 발생하고, 없다는 응답을 받는다. ä 3. Sendmail은 DNS에게 noao. edu에 대한 MX 레코드를 요구하고, 하 나의 MX 레코드를 얻는다. sun % host -t mx noao. edu MX noao. edu ä 4. Sendmail은 noao. edu에 대한 IP주소를 DNS에 질의하여 140. 252. 1. 54를 받는다(스텝 3의 additional RR) ä 5. 140. 252. 1. 54로 SMTP 연결 초기화, 메일 전송 Computer Network Lab. 25

SMTP Examples - MX Records (계속) n 다운된 호스트 l 예 sun % host

SMTP Examples - MX Records (계속) n 다운된 호스트 l 예 sun % host -a -v -t mx sun. tuc. noao. edu 86400 IN Additional Information: sun. tuc. noao. edu 86400 IN MX 0 sun. tuc. noao. edu MX 10 noao. edu A A A 140. 252. 1. 29 140. 252. 13. 33 140. 252. 1. 54 vangogh % mail -v rstevens@sun. tuc. noao. edu A test to a host that's down. EOT rstenens@sun. tuc. noao. edu. . . Connecting to sun. tuc. noao. edu. (smtp). . . rstevens@sun. tuc. noao. edu. . . Connecting to noao. edu. (smtp). . . 220 noao. edu … reminder is normal SMTP mail transfer Computer Network Lab. 26

SMTP Examples - MX Records (계속) 1 0. 0 2 0. 000621 (0. 0006)

SMTP Examples - MX Records (계속) 1 0. 0 2 0. 000621 (0. 0006) 3 0. 300203 (0. 2996) 4 0. 300620 (0. 0004) l vangogh. 3873 > 140. 252. 1. 29. 25: S 2358303745: 2358303745(0). . . 140. 252. 1. 29. 25 > vangogh. 3873: R 0: 0(0) ack 2358303746 win 0 vangogh. 3874 > 140. 252. 13. 33. 25: S 2358367745: 2358367745(0). . . 140. 252. 13. 33. 25 > vangogh. 3874: R 0: 0(0) ack 2358367746 win 0 SMTP 클라이언트의 개방 실패 원인이 호스트 서버의 다운이라면 ä 클라이언트는 총 75초 동안 SYN을 140. 252. 1. 29에 ä 다음 75초 동안은 140. 252. 13. 33에 전송 ä 150초 후에도 응답이 없으면 그다음 순위의 다른 MX 레코드 로 이동 Computer Network Lab. 27

SMTP Examples - VRFY, EXPN n VRFY l n mail을 보내지 않고 수신자 주소가

SMTP Examples - VRFY, EXPN n VRFY l n mail을 보내지 않고 수신자 주소가 옳은지를 검증 EXPN l mail을 주어진 목록으로 보내지 않고 mailing list를 확 장 Computer Network Lab. 28

SMTP Examples - VRFY, EXPN (계속) n sun예 % telnet vangogh. cs. berkeley. edu

SMTP Examples - VRFY, EXPN (계속) n sun예 % telnet vangogh. cs. berkeley. edu 25 220 -vangogh. CS. Berkeley. EDU Sendmail 8. 1 C/6. 32 ready at Tue, 3 Aug 1993 14: 59: 12 -0700 220 ESMTP spoken here helo bsdi. tuc. noao. edu 250 vangogh. CD. Berkeley. EDU Hello sun. tuc. noao. edu[140. 252. 1. 29], pleased to meet you vrfy nosuchname 550 nosuchname. . . User unknown vrfy rstevens 250 Richard Stevens <rstevens@vangogh. CS. Berkeley. EDU> expn rstevens 250 Richard Stevens <rstevens@noao. edu> l HELO에 잘못된 이름: 서버는 IP 주소를 기준으로 연결 l EXPN: . forward에 따라 우편의 진행 방향을 출력 Computer Network Lab. 29

SMTP Futures -Envelope Changes n 봉투변화: Extended SMTP l RFC 1425 [Klensin et al.

SMTP Futures -Envelope Changes n 봉투변화: Extended SMTP l RFC 1425 [Klensin et al. 1993 a] l HELO EHLO l 응답으로 250 응답 코드와 함께 보통 여러줄의 keyword를 기술한다. l keyword는 서버가 지원하는 SMTP 확장을 기술한다. l RFC에서 설명되어지며, IANA(Internet Assigned Number Authority)에 등록된다. Computer Network Lab. 30

SMTP Futures -Envelope Changes (계속) l 8 BITMIME 키워드 ehlo sun. tuc. noao. edu

SMTP Futures -Envelope Changes (계속) l 8 BITMIME 키워드 ehlo sun. tuc. noao. edu 250 -ymir. claremont. edu 250 -8 BITMIME 250 -EXPN 250 -HELP 250 -XADR 250 SIZE 461544960 ä RFC 1426[Klensin ot al. 1993 b] ä MAIL FROM 명령에 키워드 BODY를 삽입하도록 허락 ¡본문의 내용이 NVT ASCII인지 8 -비트 데이터인지 구분 ä 이 키워드가 응답되지 않으면, 클라이언트는 NVT ASCII이외 의 어떤 문자도 보낼 수 없다. l X로 시작하는 모든 키워드는 local SMTP 확장을 참조한다. Computer Network Lab. 32

SMTP Futures -Header Changes n 헤더변화: Non-ASCII Characters l RFC 1522[Moore 1993] ä RFC

SMTP Futures -Header Changes n 헤더변화: Non-ASCII Characters l RFC 1522[Moore 1993] ä RFC 822 메시지 헤더에 non-ASCII 문자들을 보내는 방법을 기술 l 주용도 ä 송신자와 수신자, 그리고 제목에 추가문자를 허용하기 위한 것 Computer Network Lab. 33

SMTP Futures -Header Changes (계속) Encoding of 6 -bit values(base-64 encoding) Computer Network Lab.

SMTP Futures -Header Changes (계속) Encoding of 6 -bit values(base-64 encoding) Computer Network Lab. 35

SMTP Futures -Header Changes (계속) RFC 1552에 기재된 2개의 부호화 예제 From: =? US-ASCII?

SMTP Futures -Header Changes (계속) RFC 1552에 기재된 2개의 부호화 예제 From: =? US-ASCII? Q? Keith_Moore? = <moore@cs. utk. edu> To: =? ISO-8859 -1? =Q? Keld_J=F 8 rn_Simonsen? = <keld@dkuug. dk> CC: =? ISO-8859 -1? =Q? Andr=E 9_? = Pirard <PARARD@vm 1. ulg. ac. be> Subject: =? ISO-8859 -1? B? SWYge. W 91 IGNhbi. By. ZWFk. IHRoa. XMge. W 8=? = =? ISO-8859 -2? B? d. SB 1 bm. R 1 Cn. N 0 YW 5 k. IHRo. ZSBle. GFTc. Gxl. Lg==? = user agent의 출력 From: Keith Moore <moore@cs. utk. edu> To: Keld J 0 rn Simonsen <keld@dkuug. dk> CC: André Pirard <PIRARD@vm 1. ulg. ac. be> Subject: If you can read this you understand the example. 1. SWYg (S=0 x 12, W=0 x 16, Y=0 x 18, g=0 x 20)를 6비트 값으로 변환 2. 010010, 010110, 011000, 100000 를 8비트/바이트로 재 조합 3. 01001001, 0110 , 00100000 0 x 49, 0 x 66, 0 x 20 ASCII 값으로 I, f, 공백 Computer Network Lab. 36

SMTP Futures -Body Changes n 본문 변경: MIME(Multipurpose Internet Mail Extentions) l RFC 1521[Borenstein

SMTP Futures -Body Changes n 본문 변경: MIME(Multipurpose Internet Mail Extentions) l RFC 1521[Borenstein and Freed 1993] ä RFC 822는 본문을 structure 없는 NVT ASCII 텍스트로 기술 ä RFC 1521은 본문에 structure를 허용 MIME는 RFC 822에 따르는 새로운 헤더를 추가함으 로써 수신자에게 본문에 구조가 있음을 알린다. ( 어떤 확장도 요구하지 않는다) l 본문은 내용과 상관없이 NVT ASCII로 전송된다. l extended SMTP SIZE 명령과 non-ASCII 헤더를 이용 (MIME에 의해 요구된 확장이 아니다) l Computer Network Lab. 37

SMTP Futures -Body Changes (계속) l MIME의 5개 헤더 필드 ä Mime-Version: , Content-Type:

SMTP Futures -Body Changes (계속) l MIME의 5개 헤더 필드 ä Mime-Version: , Content-Type: , Content-Transfer-Encoding: , Content-ID: , Content-Description: ä 예. Mime-Version: 1. 0 MIME version Content-Type: TEXT/PLAIN; charset=US-ASCII plain ASCII text ¡PLAIN: subtype ¡charset=US-ASCII : parameter Computer Network Lab. 38

SMTP Futures -Body Changes (계속) MIME Content-Type과 subtype Computer Network Lab. 39

SMTP Futures -Body Changes (계속) MIME Content-Type과 subtype Computer Network Lab. 39

SMTP Futures -Body Changes (계속) 본문을 위한 Content-Type과 Content-Transfer-Encoding 은 독립적이다. l RFC 1521에

SMTP Futures -Body Changes (계속) 본문을 위한 Content-Type과 Content-Transfer-Encoding 은 독립적이다. l RFC 1521에 정의된 5개의 다른 encoding 형식 l ä 1. 디폴트인 7비트 NVT ASCII ä 2. quoted-printable (문자의 일부만이 8번째 비트가 설정) ä 3. base-64 ä 4. non-ASCII 형태의 8번째 비트가 설정된 문자열 ä 5. binary encoding l RFC 1521은 non-ASCII 텍스트에 대해서는 quotedprintable를, image, audio, video, octet-stream application data에 대해서는 base-64를 권고한다. (RFC 822에 따르는 MTA와의 최대한의 호환을 위해) Computer Network Lab. 40

To: rfc-dist@nic. ddn. mil Subject: RFC 1479 on IDPR Protocol Mime-Version: 1. 0 Content-Type:

To: rfc-dist@nic. ddn. mil Subject: RFC 1479 on IDPR Protocol Mime-Version: 1. 0 Content-Type: Multipart/Mixed; Boundart="Next. Part" Date: Fri, 23 Jul 93 12: 17: 43 PDT From: "Joyce K. Reynolds" <jkrey@isi. edu> --Next. Part the first boundary A new Requwst for Comments is now available in online RFC libraries. . (details here on the new RFC) Below is the dara which will enable a MIME compliant Mail Reader implementation to automatically retrieve the ASCII version of the RFCs. 첫번째 boundary 이후에 헤더필드가 없고 공백이므로 첫번째와 두번째 boundary 사이는 text/plain으로 간주된다. --Next. Part the second boundary Content-Type: Multipart/Alternative; Boundary="Other. Access" a nested multipart message with a new boundary --Other. Access Content-Type: Message/External-body; access-type="mail-server"; server="mail-server@nisc. sri. com" Content-Type: text/plain SEND rfc 1479. txt --Other. Access Content-Type: Message/External-body; name="rfc 1479. txt"; site="ds. internic. net"; access-type="anon-ftp"; directory="rfc" Content-Type: text/plain --Other. Access---Next. Part-- multipart nested multipart the final boundary 41 41

Summary n user agent, MTA n Envelope, Header, Body n Extended SMTP n non-ASCII

Summary n user agent, MTA n Envelope, Header, Body n Extended SMTP n non-ASCII header n MIME Computer Network Lab. 42

Review n CNAME record: l n 규범적 이름(canonical name)을 의미, 도메인 이름으로 표시 recursion

Review n CNAME record: l n 규범적 이름(canonical name)을 의미, 도메인 이름으로 표시 recursion desired: name server에 대해서 자기 자신이 조회를 처리하도록 지시 l p. 258 DNS 헤더의 플래그 필드 l Computer Network Lab. 45