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

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

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.

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
In the file type
<destination_ip> <source_ip>
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

Related

IIS hosting, can't view site from my other machine on the same network

I have a network setup containing two machines.
On one machine I have a site hosted with IIS.
I have added an entry in the HOSTS file pointing my local IP to this domain
10.42.12.105 to - www.mysite.come. Then I configured to accept incoming calls on TCP Port 80. By going to windows firewall with advance security
Inbound Rules -> Action -> New Rule, select "Predefined" and then select the last item - World Wide Web Services(Http) and allow the connection. Also allowed port 80 too.
I can access the site with www.mysite.com with no problem on the same machine.
what I would like to do is be able to view this site from my other machine on the same network.
Can anyone see where I'm going wrong?
A host file is a way to tell 1 machine to map a web address to an IP address, like an alias. It only works on the machine containing the HOSTS file. For example, I could add a line in my hosts file which could map your URL www.mysite.com to 127.0.0.1. My browser would think your site is on my PC now.
So, if you want to set up this alias/name-mapping for multiple machines, you will need to add a host entry, on each machine (so they all have this mapping), or add this mapping to your local DNS (on your domain controller or router).
To check your firewall rules and IIS config, try having your test PC go to the IP address instead of the alias (from HOSTS).

Serve web page on named local URL

I know that on a local network, it is possible to redirect from the default port to another port like so, and run an application:
# Routes all traffic from port 80 to port 3000
sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3000
node .
For clients to access the service, typing 11.0.120.131 will have the same effect as typing 11.0.120.131:3000 (if 11.0.120.131 is the IP of the computer running the node server).
I've seen in a couple cases where you can type into the address bar a word, e.g. http://meetings and it will actually pull up a web page (as if typing in an IP). I'm not sure what the technique is called, but I would like to achieve the same thing on my local network.
Is this possible on a Linux machine using a command similar or not to iptables above?
URLs are resolved to IP addresses via the Domain Name System. In order to create a fancy URL like meetings, some router between you and the DNS server looks for those particular URLs and resolves them to the correct IP address (or provisions your machine to use a custom DNS server which does the same thing).
If you want to achieve this behavior on your computer, you can edit the hosts file (on Linux, /etc/hosts). This file contains a list of explicit URL resolutions; if you put a URL in this file, such as meetings, then it will be resolved to the IP address you specify, without ever contacting a DNS server.
If you want all the computers on your network to use this behavior, you have to set up an actual DNS server for those URLs, and configure your router to specify it as the DNS server to use, which may not be possible depending on the brand of router.

Will changing HOSTS file to block unwanted sites mess up IIS?

