All relays must accept all inbound connections to their chosen ORPort and must allow outbound connections to any valid internet-routable address and port combination, as any other internet server on any valid TCP port could be a relay.
It's worth noting that all relays are potentially valid for all positions, what positions clients use them in is determined by flags that they are given by votes from the Directory Authorities. There are no "guard", "middle" or "exit" relays.
The only position you can effectively opt-out of is the exit, but it's not that you're a "non-exit", you just have a policy that doesn't allow any exiting.