1

TP-Link repeaters allow to access their web interface through a certain domain when being connected to them. If you are not connected to them and access the very same domain, you see their website. How is this done under the hood without running into caching issues? Basically I want to ryedirect the traffic going to a certain domain to a local machine if the user is accessing it from within the local network, and routing it to a remote machine if accessed from the public internet.

Coxer
  • 157
  • 14

1 Answers1

1

You can achieve this with DNS, for example, when a device is connected to the local network, then you can use DHCP to provide your own DNS servers, and configure them to "lie".

You can create, on your internal DNS resolver a record that translates example.com to 192.168.1.23.

When the devices will no longer be connected to your network, they will get another DNS resolver which will provide the real (external) IP address of example.com to your clients.

Swisstone
  • 6,357
  • 7
  • 21
  • 32
  • Won't the DNS entry be cached at that device though? Also, I don't think the TP link repeat runs a DNS server. – Coxer Jul 16 '18 at 20:05
  • You can set a very low TTL on the DNS entry to ensure that the client device will not cache the result. – Swisstone Jul 16 '18 at 20:48
  • But I don't control the cache time for the outside DNS, right? – Coxer Jul 16 '18 at 21:01
  • Of course not. If a client connects to the external domain before yours, you will have to trust the OS for DNS client cache management. Windows does things correctly, and flushes the DNS cache when the computer connects to another network, however I don't know how other OS handle client DNS cache. – Swisstone Jul 16 '18 at 21:10
  • I still wonder whether there is a solution using for instance `iptables` since obviously the TP-link access point does not run a DNS server but only works as a gateway. – Coxer Jul 17 '18 at 13:19