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

NAT support #4630

Open
tzaeschke opened this issue Sep 23, 2024 · 15 comments
Open

NAT support #4630

tzaeschke opened this issue Sep 23, 2024 · 15 comments
Labels
workitem Something needs doing

Comments

@tzaeschke
Copy link
Contributor

As discussed in #4560 and in this proposal, we should implement NAT support.

Implementation is currently supervised by @marcfrei and @tzaeschke.

@tzaeschke tzaeschke added the workitem Something needs doing label Sep 23, 2024
@jiceatscion
Copy link
Contributor

Comment regarding the design: I'm in favor of using STUN. Any idea how we would carry STUN messages to the router and tell them appart from regular traffic? STUN, per the RFC, is described as UDP or TCP payload, with its own port. In our case we want it to go directly to the router's port. So we can't really carry it via underlay UDP; shall we carry it over UDP/SCION instead (may be with a router alert flag)?

@tzaeschke
Copy link
Contributor Author

Comment regarding the design: I'm in favor of using STUN. Any idea how we would carry STUN messages to the router and tell them appart from regular traffic? STUN, per the RFC, is described as UDP or TCP payload, with its own port. In our case we want it to go directly to the router's port. So we can't really carry it via underlay UDP; shall we carry it over UDP/SCION instead (may be with a router alert flag)?

We currently have student looking into this in form of a Bachelor thesis, so it may make sense to wait for his results.

I wouldn't know how to distinguish traffic if it were STUN traffic. That is one reason why I would prefer a custom solution, e.g. an extension to SCMP or something else. A custom protocol should also be very easy to implement. If performance is a concern, we are already inspecting packets in the border router (BR), so I think it should have little impact...?

@jiceatscion Why do you prefer STUN? Because it is a known/existing protocol? Or because of performance concerns?

@marcfrei Any comments?

@marcfrei
Copy link
Contributor

Any comments?

I'd basically +1 @tzaeschke's points regarding STUN vs. "a custom solution, e.g. an extension to SCMP or something else".

@jiceatscion
Copy link
Contributor

My only reason was indeed because it is an already specified protocol, with ready-to-use libraries: not much new code to write, maintain and test, and no new specification to add to the ietf drafts. The fact that we can't rely on a dedicated UDP port might make that a no-go, I agree.

@shitz
Copy link
Contributor

shitz commented Nov 15, 2024

We have discussed this at Anapaya and our preferred approach would be to have IP/UDP/STUN instead of IP/UDP/SCION/UDP/STUN for this. The reason is that the problem we are solving here is not NAT detection for SCION, but for the SCION underlay. I would reserve IP/UDP/SCION/UDP/STUN for when we eventually need STUN to detect SCION NATs (I hope that day never comes...).

The router would need to distinguish between STUN and SCION packets, since they would be received on the same UDP port, however, STUN's magic cookie is there for exactly that purpose.

@tzaeschke
Copy link
Contributor Author

@shitz Just to clarify:

  • The plan was to do IP/UDP/SCION/STUN (no UDP between SCION and STUN), not IP/UDP/SCION/UDP/STUN.
    This would allows us to use the SCION NextHdr field to quickly identify STUN packets without having to parse the UDP payload.
  • I am not sure about SCION NATs, I would assume they know their external address and don't need to ask for it. Even if they do, the IP/UDP/SCION/STUN proposal should work for them (why not?).
  • Also, for SCION NATs, if we think we need an additional STUN solution, wouldn't it be good to design now a single solution that works for all cases, instead of ending up with two separate STUN solution?

Just a thought: if we go the IP?UDP?STUN route, would it be a good idea to still reserve the NextHdr id for STUN (as determined by the magic number) just to allow even faster detection (and without going the validation error route) of STUN packets?

@jiceatscion
Copy link
Contributor

+1 for IP/UDP/SCION/STUN (I had completely overlooked that option). The router already has all the plumbing ready for it since that's how we carry BFD.

@shitz
Copy link
Contributor

shitz commented Nov 18, 2024

The plan was to do IP/UDP/SCION/STUN (no UDP between SCION and STUN), not IP/UDP/SCION/UDP/STUN.
This would allows us to use the SCION NextHdr field to quickly identify STUN packets without having to parse the UDP payload.

Ok I see, but I don't really agree with that. It's also not IP/STUN instead there are well-known UDP or TCP ports for STUN. Why would we do something different for SCION/STUN? I expect this would raise flag during an eventual standardization.

I am not sure about SCION NATs, I would assume they know their external address and don't need to ask for it. Even if they do, the IP/UDP/SCION/STUN proposal should work for them (why not?).

It's not that the SCION NATs would need to discover their external address, but a SCION endhost BEHIND a SCION NAT - and exactly for this I suggest we use SCION/UDP/STUN, because that's then conceptually at the right layer.

Also, for SCION NATs, if we think we need an additional STUN solution, wouldn't it be good to design now a single solution that works for all cases, instead of ending up with two separate STUN solution?

