Set IP sender on packets sent from Openfire

Hi to all.

I have this problem:

I have two openfire servers open on same machine. This machine has two network card, one has IP, and one has IP

I edit the xml files of the servers (target: /openfire/conf/openfire.xml) for to do that each server is listening his network card:

first server:


second server:

Then, I have a client “user1” (user1@ that is logged on first server and a client “user2” (user2@ that is logged on second server.

Now, I have this question:

Is possible to set at application layer (so directly with Openfire) the IP sender of the packets sent from the users?

I want to set at application layer the IP in the packets from user1@

I want to set at application layer the IP in the packets from user2@

I ask this because if I do “sniffing” of packets with Wireshark on this machine I see that all packets sent from user1 or user2 have all as IP address


I don’t do this with routing table, but I must do it at application level. Do you know if is it possible?

I hope you understand my problem.

thank you in advance,


Hi Crystal,

is this an Openfire issue or a client issue? You write “all packets sent from user1 or user2 have all as IP address”. So I wonder if you want to run local clients. Usually one has remote clients and there this shouldn’t be an issue.



I forget to say that user1 and user2 send packets to another server where is logged an user3.

I want that user1 speak with user3 and user2 speak with user3, but I want that the packets from user1 to user3 have IP and packets from user2 to user3 have IP

Instead, now, packets that arrive to user3 have all same IP:

I must doing it directly with Openfire (by application layer).

Is it possible? Do you understand now?

I hope yes.

Thank you very much.

Hi Crystal,

this should be possible. Java offers two (to keep it simply) Socket() methods:

public Socket(InetAddress address, int port)

public Socket(InetAddress address, int port, InetAddress localAddr, int localPort)

While it it usually fine to let Java or the OS decide which IP address to use there are always some reasons to use a special source address.

I just wanted to create an issue, but there is already an issue to get this fixed, see - I did create this more than one a year ago.

So you may want to fix this and compile Openfire for yourself.



I see your example. But I have a problem, I don’t know Java language very much.

Where must I insert this code?

thank you for you answer, this is exactly what I want!


there are only a few java files which contain “Socket(” so it should be quite easy to find them. Insert the code within JM-1064 as shown, between “new Socket()” and “socket.connect()”. There are some documents in the Openfire Developers forum about downloading the source and compiling it.


This Java files that you say are all in the directory lib of Openfire?

So, you think that is sufficient to insert only this code:

// get interface address to bind
String interfaceName = JiveGlobals.getXMLProperty(“network.interface”);
SocketAddress bindInterface = null;
bindInterface = new InetSocketAddress(interfaceName, 0);
// bind to interface,

for do that?

thank you very much…


I’m trying for to open this .jar files, but I don’t know as can I open it.

I have Eclipse software but it don’t open this file.

Can you help me about edit this file?

thank you…

Hi Crystal,

read ocuments - there are and

These documents should help you to setup Eclipse and Openfire. You need to download the source code, either as .zip or from SVN.

You can open .jar files with “jar”, “7zip”, … but they do contain .class files (compiled .java files) and are thus not the right place to modify something.