Accessing devices on your home network from the outside world
When you created a domain name via www.no-ip.com in the previous instructions, this domain name allows the outside world to find you. Specifically, website visitors can find devices on your home network, as long as these devices have Internet access.
When website visitors contact your domain name (in my case, itwinkle.ddns.net), their request comes from their computer's web browser, through the Internet, to your home Internet router. If any devices on your home network are "listening", they will respond. By "listening", I mean devices that can show a webpage to the website visitors.
Your Raspberry Pi running Falcon player is a "web server"; it shows a web interface when you access it through your home computer's web browser. So, when website visitors go to itwinkle.ddns.net on their web browser, they will be shown the web interface for Falcon Player, as it was "listening" and responded to their request.
One Internet connection controlling multiple devices
The problem is that the outdoor webcam needs to be "found" by website visitors. The webcam is also a webserver that uses a webpage to show the live video feed. So when website visitors go to itwinkle.ddns.net, how does it know which webserver to use (Falcon player or webcam). To make Internet controlled lights, website visitors need access to both at the same time. They need to see your house with the webcam and control your lights with Falcon Player.
Accessing multiple devices with your Internet router
Normally, only on web server can be accessed by a single domain name. But with "ports", you can access multiple web servers from a single domain name. The default port number for most websites is "80". When your Internet router receives contact from a outside visitor, it sends that request to any devices on your network listening on port "80. Both Falcon Player and your webcam are listening on port 80, which is a problem because they will both respond at the same time.
To solve this problem, your Internet router may have a feature called "port forwarding". This allows website visitors to use multiple port numbers to access your multiple devices. In my case the Raspberry Pi running Falcon player "listens" for requests on port 80 (the default port for web pages), while the webcam listens on port "8080". So, when website visitors go to "itwinkle.ddns.net" or "itwinkle.ddns.net:80", they will see the Falcon Player web interface, while going to "itwinkle.ddns.net:8080" will show them a live video feed from the webcam.
Note: The webcam has an administrative web interface on port 80. When I access the IP address of the webcam, I can login to the camera to make changes. In addition, you can configure a "video streaming" port in the MotionEye OS settings to easily display the live video stream (bypassing the web interface). I set this port to 8080. When I access itwinkle.ddns.net:8080, the router directs the request to the IP address of the webcam, then to port 8080 on the webcam, which displays the live video stream.
Not every Internet router has this "port forwarding" feature and the method to activate it is different for each brand of router. Below is how I setup this feature on my TP-Link brand of Internet router:
- Using a web browser on your home computer, go to the gateway of the IP address that was assigned to your home computer. The gateway is usually the IP address with a ".1" for the fourth number. For instance, my home computer is assigned an IP address of 184.108.40.206 by the router, so the gateway is 220.127.116.11.
- You may be prompted for a name and password to access the router's web interface. Enter the name & password if prompted.
- In the router's web interface, choose Forwarding from the left-side menu, then choose Virtual Servers from the submenu.
- Click the [Add New...] button to add an entry to the Virtual Servers list. Set the Service Port to "80" and set the IP address to the RPi running Falcon Player. Make sure that Protocol is set to "ALL" and Status is setup to "Enabled" for this entry.
The RPi has a built-in web server which is used for configuring Falcon Player via its web interface or running scripts that control your lights. This web server responds to visitor's requests on service port 80, which is the default port for accessing a website.
To allow an Internet visitor to see Falcon Player RPi, they do not know the IP address of your RPi nor the IP address of that your Internet provider assigned to your home network. But since you are using Dynamic DNS, visitors can find Falcon Player through the DDNS address. In my case, they point their web browser to itwinkle.ddns.net. When a visitor's web browser contacts your home network, their web browser defaults to port 80.
- Click the [Add New...] button again to add a second entry to the Virtual Servers list. Set the Service Port to "8080" and set the IP address to the RPi running the outdoor webcam. Make sure that Protocol is set to "ALL" and Status is setup to "Enabled" for this entry.
When Internet visitors point their web browser "itwinkle.ddns.net:8080", your router directs the request to port 8080 on the outdoor camera RPi, displaying the live video stream. The camera's RPi also has a built-in web server which is used for configuring the live video feed from the camera. This web server responds to visitor's requests on service port 80, which is the default port for accessing a website.
- Click the [Next] button at the bottom of the screen, then save your changes to the router.
In summary, your RPi running Falcon Player and the RPi running the webcam both respond to incoming requests on port 80. This is a problem as both RPis are listening for incoming requests from Internet visitors on this port. The router, through port forwarding, can send light control requests to the Falcon Player when visitors specify port 80 on their web browser. When visitors specify port 8080 on their web browser, the router sends those requests to the webcam instead. Thus both Falcon Player and the webcam can respond to incoming requests, even though they both "listen" on the same port (port 80).