How do you then distinguish between the two usecases? There might be a need for STUN for NATing that happens on the IP/UDP underlay and there might be a need for STUN for NATing that happens on the SCION/L4 level (SCION NAT). I argue we should address the former with IP/UDP/STUN since the NATing is on the IP/UDP underlay layer and the latter with SCION/UDP/STUN since the NATing is on the SCION layer.

Just a thought: if we go the IP?UDP?STUN route, would it be a good idea to still reserve the NextHdr id for STUN (as determined by the magic number) just to allow even faster detection (and without going the validation error route) of STUN packets?

As argued above, I wouldn't put STUN directly after the SCION header to be inline with how STUN for IP/UDP works.

@tzaeschke
Copy link
Contributor Author

tzaeschke commented Nov 19, 2024

In the SCION open source telecon (2024-11-19) we agreed to pursue the IP/UDP/STUN approach.

We will provide a PR for the design doc, a separate PR for the implementation (PAN library) and potentially a 3rd PR for snet.

Correction:


We will provide the following PRs:

  • PR for the design doc
  • PR on scionproto with BR implementation and tests
  • PR for the PAN library
  • potentially another PR for snet

To clarify some of my previous points

It's also not IP/STUN instead there are well-known UDP or TCP ports for STUN. Why would we do something different for SCION/STUN?

The proposal says we would use the normal border router port, not a well-known port. This is done because apparently some NATs create separate mappings for separate port. Also, as @jiceatscion pointed out, we already have BFD over SCION, I think this is similar, but I don't know why it was decided that way.

Just a thought: if we go the IP?UDP?STUN route, would it be a good idea to still reserve the NextHdr id for STUN (as determined by the magic number) just to allow even faster detection (and without going the validation error route) of STUN packets?

As argued above, I wouldn't put STUN directly after the SCION header to be inline with how STUN for IP/UDP works.

I actually meant for the IP/UDP/STUN case that you proposed. The border router could just look at the byte where the NextHdr is and immediately tell if this is a STUN packet (without SCION header) if it has the byte equals 66, which is the byte value there that is imposed by the magic number (2nd byte of the magic number).

@jiceatscion
Copy link
Contributor

For the record, given there is a method of robust demultiplexing, I'm sold on the IP/UDP/STUN.

It's a detail, but, just to make sure I understand... nexthdr is the fifth byte of the scion hdr. The magic cookie starts at the fifth byte of the STUN hdr, so nexthdr coincides with the first byte of the magic cookie, does it not? Also neither the first nor the second byte of the magic cookie is 66: the cookie is described as being 0x2112A442 in network byte order. Am I confused?

@jiceatscion
Copy link
Contributor

I know it's easy to get mixed-up, but network byte order is Big-endian; it puts the most significant byte first. That'd be 0x21, would it not?

@marcfrei
Copy link
Contributor

I think that's right. We need to look at 0x21 = 33 in decimal. At IANA, this is assigned to "Datagram Congestion Control Protocol".

@tzaeschke
Copy link
Contributor Author

tzaeschke commented Nov 20, 2024

@jiceatscion @FR4NK-W @marcfrei @lukedirtwalker @shitz

Unfortunately we forgot to mention one possibly important aspect of NAT detection over SCION vs IP/UDP/STUN: authentication.

TL;DR: Implementing authentication in STUN may be quite difficult, using SCION and DRKey may be much easier.
However, it is not clear useful authentication really is in this case.

Options:

  • Authentication in STUN requires a username/password combination. I don't know how these are usually acquired, but it may be annoying/difficult to get them inside the PAN layer to perform STUN authentication such that it is transparent to the user and the application layer.
  • If we were using SCION underneath, we could probably easily use DRKey authentication for STUN. It would have to be modified and I would avoid calling it STUN to avoid confusion.

There are some things to consider:

  • I have the impression that STUN authentication is currently not widely implemented, does anyone have a similar or contrary impression or data points?
  • I am not sure how much authentication adds to security. STUN packets already have a nonce (TxID) for requests responses, so I think only a MitM attacker could exploit this.
  • DRKey has not been designed for NAT, but it should probably work for this case. It would result in all hosts behind the NAT to be assigned the same DRKey. This is of course not ideal but should work fine for authenticating packets from the border router.

Before we go ahead and submit and PRs, can I ask everybody to indicate whether this would pose a reason to change their mind to use SCION underneath our NAT traversal protocol?

@jiceatscion
Copy link
Contributor

jiceatscion commented Nov 25, 2024 via email

@lukedirtwalker
Copy link
Collaborator

I don't see where/why we would need auth TBH. AFAIU from reading a bit on the internet it seems that if you also do TURN in combination with STUN, then authentication would be important, but given we don't do that, we don't need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workitem Something needs doing
Projects
None yet
Development

No branches or pull requests

5 participants