Controling source IP address used on outbound HTTP GET request

T

timwhunt

Hi,

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
actual Java method we are using to get the page is
connection.getInputStream(), and we get a connection with
url.openConnection();

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?

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.

Thanks!
 
B

bjeremy

Hi,

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

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.
actual Java method we are using to get the page is
connection.getInputStream(), and we get a connection with
url.openConnection();

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.
 
L

Lew

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.
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.
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top