By default, Windows treats WiFi connections as non-metered. Simply said, as soon as you join your mobile hotspot, literally every background process will start using the Internet: download updates and who knows what else. It may hurt if you are charged per megabyte or if your data contingent is basically limited.
In order to avoid this issue, Microsoft introduced a flag called 'metered connection', which you can set for a particular WiFi profile. The problem is, probably no app takes care of that flag, which renders it useless.
One solution is to virtually disconnect the operating from the shared Internet and let only the app of your choice to get an actual connection. There are different possible scenarios for that. Let's start with the most flexible one, at least as of my opinion: a Socks-Proxy. It requires an Android phone as a server. No idea whether anything similar works for iPhones and, to be honest, I don't care.
On the phone:
apt install openssh
On the PC:
ssh -ND <local_port> <your_phone_ip> -p 8022 -i <private_key_path>
-N skips execution of remote commands (forwarding ports only)
-D enables dynamic port forwarding with SOCKS4 and SOCKS5 protocol on the port given as a
local_port, which is just an arbitrary chosen port number on your local machine that will act as a proxy for your apps. Take anything above 1024.
your_phone_ip is the Gateway Address you noted down in the preparation steps.
private_key_path is a path to the private SSH key in an OpenSSH format. The OpenSSH will complain if the access rights are too relaxed. On Windows, you will have to remove access rights to anyone but you in order to proceed.
about:config page, look for a setting called
network.proxy.socks_remote_dns and set it to
The difference of this scenario is, all traffic from the PC will be redirected to a fixed location (Target A on the diagram). Depending on the needs, you may want either multiple such redirects or a proxy server on the Target A, so that other destinations are dynamically reachable (Target B on the diagram).
On the phone:
apt install socat
socat TCP-LISTEN:<phone_port>,fork TCP:<target_address>:<target_port>
phone_port is an arbitrary chosen port number on your phone that will receive connections from your PC. Take anything above 1024.
target_port is the location in the Internet, to which the traffic should be forwarded.
On the PC:
phone_port chosen above. Your phone's IP address is the Gateway Address as noted before.
Good to know:
socat session in the background.
socat is, you can forward UDP protocol as well, e.g.
socat UDP4-RECVFROM:<phone_port>,fork UDP4-SENDTO:<target_address>:<target_port>.
UDP6. For listening,
UDP6-LISTEN, if the hotspot works in IPv6 schema.