Sunshine & Moonlight - zbrewer/homelab GitHub Wiki

Sunshine started off as an open source re-implementation of Nvidia Game Stream but is now a more general open source game stream host.

Similarly, Moonlight started as an open source client for Nvidia Game Stream but is now primarily used with Sunshine.

The Sunshine server/Moonlight client are primarily intended for game streaming from either a different computer locally or over the internet (remotely). They perform this task well and generally result in low latency, good image quality, and a good overall experience. With that said, they also support launching the desktop directly and work as a good remote desktop application.

Compared to RDP/VNC and Guacamole, the latency and image quality is better so it feels much more like sitting directly in front of the computer. This makes it ideal for other tasks such as editing photos with Lightroom remotely. On the other hand, it isn't a clientless experience (like Guacamole) so the client has to be installed and configured. This isn't usually a problem since Moonlight has builds for tons of platforms but it is an extra required step that makes it less ideal for simple management interfaces.

Installation and Setup

Sunshine

Install instructions can be found in the Sunshine documentation, specifically here.

For Windows, this requires downloading the installer for the latest release and then completing the (normal) install process.

After that, the setup instructions should be followed to allow Sunshine through the Windows firewall and to create the service (if it wasn't during install). Note that these commands must be run from an administrator command prompt.

Finally, start Sunshine (can be found in the start menu) and then navigate to https://localhost:47990. Create an admin account and configure from this interface as necessary. Additional applications can be added from the Applications menu. For example, Lightroom Classic can be added by specifying "C:\Program Files\Adobe\Adobe Lightroom Classic\Lightroom" as the Command.

In order to make Sunshine start at boot, open the Task Manager (CTRL + SHIFT + ESC) and navigate to the Services tab. From there, click on the Open Services option and find the Sunshine Service entry in the window that opens. Double click it to open its settings and, on the General tab, change the Startup type to Automatic. Apply the changes. Sunshine should now start automatically at the next boot.

Moonlight

Moonlight can be installed per the instructions/downloads on their website. Specifically, in the Client Downloads section. The Setup Guide is also useful for information about setting up Moonlight.

In general, if on the same network, Moonlight should find the running Sunshine server automatically and ask if you want to add it. It will then provide a pin to enter on the PIN section of the Sunshine configuration dashboard. Once this is done, the two devices should be paired and the Moonlight client should be able to connect/launch a session.

Firewall

In order to allow streaming across networks protected by a firewall, the following ports must be allowed to connect from the clients to the server:

  • TCP: 47984, 47989, 48010
  • UDP: 47998, 47999, 48000, 48002, 48010

Caveats

There are a few "gotchas" that one should be aware of when using this setup:

  • There must be a display connected to the GPU in order to use Sunshine/Moonlight. If hosting on a headless machine, a display emulator/dummy plug (such as this one) can be used to trick the machine into thinking there is a display.
  • The host resolution isn't changed automatically based on the Moonlight streaming configuration. Instead, the host resolution might need to be changed manually after connecting or some other workaround used. A particularly nice sounding one is to use a display dummy plug to set up an extra "monitor" that can be configured as the display to stream (instead of the primary display) from within Sunshine. This is done under Configuration > Audio/Video > Output Name.
  • A "local" login must be performed between RDP and Moonlight sessions (although an RDP session can follow Moonlight without completing this step).

Wake-on-LAN

Moonlight is configured to be able to send WoL packets out of the box. This requires setting up the host computer for Wake-on-LAN but otherwise lets you wake the computer from sleep before connecting (so that it doesn't have to remain on all the time).

This is a super convenient feature and generally works well when on the same network (like when streaming locally). That being said, it apparently sends the WoL packets to the limited broadcast address (255.255.255.255) so most routers will not forward these across VLANs. If the client is on a separate network segment, forwarding may have to be set up (it sends packets on ports 7, 9, and 47998-48000) or a different WoL solution used in conjunction with Moonlight. Source here.

See my Guacamole docs for more information on WoL.