Now I know that many people know all this stuff, but for the benefit of newbe's, added this section to understand how a web address gets to your server.
At this point, we can talk from one computer to another on the local lan, using the target computer ip address and port number. Think of this like a telephone number with the computer being the area code and the port as the rest of the phone number. As example, the phone number 408-555-1234 has an area code of 408 and the phone number being 555-1234. The 408 is your router and the 555 is your computer and the 1234 is your port number.
Now a server is just a piece of software located on some computer, listening on a port for a message for it to do something. The computer has an IP address that identifies the computer. On the local lan, you can say 192.169.1.20 : 8080. the192.168.1.20 is the computer and the 8080 is the port , sometimes known as a service.
From the outside, i.e. the www, a remote computer wanting to connect to a service (owncast,ftp,etc) in your home lan network, has no idea how to get there. This is where DNS or domain name lookup comes into play. From the outside, you want to use a name instead of a ip address to get there. Many people have a web website. You normally get there by typing in a name like my_website.com using using a brower. You browser goes out to DNS or dynamic name server. Your browser talks to dns and gets an ip address in exchang and "ONLY" an ip address. There is no port information or ip address for the individual computer on your home network. just how to get to your router.
When you send a request to my_website.com : 8080, the browser gets the ip address from the DNS and creates a new target maybe 147.12.34.10 + 8080 to get 147.12.34.10:8080. At this point , the request comes into your router and it has no idea what this port 8080 is and on what local computer it is located on.
Now suppose you have 3 web cameras on your lan and each talks over port 1200 and has 3 different ip addresses. You can't just say :1200 coming into your router. But using PORT FORWARDING you can. Ffrom the outside, assign port 1201 to camera 1, 1202 to camera 2 and 1203 to camera 3. These are completely made up numbers you choose. In the router, you have a translation table (DNAT) that creates a new ip address and port number form the incoming made up port number.
Internally the 3 web cam have the following addresses :
Cam 1: - 192.168.1.21:1200
Cam 2 - 192.168.1.22:1200
Cam3 - 192.168.1.23:1200
Notice the .21,.22,.23 that identifes the indivual cameras.
The router DNAT table translates 1201,1202 and 1203 into
1201 as 192.168.1.21:1200 (cam 1)
1202 as 192.168.1.22:1200 (cam 2)
1203 as 192.168.1.23:1200 (cam 3)
When setting this up, you need to log onto your router as admin and create the tables. Different rotuers have differernt menus.
So the thing to keep in mind is that when using a domain name.
1. The name like my_website.com gets translated into your router ip address.
2. The port number you invent gets translated (via the DNST table in the router) into the real local computer ip and the correct port number for that service.
So you are sitting at home and you bring up vlc or media player and you want to set cam 1
You want the camera , not the website, so you might typing "cameras.my_website.com : 1201" for cam 1
ok, so what is the "cameras." tag.
When your media player asks for .cameras.my_website.com, what happens first is that my_website.com as the address gets looked up. This would be the ip address of the actual website. Now all DNS addresses also support the added ".some tag.also as a secondary address. This is stored in table that stores "A" records. This is used to point at servers other than the my_website. i use godaddy and I would just create a new A record and give it the ipaddress of my router. So .cameras.my_website would now point to my router.
So to talk to "cameras.my_website.com:1201" which is camera 1
1. media player asks DNS for the address of cameras.my_website.com
2 DNS looks up my_website.com
3 DNS sees secondary tag "cameras.", looks that up in the A record table and returns the external ip address of your router
4.Port forwarding in the router see 1201 and translates this to the camera 1 ip and port 1200.
Basically there are two lookups, one in the dns and one in the port worward part of you router.
Once you get your head around all this, you will find it not that hard.
If I got any of this wrong, please let me know.