How to connect webservice client with specified IP (network interface) with Apache CXF?

My problems: there is one default RHEL server with 2 network adapter configurations:

  • eth0 with IP 10.100.0.1
  • eth1 with IP 10.100.100.1

In addition, Red Hat has jboss-6.0.0.20101110-CR1 installed with an EAR deployed on this JBoss, which is a simple servlet that listens for incoming data, and after some processing, the application sends the processed data to another service network on another host (for example, 10.200.0.1) using the Apache CXF framework (such a proxy with some processing).

Now configuration problems.

When JBoss needs to listen for incoming data on eth0, IP 10.100.0.1 , you need to run run.sh with the -b switch: run.sh -b 10.100.0.1, which is simple and clean.

But I want to expand my problem: I want JBoss to call the web service on another host with 10.100.100.1 as the source IP address for network traffic. How to do it? Is there any switch / property / something that does the job?

Summary:

JBoss contacts eth0 to listen for incoming data on 10.100.0.1 and calls a web service with the source IP address 10.100.100.1 on 10.200.0.1 .

Please help me, any ideas are really appreciated. I want to avoid any iptables / xinted forwarding configuration :-)

Hello,

Mariusz

PS. I found another similar problem (but native JBoss WS related ...) in my company: one of our software providers modified JBoss5 jbossws-native-core.jar to force this behavior to add a line:

bootstrap.setOption ("localAddress", new InetSocketAddress (localAddress, 0));

in NettyClient.java when localAddress is supplied with the -D switch and read by the getProperty () method in the code. But also I want to avoid modifying JBoss components ...

+4
source share
1 answer

If JBoss only listens for one ip, all that it can easily answer with the same ip. I suggest you resolve this using routing, not hacking in java. I suppose, because it already works, that 10.200.0.1 is really accessible through eth0 and eth1.

I suggest making this available only through eth1, and then with jboss listen on both interfaces. Then Jboss will happily select any source address needed to route traffic.

You may need some appropriate routing on the remote side if you have some specific reason why you only wanted to listen on one interface, or if you cannot control it, you can write a servlet filter for failure / failure all traffic, arriving with the wrong destination address.

0
source

Source: https://habr.com/ru/post/1333150/


All Articles