RMI app behind NAT firewall

Tobias Weih <[email protected]> Fri, 27 Jan 2006 12:59:12 +0100
Newsgroups gmane.comp.java.sun.rmi
Message-ID <OFF3AE707B.6286577A-ONC1257103.0041BC91-C1257103.0041D824@de.ibm.com>
I have a problem getting my RMI application to work. Having a RMI Server
app running in a VMWare that forwards port 1099 in a NAT enviroment.
Physical machines IP on the outside = 9.154.38.47
Physical machines IP in local area = 192.168.0.1
Virtual machines IP = 192.168.0.100

I start a rmiregistry on my virtual machine and since port 1099 is
NAT-forwarded I can connect to the registry from the outside using telnet
9.154.38.47:1099.

I startup my serverside rmi-app on the virtual machine
code:

-Djava.rmi.server.hostname=$HOST



and in my app I do the following binding:
code:

System.getProperties().put("java.rmi.server.hostname", HOST);
Registry reg = LocateRegistry.createRegistry Registry.REGISTRY_PORT);
Naming.rebind("//"+ HOST + ":1099/" + CommandBroker.NAME, this);



This work fine with HOST=127.0.0.1 or HOST=192.168.0.100 but when setting
HOST=9.154.38.47 (the public IP address), startup fails with:
code:

java.rmi.AccessException: Registry.Registry.rebind disallowed; origin
/9.154.38.47 is non-local host



When server is running with HOST=127.0.0.1 or HOST=192.168.0.100 (like I
said using HOST=9.154.38.47 doesn't work at all, the server is not allowed
to bind) the binding from the outside using my client-app works (bind to
9.154.38.47 the public IP) , but however when trying to actually use the
remote object the client throws the following exception:
Using HOST=127.0.0.1 on serverside
code:

Operation timed out: connect:could be due to invalid address


or when server HOST=192.168.0.1
code:

java.net.ConnectException: Connection refused: connect
                 at
sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:585)



I assume using the public IP on serverside by setting HOST= to 9.154.38.47
is the right way, but as stated above binding to the rmiregistry is not
allowed! What am I missing?

Thanks alot, your help is very much appreciated.
Cheers,
Tobi

===========================================================================
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff RMI-USERS".  For general help, send email to
[email protected] and include in the body of the message "help".

For a list of frequently asked RMI questions please refer to:
http://java.sun.com/j2se/1.3/docs/guide/rmi/faq.html

To view past RMI-USERS postings, please see:
http://archives.java.sun.com/archives/rmi-users.html