I've got IIS set up on 127.0.0.l and I'm tinkering with adware blockers that use 127.0.0.1 as the address to route malicious sites to (127.0.0.1 www.badsite.com)
Will this make all calls to those sites hit my IIS and make it load a default page?
Is there a way to still block these sites via HOSTS without hitting IIS?
On Win 7 pro.
Yes, all calls to those sites will hit your IIS instance. IIS might return a default page, or a "file not found" page, or if it has an actual page it might return that.
127.0.0.1 is used because it always points to the local machine, which prevents your computer from wasting bandwidth (and possibly DDOSing some poor victim) by trying to send these packets externally. You could try 127.0.0.2 or 127.254.254.254, which would work IIS is listening on 127.0.0.1 specifically or 127.0.0.0/24 rather than on every address on the loopback interface.
There isn't any other address guaranteed to not reach the public Internet, although you may be able to set one up yourself by locally blocking outgoing packets to 192.0.2.1 or the like in your firewall.
Other options for ad blocking include using a local proxy which would return HTTP 404 or the like for blocked URLs or a local DNS relay that would return NXDOMAIN for blocked domains.
Yes, as Anomie points out, they will hit your IIS and then will serve the default page or an error status or an actual page if it finds one (unlikely however).
To avoid that, I use 0.0.0.0 as the address. I've been using it with MVPS Hosts file without any issues for years now.
Also, as this post suggests, you can use 0 too (any invalid ip will do I guess)
Both of these will be a bit faster as they will avoid the wait for timeout on 127.0.0.1.
Another option would be to run IIS another port. If you are running behind a firewall or something like a home router, you could set it to port forward port 80 for incoming requests to your alternate port. (If you're using IIS inside, you'd need to go to http://[your ip address]:[alt port])

Windows hosts file and IIS binding question

I'm building a few SharePoint sites, and I want to make use of zones so I may set security different in the various zones.
My workstation has a local SharePoint, and I use it for development.
My workstation has a static IP, and is connected to the internet.
When I make a SharePoint site, I want to add a host header, for instance, devbox.com.
I do not own this name, nor do I want to.
I then add an entry in my hosts file, but when I surf to http://devbox.com:8080, it does not resolve.
Do I need to register the name I want to use, or should this work, i.e., have my hosts file resolve names/IPs first?
It should work. You will need to make sure your website has the right mappings, though. For example, if you want your site to respond to http://devbox.com:8080, you'll need to either set up your website to respond to all IP addresses and port 8080, or to respond to the devbox.com host header and port 8080.
BTW, to test whether your HOSTS file is set up correcly, open up a command line and PING devbox.com. You should see the address resolved to your local machine's IP address. If not, you've done something wrong in how you've set up your HOSTS file... please post the line in the HOSTS file that you're using.
BTW, per my comment below, you should probably use 127.0.0.1 (aka localhost) in your HOSTS file line, rather than your external IP. This will remove the IP address as a potential point of failure (e.g. in case a firewall blocks the traffic)

xampp server (How to get up and running)

I've been developing locally on a little ubuntu netbook with xampp for about 7 months. Two weeks ago I got a computer I'd like to use as a server. I've installed the latest Ubuntu distribution and xampp, moved all my files over, and forwarded port 80. I've also got a domain name from dyndns.com which is being updated by a client which runs in my router (a Netgear WGR6154 v8).
Now, when I try to access my server by typing in the address I got from dyndns.com the browser loads until it timesout. I can access everything locally using localhost as the address so I believe xampp is running, just unable to connect with the internet.
In order to be able to view my files over the internet what should I do next?
Thanks to all in advance...
[I'm starting a bounty for the first person to help me get my files successfully online]
You have a combination of issues here, and that is something of a problem. Each issue is complex in an of itself. Here is what I would recommend to get you going for certain.
First verify that you can surf the web from your server. This will confirm that you have a working ethernet interface.
Step 1 make sure that XAMPP, and your files are viewable from your home network. I assume you are using something like 192.168.1.X for your network and perhaps your server is 192.168.1.10
Go to another computer in your house and type http://192.168.1.10/ and see if you can see your files. If you can then you know that the server is properly configured and XAMPP is working.
Then add an entry to your hosts file to resolve yourdnsrecord.com (or whatever your dyndns record is) to your private ip address. Then when you type yourdnsrecord.com into a browser from that computer you should still get your files. This will rule out your server being improperly configured to listen for that domain name.
Next you need to test to see if there is a firewall problem. To simplify this, first remove your home router from the equation. Instead, place your new server directly onto your internet connection. (assuming you can). This way, you do not need to have NAT or firewalls properly configured. Your dyndns name should map to a public IP and your server should then have that IP and be connected directly to the Internet. If you have your server directly connected, and the command ifconfig from the root prompt returns the same public IP address that your dynamic dns record is point to, then it should work.
It will make your life easier if you have an iphone or some other way to test how your network is seen from the Internet.
If your public IP as shown by ifconfig is different than the IP record in your dyndns account, then your dynamic dns update script is broken. manually set the IP, and see if things work.
It is very possible that this will not work. Some ISPs firewall port 80 preventing their subscribers from hosting servers. Once you have your server directly connected to the internet you can test this (even if your dns is not working) by using the public IP address. As root, type ifconfig from the command prompt to get your public ip address. Then type the command tcpdump -i eth? port 80 from the root prompt. eth? needs to be the same interface that you saw had a public IP address from the ifconfig command. usually this is eth0 but it might be wire0 or something like that.
This command will show you all traffic coming on port 80 to your server.
From an iphone (or whatever second Internet connection you have) browse to the IP address that you got from your ifconfig command. If you see something on your server (and it is directly connected to your ISP) then your ISP is not firewalling you.
If you can get to your server, when it is directly connected to the Internet, either by IP address or by DynDNS address, then your ISP is OK and it is time to debug your firewall.
Two things need to work for your firewall to be configured NAT, where the public address that your router gets from your ISP is converted into your private network and a firewall rule which permits that traffic. If you get this far, then you know your firewall is the problem and then it is just a matter of getting its configuration correct. There are far to many home routers to document here, but you usually can find how-to instructions for your router for this task from the manufacturers website (usually it is part of the manual)
If you follow these instructions exactly you will get your system working. Make comments on the process and I will be happy to modify this to make it clearer.
HTH,
-FT
You should make sure your xampp is not listening to only the localhost.
to do so edit your apache configuration file and check and search for Listen directive
you should be able to know also by analysing the output of netstat -a.
After that make sure your router is forwarding properly, using tcpdump would help.
drop me a comment if you need more help.
Cheers

Resources