DNS & mail
97/12/17
Agenda DNS & mail
n n
InternetWeek ’98 Tutorial 1998/12/15 Motonori Nakamura
[email protected] [email protected]
n n
Internet mail basics DNS structure and management Mail system design SPAM countermeasures
E- mail System n
MUA (Mail User Agent) MTA (Mail Transfer Agent) n DNS (Domain Name System) n
1. Internet Mail Basics
DNS SMTP MUA
MTA SMTP
MTA
MUA
POP/IMAP/... MB mailbox 4
MUA (Mail User Agent)
MTA (Mail Transfer Agent) n
User application
Mail receipt Determination of delivery point n Delivery of mail
– reading mail – writing mail – saving/searching mail n
n
– to remote, to local, to sender (error)
UNIX – ucbmail ucbmail,, RMAIL, mush, MH (mh (mh-- e), mew,....
n
l
Windows
Store and Forward – After receiving, attempt forwarding to next host
– OutLook OutLook,, Netscape Mail, Eudora,.... 5
InternetWeek'97
6
1
DNS & mail
97/12/17
Sending and Receiving Mail on the Internet
MTA Programs n n n n n n n n
sendmail http://www.sendmail.org http:// www.sendmail.org// qmail http://www.qmail.org http:// www.qmail.org// SMAIL (GNU) MMDF (Multi (Multi--channel Memo Distribution, CSNET) exim http://www.exim.org http:// www.exim.org// VMail http://wzv.win.tue.nl/vmail http:// wzv.win.tue.nl/vmail// LSMTP http://www.lsoft.com/LSMTP.html http:// www.lsoft.com/LSMTP.html PP (X.400)
n
SMTP - Simple Mail Transfer Protocol RFC821(S) n TCP port number 25 n
Most MTAs implement SMTP – has coordination function with DNS
7
8
Method of Determining Mail Destination on the Internet
SMTP Action 220 r.domain SMTP Server ready (Message from server) HELO s.domain (Message to server) 250 r.domain Hello s.domain MAIL FROM:<
[email protected]> (sender (sender’’s address) 250 sender ok RCPT TO:
(recipient (recipient’’s address) 250 recipient ok DATA 354 Enter mail, end with "." on a line by itself e - mail data comes here . (indicates end of data) 250 Message accepted for delivery QUIT 221 r.domain closing connection
n
Extracting host name from destination mail address user@host
n
Retrieval of IP address from host name host → 12.34.56.78 – /etc/hosts – NIS (YP) – DNS (Domain Name System)
9
DNS (Domain Name System)
Terminology n
n
10
Wide--area distributed directory service Wide
delivery – local delivery → mailbox – remote delivery → pass to another MTA
– Distributed allocation – Decentralized management
n
transfer
n
acceptance (probably not a universal term)
– remote delivery
Host name → IP address n Mail address → MXHost name → IP address n
– local delivery n
– Sharing same domain space
– delivered from remote 11
InternetWeek'97
receive 12
2
DNS & mail
97/12/17
Mail Address
%-Hack
n
n
Used as sender information/receiver information n User @ domain
user % host @ relay
– motonori @ wide.ad.jp n
RFC1123(S)
sender → relay → host çwhen relay is reached, rewritten as user @ host
Other formats – %- Hack – Route Address – UUCP addressing
user % host % relay2 @ relay1 sender → relay1 → relay2 → host 13
14
Route Address n
UUCP Addressing n
RFC822(S)
n
host ! user relay ! host ! user
n
host ! user @ domain interpretation
@relay: user @ host sender → relay → host çwhen relay is reached, rewritten as user @ host
– “ host ! user” user” @ domain
(in terms of Internet)
» sender → domain → host
– host ! “ user @ domain” domain ”
@relay1, @relay2: user @ host
(in terms of UUCP)
» sender → host → domain
sender → relay1 → relay2 → host 15
16
Comment Format n
Full Name <user@domain>
n
user@domain (Full Name)
n
user(User Name)@domain(Company Name) – The ( ) comment may be inserted anywhere
Domain Part n
Fully Qualified Domain Name – A complete host/domain name in the Internet domain format
n
Fully Qualified Mail Address – [email protected] – means it ’ s not user@mailhost
n
Not Qualified Mail Address
n
Generic Address
– user 17
InternetWeek'97
– [email protected]
18
3
DNS & mail
97/12/17
Message Format n
Sender and Recipient
Header and body n
RFC822(S): Standard for the format of arpa internet text messages n
Sender – one person – the senders in the header may be plural
The first blank line is the divider
» representing the senders
From: [email protected] To: [email protected] Subject: InternetWeek ’98
n
Recipient – one or more persons
← blank line (no space either)
InternetWeek ’ 98 announcement 19
20
Header and Envelope (cont.)
Header and Envelope (cont ’d)
n
Looks like an envelope n Envelope
n
– Sender/destination – Sender/destination as indicated on front
– person who wrote body/person intended for – sender/recipient of enclosed text – generally cannot be rewritten
» person who actually does procedure
– Rewritten upon delivery n
n
RFC821(S): Simple Mail Transfer Protocol
» to individuals
UUCP – Envelope is specified in rmail command line
– may be different » mailing lists etc.
21
When the Envelope is Created n
n
Extracted from the header
Delivery error notice reply (automatic) – Sender of envelope – “ Errors Errors--To: To:”” header » For systems that don’ don’ t have the envelope concept (do these still exist?) exist?)
The envelope is rewritten during the delivery process
n
Response to content (person intervention) – Sender in header
– transfer – mailing list
» From:, ReplyReply-To: » (To:, Cc:) 23
InternetWeek'97
22
Address Used for Reply
– The sending MUA does it – The MTA which processes it first does it n
header and envelope sender/recipient – may be the same
– Envelope is specified with command n
header
24
4
DNS & mail
97/12/17
From the Mailbox to MUA
The 3 Points of Mail Delivery 1) Receipt (delivery from remote)
n
Local mailbox
– Sent from remote mail server
– UNIX etc.
2) Acceptance (delivery to local) 3) Sending/Forwarding (delivery to remote)
n
POP n IMAP
– Sent to recipient’ recipient ’ s mail server DNS
DNS MTA
receive
MTA
accept Range of configuration
25
Send/transfer
MB
DNS Records referred to for Mail Delivery
1) Settings for Mail Receipt How to convey destination to sender n Internet
n
A (Address) RR (Resource Record)
– Direct delivery by SMTP → Define delivery destination to DNS
n
MX (Mail eXchanger eXchanger)) RR
n
– IP address extracted from host name – Destination host name extracted from mail address
Bucket relay system – UUCP etc. (From JUNET era) → Configure delivery destination in (all) hosts along path – Usage of mailconf » sendmail.cf creation tool
26
n
CNAME (Canonical NAME) RR – Alternative host name extracted
27
Confirm A with nslookup (1)
28
Hosts with Multiple IP addresses mail.x.co.jp
IN A 12.34.56.78 IN A 12.34.54.32 n If delivery to the first address doesn’ doesn ’t work, it tries all addresses one by one (implementation dependent) n With the DNS roundround -robin function, the address obtained through search is different each time
% nslookup sh.wide.ad.jp sh.wide.ad.jp.. Server: localhost Address: 127.0.0.1 Name: sh.wide.ad.jp Address: 203.178.137.73
29
InternetWeek'97
– Load sharing – Even it only tries first address, it may work eventually after several time trial(?)
30
5
DNS & mail
97/12/17
Confirm A with nslookup (2)
Generic Mail Address n
% nslookup jp jp--gate.wide.ad.jp Server: localhost Address: 127.0.0.1
No host name part – Not dependent on host reorganization
n
Name: jp jp--gate.wide.ad.jp gate.wide.ad.jp.. Addresses: 203.178.137.17, 203.178.136.81, 203.178.137.75, 203.178.136.89
Uses MX (Mail eXchanger eXchanger)) RR n Mail to [email protected] is sent to specified host – Look up MX, and with obtained host name around the right, look up A and obtain IP address
31
Confirm MX with nslookup
Preparing for Failures (for MX)
% nslookup - q= q=mx mx wide.ad.jp wide.ad.jp.. Server: localhost Address: 127.0.0.1 wide.ad.jp preference = 10, mail exchanger = sh.wide.ad.jp : (additional information) sh.wide.ad.jp internet address = 203.178.137.73 n Please note: for destination when MX can’ can’t be found, it follows A, and if both are found, MX has priority. – Therefore it’ it’ s possible for mail to go to another host using MX setting.
32
n
Mail receipt backback-up x.co.jp preference= preference=10 10,, mx mx=mail1.x.co.jp =mail1.x.co.jp preference=50 preference= 50,, mx mx=mail2.x.co.jp =mail2.x.co.jp
n
Smaller the number, Higher the priority (cost value) – Until the sender succeeds in sending, higher cost attempts are gradually made
n
Mail2 transfers to mail1 upon its recovery – Be aware of mail saving period for mail2 mail2
33
sender
Lower MX Conditions
34
Load Sharing
(Conditions to avoid mail loop) x.co.jp n
mail1
Awareness of own name on right of MX RR
preference=10, mx mx=mail1.x.co.jp. =mail1.x.co.jp. Preference=10, mx mx=mail2.x.co.jp. =mail2.x.co.jp.
– Prevent connection to oneself » confirm with $=w at sendmail -bt » automatic registration of interface address names » qmail is confirmed by IP address n
n
n
When cost is the same, sender chooses destination randomly n In the end, sent to one mailbox
Connection is not made to IP address of oneself
RR costs higher than the MX RR preference – Prevent pingping- pong between Lower MX
InternetWeek'97
– recipient needs some settings » static delivery definition, etc.
for oneself are thrown out 35
36
6
DNS & mail
97/12/17
Configuration of Accepting Address
2) Acceptance of Mail n
Recognize that received mail is to oneself – local delivery (acceptance) – not “ received = to oneself” oneself”
n
Sendmail (CF)
n
qmail
– set as ACCEPT_ADDRS – set as /var/qmail/control/locals /var/qmail/control/locals
n
If decided that it’ it ’s not to oneself – search transfer destination
37
38
Summary of Receive Mail Settings n
3) Mail Delivery Settings
Convey destination to sender
Variations of delivery methods
– Define MX record n n
Recognize that received mail is to oneself
Delivery by reference to DNS MX RR – Prepare MTA to refer to MX
– Delivery to local (acceptance)
n
Delivery based on host name only n Delivery based on set rules
Separate configurations are necessary
– Consider need of referring to DNS 39
40
Basic Configuration for Referring to DNS n n
/etc/ etc/resolv.conf resolv.conf n
/etc/ etc/resolv.conf resolv.conf
Designation of name server nameserver 0.0.0.0 (interpreted as localhost - 127.0.0.1) nameserver 12.34.56.78 nameserver 12.34.56.79
service switch file
– up to 3 (MAXNS in resolv.h resolv.h)) » time out is same regardless of how many (75s) domain sub.x.co.jp search sub1.x.co.jp sub2.x.co.jp x.co.jp
– Used for address supplement 41
InternetWeek'97
42
7
DNS & mail
97/12/17
Service Switch file n
When referring to DNS MX n
Solaris – /etc/ /etc/nsswitch.conf nsswitch.conf
– sendmail.mx
» hosts: files dns n
» link to libresolv.a
– sendmail.cf for reference to MX
DEC
» MX_SENDMAIL=yes (CF) » (Actually Wildcard MX strategy only)
– /etc/ /etc/svc.conf svc.conf n
MTA referring to MX
Others
→ Address supplement
– ServiceSwitchFile option (sendmail.cf (sendmail.cf)) – Default: /etc/service.switch hosts dns files nis
43
44
Delivery Based on Set Rules n
Confirmation for Delivery
Write set rules in sendmail.cf – mailconf – CF
n
Is the address interpreted correctly?
n
Is MX able to search normally?
– sendmail - bv or sendmail - bt /parse
» STATIC_ROUTE_FILE
– use sendmail - bt for /mx /mx command n
Is it able to actually send? – sendmail - v
45
46
Summary of Delivery Settings n
Host should be able to refer to DNS – resolv.conf – Service Switch file
n
Consider destination according to mail address – Refer to DNS (MX) and deliver as is » which name server should be looked at (more later)
– Destination is statically set
InternetWeek'97
47
8