Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2007

Tip: Looking for answers? Try searching our database.

Set client IP of HttpURLConnection

Thread view: 
js@deriva.de - 07 Jun 2007 11:00 GMT
Hello,

I have the following problem:
On one of our servers runs a web application which connects through a
HttpUrlConnection to another server and sends requests. Our server has
two IP addresses. The other server only accepts requests from one of
those. But our server uses the other one as default...

The following options are not possible for different reasons:
- to write our own HttpUrlConnection class
- to change the default IP of our server
- to change the configuration of the other server
- to fiddle with the IP of outgoing packets via NAT or something

Does anyone know how to set the source IP of the request from Java?

Greetings and thanks in advance
Jan Strube
Gordon Beaton - 08 Jun 2007 08:19 GMT
> - to fiddle with the IP of outgoing packets via NAT or something

The "wrong" outgoing interface is chosen because it matches a routing
rule, probably the default route of the connecting machine.

You could set up a static route to the other server that specifies the
correct local interface, no need for NAT.

/gordon

--
Esmond Pitt - 08 Jun 2007 09:40 GMT
It can't be done in Java. AFAIK an HTTP request doesn't even contain it,
 it's in the TCP packets, and you can't control that.

You will have to fix the fussy server.
js@deriva.de - 08 Jun 2007 12:36 GMT
I've got the solution:
With the Apache Commons HttpClient it is possible to set the local
address.

Greetings
Jan
Manivannan Palanichamy - 08 Jun 2007 15:13 GMT
On Jun 7, 3:00 pm, j...@deriva.de wrote:
> Hello,
>
[quoted text clipped - 14 lines]
> Greetings and thanks in advance
> Jan Strube

looks like a puzzle in java :-) Those 4 steps are the possible ways of
finding a solution to this prob.
anyway, you could set the source ip of packet in using Jpcap -- Java
packet filtering libraries. But, that will
require highest user login, such as root in linux or administrator in
windows.

--

Manivannan.Palanichamy (@) Oracle.com
http://mani.gw.googlepages.com/index.html


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.