Skip to content

Two Machines Connecting via Firewalls #486

Closed

Description

@digilord

I have two machines that are running rethinkdb. Both are behind firewalls. Each machine has the intracluster ports forwarded to the internal IP address from the firewall. The error I am getting is:

error: received inconsistent routing information (wrong address) from xxx.xxx.xxx.xxx (expected_address = peer_address{ips=[xxx.xxx.xxx.xxx], port=29015}, other_address = peer_address{ips=[127.0.0.1, 127.0.1.1, 192.168.1.33], port=29015}), closing connection

Where xxx.xxx.xxx.xxx is my external IPv4 address.

Activity

  1. coffeemug commented on Mar 18, 2013

    @coffeemug
    Contributor

    @timmaxw, @Tryneus -- you know the most about the routing code. What can we do to solve this problem? (Would turning off the checks be sufficient?)

  2. neumino commented on Mar 18, 2013

    @neumino
    Member

    I think I had this issue before.

    The ports used to forward traffic have to be the same (in and out ports).
    On Mar 18, 2013 9:46 AM, "coffeemug" [email protected] wrote:

    @timmaxw https://github.com/timmaxw, @Tryneushttps://github.com/Tryneus-- you know the most about the routing code. What can we do to solve this
    problem? (Would turning off the checks be sufficient?)

    —
    Reply to this email directly or view it on GitHubhttps://github.com//issues/486#issuecomment-15066107
    .

  3. timmaxw commented on Mar 18, 2013

    @timmaxw
    Member

    Turning off the checks won't fix it.

    Here's the problem: Machine 1 thinks its address is peer_address{ips=[127.0.0.1, 127.0.1.1, 192.168.1.33], port=29015}. Machine 2 contacts it by connecting to peer_address{ips=[xxx.xxx.xxx.xxx], port=29015}. Suppose that we disable the check. Then Machine 2 will think that Machine 1's address is peer_address{ips=[127.0.0.1, 127.0.1.1, 192.168.1.33], port=29015}, because that's what Machine 1 told Machine 2 its address was. Now suppose Machine 3 contacts Machine 2 and says, "How do I contact Machine 1"? Unless Machine 3 is behind the same firewall as Machine 1, the address peer_address{ips=[127.0.0.1, 127.0.1.1, 192.168.1.33], port=29015} won't work.

    Here's a solution: Add another command-line parameter. For the sake of discussion let's call it --canonical-address. Its argument is a host and port. If a machine anywhere in the cluster tries to make a connection to the canonical address, it must reach this machine's clustering port. So, for a machine behind a firewall, --canonical-address would be the external address and port. Whenever two machines make a connection, they will swap canonical addresses; whenever Machine 2 needs to tell Machine 3 how to contact Machine 1, Machine 2 will give Machine 1's canonical address to Machine 3. The assertion that was tripped that caused this issue would be removed.

    That's the gist of it, but there are some subtleties to work out:

    • What should --canonical-address default to? Perhaps it should default to whatever address(es) were bound to. But then it needs to permit multiple values. That's okay; if --canonical-address is not specified, it defaults to our current behavior.
    • Here's a neat trick: If the user passes a hostname rather than an IP address to --canonical-address, we don't resolve the hostname until it's time to make the connection. That way, they can have the same machine be contacted by different addresses from different locations. For example, if Machine A and Machine B are behind different firewalls but Machine A and Machine C are connected by a crossover cable, then Machine A's canonical address can just be machine-a, and Machine C's hosts file can say that machine-a is whatever its IP is on the ethernet interface attached to the crossover cable, but Machine B's DNS lookup can say that machine-a is whatever external IP address the firewall will forward to Machine A.

    I'm not 100% sure about this; someone who knows more about DNS and IP should take a look. I wonder how existing clustering products do it?

  4. timmaxw commented on Mar 18, 2013

    @timmaxw
    Member

    This also resolves the issue Michel saw, because --canonical-address can have a port that is not the port that the machine is listening on. But if the port is not specified, it should probably default to the port that the machine is listening on.

  5. coffeemug commented on Mar 20, 2013

    @coffeemug
    Contributor

    @digilord -- it looks like this is more complicated than it appears and unfortunately we don't have the resources to fix it now. I'm moving this to backlog. Could you post here if you didn't find a workaround, and we'll help you find one until we can fix this?

  6. digilord commented on Mar 20, 2013

    @digilord
    Author

    I will revisit this in a few weeks. Thanks for looking into it for me.

  7. ConceitedCode commented on Jul 1, 2013

    @ConceitedCode

    I'm running rethink inside an LXC container using Docker and am trying to connect using rethinkdb admin -j x.x.x.x:29015 from outside the container and have ran into this issue. I'm getting the exact same error as @digilord. What are the plans for fixing this issue, if there are any?

  8. coffeemug commented on Jul 1, 2013

    @coffeemug
    Contributor

    This issue is currently unscheduled. I'll try to prioritize it and get this fixed in the 1.8 release. @Tryneus -- do you think this is doable?

  9. Tryneus commented on Jul 1, 2013

    @Tryneus
    Member

    Absolutely, I'll start working on this once I finish up query/connection logging.

  10. coffeemug commented on Jul 1, 2013

    @coffeemug
    Contributor

    Ok, in this case, @digilord @ConceitedCode -- this is scheduled for 1.8. Thanks for bringing it to our attention.

  11. ghost assigned on Jul 1, 2013
  12. Tryneus commented on Jul 15, 2013

    @Tryneus
    Member

    Alright, this is implemented pretty much to @timmaxw's specifications, and up in review 740. Some notes:

    The new command-line option is --canonical-address HOST[:PORT] and can be specified multiple times. This option is available for all rethinkdb invocations that take a --join option, which would be porcelain, serve, proxy, and admin. If port is omitted, it will use whatever port the cluster ends up listening on. You cannot specify '0' for this port, as that would not make sense.

    If no canonical addresses are given, we will use our bound local IP addresses (as we currently do) for intracluster routing. If there are any canonical addresses, we will only use those.

    Peer addresses are now passed around the cluster as host/port pairs, which allows each node in the cluster to perform its own lookup of its peers' addresses.

    This should allow port forwarding and tunneling and some other crazy stuff people do with their networks, but probably won't cover every situation.

  13. Tryneus commented on Jul 17, 2013

    @Tryneus
    Member

    This has been merged into next as of 5f487d0. Will be in the 1.8 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions