Re: Controling source IP address used on outbound HTTP GET request
timwhunt@gmail.com wrote:
We are looking for a way to control the IP address we use for outgoing
HTTP requests so that we can choose between two IP addresses we will
have on a linux server. We have a Linux server running Java/Tomcat
which is making HTTP GET requests to Web servers. We want to be able
to use one IP address when making requests to one Web server and use a
different IP address when making requests to another server. The
bjeremy wrote:
Then just open two different Sockets, each for one destination IP
Address. Most likely you will need to open a socket per request, unless
you are using persitent connections with the web server.
Was the OP referring to using different server addresses or different client
addresses? Either way, I am pretty sure that the answer provided by bjeremy
(infra) solves it.
Is it possible to control which of the server's IP addresses is used
for each request, and if so, how? Is there some way we can set up the
Linux server or Tomcat to make it work?
Yeah... if you have two IP addrs on your linux server, and you want to
use one or the other you can simply add a routing entry (/sbin/route)
in your linux servers routing tables. If you are going to web server A,
then send the packet out interface (dev) A, if you are going to B, use
interface B.
BTW, I believe it is possible to have two IP addresses on a linux
server, but I haven't looked into what's involved. Feel free to
comment on this if relevant.
You would need two nic (network interface (i.e. ethernet) cards) and
bind an ip address to each card... You can also do virtual
interfaces... but I'm assuming you don't want to do this.
If you did want to, web servers like Apache's give very fine-grained control
over IP address service.
- Lew