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

Add support for forwarding to DNS on ports other than 53 #589

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alainbryden
Copy link

@alainbryden alainbryden commented Dec 2, 2020

Added support for forwarding to DNS on ports other than 53.

In my case, I have a local DNS server running (pi-hole) that I want to use (rather than some public or ISP DNS server - which are guaranteed to use port 53.) I set up my pihole to answer DNS requests on another port (10053) because I wanted PlexConnect to be my PC's "first responder" to DNS requests - since it has its special logic for intercepting Apple TV requests that I don't want to have to re-code and maintain in PiHole.

Makes sense to me ¯_(ツ)_/¯ , low footprint addition, so hopefully one others can benefit from as well.

…lly running pihole hosted on a different port to avoid clashing with PlexConnect)
@alainbryden alainbryden force-pushed the support-dnsmaster-port-other-than-53 branch from b8d19b1 to c7c8bf5 Compare December 2, 2020 02:40
@moodyblue
Copy link
Collaborator

moodyblue commented Dec 2, 2020

Thanks for your contribution, but I'm wondering if it this is really necessary. PlexConnect has two services, DNS and HTTP, and the DNS service can be disabled (in Settings.cfg) when you opt to have your own DNS. It's very easy, for those that have their own DNS server, to recode the interceptions required by PlexConnect.

Also see this.

@alainbryden
Copy link
Author

alainbryden commented Dec 2, 2020

Fair enough.

At first, I did attempt to set enable_dnsserver = False and code up the route trailers.apple.com to my computer's ip (192.168.0.100) - which at this point is running Plex (on port 32400), PlexConnect, and PiHole (dockerized) - but that didn't work for resons unclear. I wasn't clear on the exact mechanism PlexConnect uses to "service" trailers.apple.com requests and serve up Plex content, and whether it was doing something special to respond to DNS requests with both an IP and new port. (I see now that was a silly though - DNS has no notion of ports). Upon reflection, it likely wasn't working because PiHole was stealing local ports 80/443 for its own admin panel dashboard - which would have interfered with PlexConnect's HTTP service.

Nevertheless, I got to thinking about the other things PlexConnect did (e.g. intercepting the request for a certificate, or menu items on a reboot) and wasn't confident that I could gather and reproduce all those nuances.

Is there a wiki page that has a small table of all the routes PlexConnect's DNS service forwards - or is that best gleaned just by poking through the latest DNSServer.py?

@moodyblue
Copy link
Collaborator

moodyblue commented Dec 2, 2020

Every DNS has its own way to be parametrized. Here is from an old post (PlexConnect for Synology) in the Plex forum:

When you are already using the Synology DNS Server package, the PlexConnect DNS proxy will not work, since they both want to use the same port on your Synology.

If your not using the DNS Server, stopping and uninstalling it, is the easiest solution.
When you are using the DNS Server, adding trailers.apple.com and redirecting it to PlexConnect also solves the problem. Follow these steps to use this setup:

    Connect to Synology DSM web interface
    Open the DNS Server Settings from the DSM 'Start' button
    ![post-14912-0-32591800-1382274766.png|480x86](upload://wqFmRqE0SZXcOUAh2FgqHzk5tBB.png)
    Goto Zones and select Create > Master Zone
    Enter this info and click OK:
    Domain Type: Forward Zone
    Domain name: trailers.apple.com
    Master DNS Server: *IP of your Synology*
    ![post-14912-0-79881700-1382274772.png|480x264](upload://7Kk1ObkjS9ppKEfVv1TwGKvJFak.png)
    Select the new trailers.apple.com row and click Edit > Resource record (or double click the row for the same effect)
    Create > A Type
    Enter this info and click OK:
    Name: *leave empty*
    TTL: *use default, probably 86400*
    IP address:*IP of your Synology*
    ![post-14912-0-04564000-1382274779.png|480x264](upload://sPqrshZ7ALq30DOMM217ZdNQbms.png)
    Click Finish
    ![post-14912-0-15056400-1382274784.png|480x84](upload://iYxDDW7TWfAnAJ2i5cMUN2mWUId.png)
    Do the same steps [3-8] again but this time with "atv.plexconnect"
    Goto Log and check if there are no errors
    ![post-14912-0-51321200-1382274789.png|480x124](upload://e5K17HPOcnNfVYERNSPRfcMgkrJ.png)

    The DNS should be working now, time to disable the PlexConnect DNS and get everything connected.
    Stop PlexConnect from package center if it is running
    Login as root on your Synology using SSH (password for root is the same for admin on webinterface)
    If you did not disable the Internal DNS server then Edit /usr/local/plexconnect/share/PlexConnect/Settings.cfg and set enable_dnsserver = False
    Start PlexConnect again

Also this thread may be interesting.

To use ports other than 80/443 see this

It would be great if you could "translate" this to pi-hole. I would add it to the wiki.

@alainbryden
Copy link
Author

alainbryden commented Dec 2, 2020

From what I've gleaned, even those instructions might be incomplete, because it doesn't capture some PlexConnect DNS behaviour, like redirecting "a1.phobos.apple.com" (if intercept_atv_icon=true. which is the case by default).

As far as I can tell, the full set of routes that PlexConnect DNS does map is:

trailers.apple.com => <plex_connect_host_IP>,
a1.phobos.apple.com => <plex_connect_host_IP>,
mesu.apple.com => 127.0.0.1,
appldnld.apple.com => 127.0.0.1,
appldnld.apple.com.edgesuite.net => 127.0.0.1

I might have missed some. I was kind of hoping there was somewhere in the docs or something that had that mapping table. Perhaps one to create if not.

@alainbryden
Copy link
Author

alainbryden commented Dec 2, 2020

Alright - successfully got PiHole and PlexConnect working nicely with one-another on the same host without resorting to the new feature proposed in this pull request :)

Steps to use PlexConnect and PiHole at the same time:

  1. To avoid troubleshooting unrelated issues:
    -> Ensure you have successfully gotten PlexConnect working on its own. Now turn it off.
    -> Ensure you have succesffully gotten PiHole working on its own. Now turn it off.

  2. Disable PlexConnect's DNS Service (enable_dnsserver = False in Settings.cfg) this frees up port 53 for PiHole.

  3. Reconfigure PiHole's admin panel to be hosted on ports other than 80/443.
    PlexConnect must own these ports, unless you have a reverse proxy and can selectively redirect ATV traffic to port 80 on your host from the apple tv to a new port)
    -> If your PiHole is dockerized, you can configure docker to forward e.g. port 10080 to port 80 on your docker container by adding arguments -p 10080:80 -p 10443:443 to your docker run command.
    -> If your PiHole is running natively on the same host, you can edit the PiHole lighttpd.conf file and change the web server port, then restart the lighttpd service.

  4. Test: You should be able to see the "PlexConnect UP" page at http://<host_local_ip_address>/ and the PiHole portal at e.g. http://<host_local_ip_address>:10080/admin
    image
    Note: <host_local_ip_address> is the ip address of the machine running PlexConnect and the PiHole, which should of course be connected to the same router as your Apple TV and on the same subnet.

  5. Configure your pi-hole to do the work the PlexConnect DNS used to be doing. On the "Local DNS > DNS Records" page, you can set up the same basic redirects that PlexConnect relies on:
    image

    • trailers.apple.com => <host_local_ip_address>
    • atv.plexconnect => <host_local_ip_address>
    • a1.phobos.apple.com => <host_local_ip_address> (optional, if you wish to override the Trailers icon when ATV is reset)
    • mesu.apple.com => 127.0.0.1 (optional, if you wish to disable ATV auto-updates)
    • appldnld.apple.com => 127.0.0.1 (optional, if you wish to disable ATV auto-updates)
    • appldnld.apple.com.edgesuite.net => 127.0.0.1 (optional, if you wish to disable ATV auto-updates)

@alainbryden
Copy link
Author

Side note, the wiki you linked mentions atv.plexconnect, but not the others. Has that requirement changed, or should I be adding atv.plexconnect to the guide?

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

Successfully merging this pull request may close these issues.

2 participants