wataru koyama
2018-07-26 05:35:02 UTC
ã¯ãããŸããŠãå°å±±æžã§ãã
Resolv::DNSã®MXã¬ã³ãŒãååŸã«ã€ããŠã«ã€ããŠè³ªåãããŠãã ããã
MXã¬ã³ãŒããååŸã§ããå Žåã«æ£åžžãªã¡ãŒã«ãã¡ã€ã³ãšå€å®ããããšäžèšã®ãããªã³ãŒããèšèŒããŸããã
ã³ãŒãã®æå³ãšããŠã¯
*recordsã空ãªã äžæ£ãªã¡ãŒã«ãã¡ã€ã³
*recordsã«äœãå ¥ã£ãŠããã° æ£åžžãªã¡ãŒã«ãã¡ã€ã³
ãšããæãã§ãã
ãã ã'hoge..gmail.com'ã®ãããªäžæ£ãªããããç¶ãã¿ã€ãã§è¡ããšMXã¬ã³ãŒããååŸã§ããæ£åžžãªãã®ãšå€å®ãããŠããŸããŸããã
records = Resolv::DNS.open do |dns|
dns.timeouts = 1
records = dns.getresources('hoge..gmail.com',
Resolv::DNS::Resource::IN::MX)
end
p records #=> å€ãè¿ã£ãŠãã
ãããŠåæ§ã®ç¢ºèªãnslookupã³ãã³ãã«ãŠè¡ããšMXã¬ã³ãŒããåããªããšå€å®ãããŸãã
nslookup
ãMXã¬ã³ãŒããååšããªããã®ãšå€å®ã§ããæ¹æ³ããããŸãããã
ãææããã ãããšå¹žãã§ãã
ç°å¢ã¯centos 6.9
ruby 2.3.3p222
以äžã§ãã倱瀌ããããŸãã
Resolv::DNSã®MXã¬ã³ãŒãååŸã«ã€ããŠã«ã€ããŠè³ªåãããŠãã ããã
MXã¬ã³ãŒããååŸã§ããå Žåã«æ£åžžãªã¡ãŒã«ãã¡ã€ã³ãšå€å®ããããšäžèšã®ãããªã³ãŒããèšèŒããŸããã
ã³ãŒãã®æå³ãšããŠã¯
*recordsã空ãªã äžæ£ãªã¡ãŒã«ãã¡ã€ã³
*recordsã«äœãå ¥ã£ãŠããã° æ£åžžãªã¡ãŒã«ãã¡ã€ã³
ãšããæãã§ãã
ãã ã'hoge..gmail.com'ã®ãããªäžæ£ãªããããç¶ãã¿ã€ãã§è¡ããšMXã¬ã³ãŒããååŸã§ããæ£åžžãªãã®ãšå€å®ãããŠããŸããŸããã
records = Resolv::DNS.open do |dns|
dns.timeouts = 1
records = dns.getresources('hoge..gmail.com',
Resolv::DNS::Resource::IN::MX)
end
p records #=> å€ãè¿ã£ãŠãã
ãããŠåæ§ã®ç¢ºèªãnslookupã³ãã³ãã«ãŠè¡ããšMXã¬ã³ãŒããåããªããšå€å®ãããŸãã
nslookup
set q=MX
hoge..gmail.com
ç§ã®Resolv::DNSã®äœ¿ãæ¹ãééã£ãŠããã®ããããéãæ¹æ³ã«ãŠãhoge..gmail.comhoge..gmail.com
ãMXã¬ã³ãŒããååšããªããã®ãšå€å®ã§ããæ¹æ³ããããŸãããã
ãææããã ãããšå¹žãã§ãã
ç°å¢ã¯centos 6.9
ruby 2.3.3p222
以äžã§ãã倱瀌ããããŸãã