简体   繁体   中英

How to redirect connections by an exe file to a specific external ip address

  • I have an exe program that connects randomly to one of the 4 addresses 188.39.21.82...83...84...85 out of which only 82 works
  • Currently I blocked the remaining addresses using Windows 10 Firewall outbound rules by simply blocking them
  • My problem is that the program will keep attempting to connect say 10-20 times (times out after 20 seconds each time) before it finally connects to the IP address ending with 82
  • Is there a way that I can write a rule such that the program will get redirected to the IP address ending with 82 regardless of which IP it attempts to connect with?
  • Example: the program tries to connect to 188.39.21.85 but gets redirect to 188.39.21.82
  • I want to add that all the IP addresses actually work but the exe file doesnt work properly on any of them except the one ending with 82

you could setup the virtual host for redirecting the traffic.

1.go to Windows > Search > Run and paste the following line C:\Windows\System32\drivers\etc\hosts

  1. In the file type
<destination_ip> <source_ip>
  1. save the file eg in your case
188.39.21.82 188.39.21.85

now all traffic from 188.39.21.85 will redirect to 188.39.21.82
similarly you can redirect all ips traffic to 188.39.21.82

Same can be used for unix system using the hosts file

Try using Netsh's add v4tov4 (found here and here ) to proxy outgoing connections from the range 188.39.21.83 - 188.39.21.85 (You don't need to include 82 since it works) to go directly to the working host. Only TCP is supported though.

add v4tov4listenport=[port] connectaddress=[188.39.21.82] connectport=[port] listenaddress=[not working IPs]

Note that you may not be able to list listenaddress to multiple addresses in one command, so you might have to change the IP and execute it again.

you may as well login to your home router go to port forwarder section usually located on network / advanced setting. from there you can redirect requests from port to another. to access your router usually its the gateway numbber. you can run cmd and type ipconfig / all it will show the internet gateway.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM