Dynamically set server address in stream settings

Nimble

Member
I'm running an Nginx RTMP server via WSL2 on the same PC I'm running OBS on, I'm using Nginx to push multiple streams to multiple locations.

Most of these streams are coming from FFmpeg outside of OBS, but I'd also like to push my OBS output to two different servers using my Nginx RTMP server. The IP address of my WLS2 instance changes every time I restart my PC, I can circumvent any issues with my FFmpeg instances outside of OBS by using a Powershell variable that returns the WSL2 instance's current IP ($((wsl hostname -I).Trim()). However, I can't seem to find a way to set the stream address dynamically in OBS...

Probably impossible without running another server of some kind, but I thought I'd ask anyways. Would be nice if I could read a file as the server address, I could populate that file at boot with a Powershell script. Any Ideas?
 

Nimble

Member
use the IPv6 adress, that should be static.
This doesn't appear to be the case, I restarted the WSL2 instance and the IPv6 address changed. Something to do with virtualization is forcing the network information to change every time WSL2 starts, I read something about forcing it to change to a "static" address after boot, but it had drawbacks.

Or use dynamic domain names
Could you elaborate on this?
 

Harold

Active Member
You can use a hostname defined in either a self-hosted dns server or the windows hosts file to specify the address, and have the WSL2 instance update the address

The self-hosted DNS server is probably the better route for that, although significantly more complicated.
you could also set up a samba server on the wsl2 instance to allow it to announce its network name to the windows host machine.
 

TryHD

Member
This doesn't appear to be the case, I restarted the WSL2 instance and the IPv6 address changed. Something to do with virtualization is forcing the network information to change every time WSL2 starts, I read something about forcing it to change to a "static" address after boot, but it had drawbacks.
You are right after wsl --shutdown the ip stays the same, after a real reboot it does change, same crap as their IPv6 implementation which does not work for wsl2. Microsoft is still a mess.
 

Nimble

Member
You are right after wsl --shutdown the ip stays the same, after a real reboot it does change, same crap as their IPv6 implementation which does not work for wsl2. Microsoft is still a mess.
As far as I understand this is a limitation of virtualization, so IDK if Microsoft can do anything about it without being hacky.

It seems like all this would be unnecessary if you just ran NGINX on Windows. Works fine for me. I used this guide:
https://www.youtube.com/watch?v=wJaz59ZHgCo
Huh, I didn't realize you could compile Nginx for Windows with RTMP, now that I've already got it running in Linux I'd rather not recompile it, but this is probably the most logical route.

You can use a hostname defined in either a self-hosted dns server or the windows hosts file to specify the address, and have the WSL2 instance update the address

The self-hosted DNS server is probably the better route for that, although significantly more complicated.
you could also set up a samba server on the wsl2 instance to allow it to announce its network name to the windows host machine.
I tried using the host file but couldn't seem to get it to redirect traffic from a fake IP address, maybe I was doing something wrong. I've setup Bind9 a few times and it was quite the headache, I saved of videos of me setting it up the last time so that I could reference it though.

Would be nice if I could just get it working through the host file, this is how I had it setup:
Code:
192.168.1.254 172.21.255.72

Where the first address is fake and the second address is the WSL2 IP address, then I put rtmp://192.168.1.254/Restream in the Server field in OBS. Am I doing something wrong there? In this case, if I put rtmp://172.21.255.72/Restream in the Server field it works as intended.
 

Nimble

Member
It seems like all this would be unnecessary if you just ran NGINX on Windows. Works fine for me. I used this guide:
https://www.youtube.com/watch?v=wJaz59ZHgCo
Was just looking into compiling this myself for Windows and it seems like a huge headache, I'd also rather not bloat my main system with all the compiling tools. Compiling on Ubuntu was so much simpler and everything is contained within the WSL2 instance, which theoretically prevents me from installing packages that would conflict with other software running on my capture PC.

I understand that I could just install a precompiled version like the one from that video, but I'd rather not, better to keep things up to date IMO. I appreciate the suggestion though, if push comes to shove I could build it on another boot with all the right tools or within a VM.
 

Nimble

Member
You can't map one ip address to another. You need to map a network name.
I have two networks right now, one where every computer I have is connected to a switch that connects to a router, and another where every computer is connected to a switch that's connected to a NAS. This is to allow for full speed file transfer with the NAS and between PCs without saturating the network that my internet runs on. On both networks I have static IPs and the NAS subnet is 192.168.2.1, when I do:
Code:
192.168.2.3 192.168.2.5

And I ping 192.168.2.3 it arrives at 192.168.2.5, where the first IP is my main desktop and the second is my render pc. Wouldn't that mean this shouldn't be working?

Not trying to contradict you, just trying to understand.
 

Harold

Active Member
if it works, it shouldn't
and down the road (or even right now) if you have a device on either ip you remap like that, it's going to break
 

Nimble

Member
if it works, it shouldn't
and down the road (or even right now) if you have a device on either ip you remap like that, it's going to break
I understand how it works now, not sure why I thought it was this way, but I thought the first record was the redirect.

Using:
Code:
172.21.255.72 WSL2

Allows me to put rtmp://WSL2/Restream in OBS, works great. Super easy to create a process that dynamically edits the host file, thanks!
 
Top