I have a simple network in my company, where I use my ISP's ADSL Router. The LAN is
192.168.1.0/24. Router's IP is
192.168.1.1. It also has DHCP enabled, which ranges from
2 to 250.
I have a Digital Video Recorder (DVR) configured with static IP address, with the following LAN configuration:
IP : 192.168.1.254
GW : 192.168.1.1
I also need to configure connection ports - in this case, DVR's HTTP port is
8080 and Server port is
6036. I made the adjustments on my router to forward the ports to the DVR.
So I downloaded the phone APP and configure it to connect
192.168.1.254 - it works. Therefore, DVR network configuration is correct. Then, I configured the DVR's
DDNS and reconfigured the APP on my cellphone... and here is where the problem happens:
When I'm outside my work network (ie. 3G or at my house), it works. It connects to my DVR using the
DDNS. However, if I'm in the network it doesn't work.
Lets say my network's public address is
18.104.22.168. So, from my phone are coming out packets with destination address 22.214.171.124 to both ports (8080 and 6036). So it's trying to connect correctly as expected (because I can connect to the DVR from my house, so I know both DDNS and port-forward are correct)
My reasoning: when I'm inside the network, the packet reaches my router, matches only the default route and goes out the gateway. However, now the packet will have both source and destination address equal to
126.96.36.199 ... so the gateway network will just drop my packet?
I thought adding a static route to my routing table would fix this, but as my public IP always changes, that won't be every efficient...
My conclusion so far: you can't connect to your network using your public address.
(Why I wanna solve this: the way it is now, all phones need two configurations: one to connect to the DVR when we are here, and another one for when we are not here.)
My question: what exactly is happening and why?