Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Multihomed MX records use only a single IP #28

Closed
AlexeyDemidov opened this issue Apr 6, 2019 · 4 comments
Closed

[BUG] Multihomed MX records use only a single IP #28

AlexeyDemidov opened this issue Apr 6, 2019 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@AlexeyDemidov
Copy link

When we have multi-homed MX record(s) which resolves into multiple A records eg.

@ IN MX 0 mail.example.com.
mail.example.com. IN A 192.168.100.1
mail.example.com. IN A 192.168.100.2

Only a single IP address will be checked as Resolv.getaddress is used for MX hosts name resolution instead of Resolv.getaddresses.

@bestwebua
Copy link
Member

Hi, Alexey! It make a sense, but what's wrong? In realization below we get array of mx records, and convert each mx record object to ip adress.

def mx_records(domain)
  Resolv::DNS.new.getresources(domain, Resolv::DNS::Resource::IN::MX).map do |mx_record|
    Resolv.getaddress(mx_record.exchange.to_s)
  end
end

@bestwebua bestwebua self-assigned this Apr 7, 2019
@AlexeyDemidov
Copy link
Author

Each MX record contains a single hostname but this hostname can have multiple A records so it resolves into multiple IP addresses. When a single hostname resolves into multiple IPs it is called multihomed host. In my example above you can see only one MX record but it resolves into multiple address. With this example current implementation using getaddress returns only one IP out of two (192.168.100.1 and 192.168.100.2) actually present in DNS for hostname mail.example.com. You need to use getaddresses to get an array of IP addresses returned for a single MX record.

@bestwebua
Copy link
Member

Thanks for explanation, @AlexeyDemidov! I will fix it in next release 👍

@bestwebua bestwebua added bug Something isn't working and removed needs discuss labels Apr 7, 2019
@bestwebua
Copy link
Member

Fixed!

@bestwebua bestwebua changed the title Multihomed MX records use only a single IP [BUG] Multihomed MX records use only a single IP Nov 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants