Plex and nat based vps

Hello,

I got a nat based vps.So my vps gets only a specific range of ports from an ip address.
I selected to manual public port but Plex cannot announce the server and strangely enough it only recognized the public ip but no the private one. Any ideas ?

I think it can be solved with iptables …but how!
tried this and failed miserably:
iptables -t nat -A PREROUTING -i lo -p tcp -d 127.0.0.1 --dport 32400 -j DNAT --to-destination 127.0.0.2:8905

This isn’t your problem. Even though you have port 8905 selected this IS NOT the port Plex is listening on. Plex is ALWAYS listening on port 32400 and it’s hard coded in the source code this way.

Typically with either router forwarding or UPnP the router will listen to the public port such as 8905 but will forward this to your Plex server on port 32400. Plex will use the manual port number to modify URLs so your router can listen and forward correctly.

It’s goofy but generally works ok for almost everyone. YOU ARE NOT ok with this. In your case UNLESS you were given a range that includes 32400 you are screwed at present. You need to contact support and tell them you MUST have port 32400 in your range if your server is running on a public IP address.

I’m not sure exactly if you have a public or private IP from those pictures. Kind of confusing. But if you are truly behind a NAT then you can ask the provider what the public IP address is AND ask them to forward:
port 8905 external to your internal IP on port 32400.

Any way you cut it Plex software is ONLY going to listen to port 32400 so you either need direct access to this port or you must forward some other port to 32400.

If you give us more info we can help you better. At least now you will understand where/why you are having a problem and what you can do to fix it.

Carlo

I am not sure if I just can’t comprehend the logic or you misunderstood my setup. I’ll try to be more detailed to avoid the confusion.
The vps has one (common) public ip for many users. The public ports available to me are 8900-8920. There are two of interfaces (three with lo) :

**lo ** Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host

venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:127.0.0.2 P-t-P:127.0.0.2 Bcast:0.0.0.0 Mask:255.255.255.255
inet6 addr: 2a06:xxxxx:0:948::1/64 Scope:Global
UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1

venet0:0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:192.168.43.89 P-t-P:192.168.43.89 Bcast:192.168.43.89 Mask:255.255.255.255

192.168.43.89 is the local ip of the vps in the network (not the public ip)
I understand that 127.0.0.1 is the localhost of the vps (so with ssh port forwarding I can go to plex webui with 127.0.0.1:32400) so locally I have all ports available.

From the web I can only receive requests from 8900-8920 ports to a fixed (shared) ip. I am not really aware how nat works in such config so I am not sure how 127.0.0.2 works to translate things. But I think that there is a way with iptables to make the incoming request from the manual port and forward it locally to 32400 for plex. No?

You will not use the loopback address of 127.x.x.x at all.

Anything starting with 192 is a non-routable “inside” address. You will need to have an public “external” address.
You will need to forward the port 8905 (if this is the one you want to use) on the PUBLIC IP to port 32400 on 192.168.43.89 (your internal IP).

This 8905 can’t go to 8905 on your IP but MUST go to 32400. If they can’t/won’t do this for you OR they can’t give you an external IP that forwards to your internal IP then you can’t use this provider to host Plex.

Plex must be accessible from the outside and must be able to listen on port 32400. Personally it sounds to me based on what’s been said that you can’t use them.

Carlo

Thank you for the reply!
Ok I think I start to get a grasp of the concept!
So my public “external” address is 185.164.13x.xx and I chose the port 8905 that is accessible publicly (and set on Plex manual port).
My internal IP is 192.168.43.89 (venet0:0).
I cannot use an iptable rule to forward 8905 external port to 32400 internal port of internal ip?
This can only been done from the provider?

google consulting says it’s feasable to use iptables for portforwarding :wink:

Depending on what features your provider expose on the web console you might have everything required at hand to configure a virtual network, virtual firewall and/or a virtual router.

Is your plex instance running in a docker environment?

You don’t want to NAT to localhost, because localhost is treated differently to other server-local IPs. Use another static IP that’s fixed on an interface of your server, and assuming you’ve specified port 8905 as the manually specified public port, the following should do the job:

iptables -t nat -I PREROUTING -p tcp --dport 8905 -j DNAT --to <server-local-ip-address-thats-not-localhost>:32400

Thanks guys! It finally works B)