0

I have a MikroTik router with dynamic IP. I also have one of PCs connected to that router via cable. That machine has a TCP socket server program running on it. Previously I was testing the server by connecting from another machine in the same LAN. Now I want to connect with the server from any PC via internet. I tried this and this tutorials. I still can't connect to the server. I currently try to set it all up on Windows 10. I double checked firewalls on both client and server machines. When the client is trying to connect (via Wi-Fi), the socket fails with an error:

No connection could be made because the target machine actively refused it.

The error is API specific (using boost.asio in this case) so probably every other netwokring API would issue some different error.

What I have done:

  1. Login into my router.
  2. IP -> Firewall -> Nat-> Add New:

General:

enter image description here

Action:

enter image description here

The IP in the 'Action' panel comes from ipconfig -> Default Gateway. But I also tried the IP from IPv4 Address line as I am not completely sure which of those should be used.

That's basically it. The client uses the internet IP of the router, which I put into the "Dst.Address" field. And here I also tried to substitute with WAN IP (via http://wanip.info/), which is different from router's internet IP. Again, I am not sure which one should be used. My reason tells me that the WAN IP is not what I should use on the client program as it doesn't take me to the router. Maybe I am wrong. Any help to get this setup working will be highly appreciated.

Michael IV
  • 145
  • 8

1 Answers1

0

First of all, the main reason is that your WAN address is still a private address in the 10.0.0.0/8 subnet which is not routable on the public internet - the reason is that there is a carrier-grade NAT going on, and basically the clients get private IP addresses with the ISP doing the NAT, just like your router, just on a much larger scale. If you want it publicly accessible, maybe you can talk to your ISP about getting a static public IP address, though if they are open to it, they'll probably want you to pay for it.

Secondly, when doing dst-nat, you have to put the target computer (the PC with the server software) address in the "To addresses" field - the idea is that in the "General" section you define what connections to match, and in the "Action" section you define what to do with them (where to send them, in this case.)

pilsetnieks
  • 286
  • 2
  • 13