Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirecting request for an IP to another IP

 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy,

I'm trying to achieve something whereby any requests made from a Windows PC (machine A) to an IP lets say 223.223.223.223 (on a specific port lets say 1888 [Edit:even if it does that on all ports its fine]) should get redirected/rerouted to 192.168.1.1 (port 1888). The 223.223.223.223 is external IP and 192.168.1.1 is the internal IP of the same machine. So if from machine A if I open a browser and hit 223.223.223.223 or from any java code running on machine A if I hit 223.223.223.223 then it should go to 192.168.1.1. I tried changing the host file but that doesn't seem to work as windows is not doing a lookup. I think I can do something like this if I install a firewall on machine A but I'm not sure about that (maybe I need a proxy or something). Does anyone have any clue about how to achieve something like this?

Thanks in advance.
 
Tim Moores
Bartender
Posts: 2895
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A hosts file is used for translating domain names to IP addresses; it would work if you wanted to redirect accesess to "www.domain.com" to 192.168.1.1. But it would be used for all ports, not just a specific one.

A proxy would work if the source app can be made to use it - browsers can be set up to use them, but I don't think connections from arbitrary processes can be forced through one if their code isn't written with that in mind.

The built-in router of a firewall would indeed be able to do this via port forwarding, but I'm not sure if the firewall that ships with Windows can be configured that way.
 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Moores wrote:A hosts file is used for translating domain names to IP addresses; it would work if you wanted to redirect accesess to "www.domain.com" to 192.168.1.1. But it would be used for all ports, not just a specific one.

All ports is fine (I've edited my post to reflect that). But when the request is made for an IP windows doesn't seem to consider the host file.

Tim Moores wrote:The built-in router of a firewall would indeed be able to do this via port forwarding, but I'm not sure if the firewall that ships with Windows can be configured that way.

It would be helpful if you know about any firewall (may not come with windows that's fine) that you know of which can do this?
 
Tim Moores
Bartender
Posts: 2895
46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But when the request is made for an IP windows doesn't seem to consider the host file.

Correct - it's used only for translating domain names, not IP addresses.

It would be helpful if you know about any firewall (may not come with windows that's fine) that you know of which can do this?

Not sure what one would use on Windows; ipfilter/ipf and iptables are common Unix firewalls/IP routers. The hardware router on your network should have one built in.
 
Ankit Garg
Sheriff
Posts: 9528
32
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim, that was helpful. I'll check with the networks department of our office if they know of any such firewall (or maybe configure a router)...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic