Option '-Djava.rmi.server.hostname' unnecessary?

In this tutorial:
http://java.sun.com/docs/books/tutorial/rmi/running.html
you start the rmi server with:
java -Djava.rmi.server.codebase=file:/c:\home\ann\public_html\classes/
-Djava.rmi.server.hostname=zaphod.east.sun.com
-Djava.security.policy=java.policy
engine.ComputeEngine
but in this tutorial:
http://java.sun.com/j2se/1.4.2/docs/guide/rmi/getstart.doc.html#5321
you start it without the Djava.rmi.server.hostname option:
java -Djava.rmi.server.codebase=http://myhost/~myusrname/myclasses/ -Djava.security.policy=$HOME/mysrc/policy examples.hello.HelloImpl
I have also tried to omit the hostname option from the first tutorial and it works fine..
Why is it not necessary to specify the Djava.rmi.server.hostname option to make the examples work?
What is the function of this option?

It's only necessary if you have a fouled-up DNS which doesn't give the right hostname by default.
And if Sun had understood the TCP weak-end model better than they did in 1996 it wouldn't be necessary at all.

Similar Messages

  • -Djava.rmi.server.codebase Question.

    When I study the meaning of codebase in
    http://java.sun.com/j2se/1.3/docs/guide/rmi/codebase.html
    , I am still confuse what is different between codebase
    settings in Remote Object side and RMI Client side.
    The command options -Djava.rmi.server.codebase=
    http://myHost/myDir and -Djava.rmi.server.codebase=
    http://wwwserver/mydirectory ( in Figure3 and Figure4 of
    http://java.sun.com/j2se/1.3/docs/guide/rmi/codebase.html
    ) are set in which side ??
    The option in Remote Object side seems no any work.
    Who can explain its meaning ??
    Thank you in advance... Alan.

    Hi,
    For the dynamic class loading to work, you should give
    -Djava.rmi.server.codebase=http://some-server/
    you can see that it supports http protocol.. So there should be one web server running on the server side so that client can call it by name or by IP address.. Then try running the program again. now it will work..
    actually you should give this option on client side as it is the client who needs this property.. so in order to download classes the server machine should be addresable to the client in any method. if it is a LAN, try giving '\\computer-name' in the value of the property.. I haven't tried this, but I think you dont need a http server this time.. I am not sure abt this,,. check it out..
    - Bibin.

  • Rebind Method and java.rmi.server.hostname

    Hello,
    We are trying to execute a server on the internet which is installed in a machine whose private IP address is 10.X.X.XX.
    To access the server by internet, the IP address is 196.XXX.XXX.XX and is converted by NAT to the IP address 10.X.X.XX.
    I start the server with the command:
    java -Djava.rmi.server.hostname=196.XXX.XXX.XXX myServer
    Also, and according some recommendation in this forum, we don't use the "rmiregistry" and instead we use the method:
    Registry r = LocateRegistry.getRegistry(MYPORT);
    r.rebind("MyServer", obj);
    However,
    And it takes about over 4 minutes for this app to execute the rebind method. Does anyone know why ?
    If I start without java.rmi.server.hostname propert. it executes immediatelly, but then I can't access the server from outside firewall.
    Am I missing something?
    Any advice or idea?
    Thanks
    Gerardo
    PS. I am using Java 1.4.1 under Linux Red Hat 9.0.

    I start the server with the command:
    java -Djava.rmi.server.hostname=196.XXX.XXX.XXX myServerThe wait is probably due to your DNS setup. Is a client inside the firewall able to reverse-resolve a 196.xxx.xxx.xxx address?
    EJP

  • Propertie java.rmi.server.hostname during 1 minute

    Hello from Spain,
    I �m developing an application using Rmi over http (tunneling)
    I execute the example of "rmiservlethandler" and it 's works fine in localnetwork mode.
    Nevertheless, when i try to execute the application accross internet i must put the propertie
    -Djava.rmi.server.hostname=<public ip of server>
    I run this server but only works during 1 minute aprox.
    Later this minute, the server is automatically shutdown and it doesn't report any errors
    What can i do?
    Please, help me and thanks in advance

    I forget say that during this minute, the examples works fine

  • Reading java.rmi.server.hostname property

    When try to read java.rmi.server.hostname property within my server I got following exception:
    Exception in thread "main" java.security.AccessControlException: access denied (
    java.util.PropertyPermission java.rmi.server.hostname read)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    at java.lang.System.getProperty(Unknown Source)
    at engine.ComputeEngine.main(ComputeEngine.java:22)
    Any idea how to read this property from program.
    Syed

    Looks as if you need to create a security manager or add a security policy file.
    To create a security manager, add:
    if (System.getSecurityManager() == null) {
    System.setSecurityManager(new RMISecurityManager());
    to the server's 'main' method.
    Then, at program startup, pass in a security policy file:
    java ... -Djava.security.policy=[<pathname>]security.policy [<classpath>]/<RMI server name>
    Where the file security.policy might contain:
    grant {
    // Allow everything for now
    permission java.security.AllPermission;
    Amoong other privileges.

  • Rmiregistry �J-Djava.rmi.server.codebase=URL

    Hi all,
    When starting the rmiregistry, I do the following:
    rmiregistry �J-Djava.rmi.server.codebase=URL
    Eager to understand what is going on, I read that this means the following:
    RMIClassLoader:
    For stubs and skeletons of remote objects created in the local virtual machine, the URL specified by the local java.rmi.server.codebase property is used.
    I thought "hey why not do the same for the server" and tried:
    java -Djava.rmi.server.codebase=URL Server
    getting me a StubNotFoundException. Can anybody tell me what I am doing wrong? The Server works when the Stub is in the local classpath but refuses to load it via the http Server. Am I at least theoretically right or is there a fundamental misconception in what I am trying?
    Thanks,
    Ralf

    RMI uses annotations to record codebase information. In addition to recording the class despriptions also records info about the location from which it loaded the classes bytecode. If you are trying to specify the codebase on the server and removing the stubs from the servers classpath the bytecode will never actually get loaded.

  • Java -Djava.rmi.server.codebase=file:///.....

    Cross posted in the hope that someone using it knows how....
    I am using the following command:
    java -Djava.rmi.server.codebase=file:///home/ben/fyp/build/ -Djava.security.policy=security.policy -cp ./lib/bcprov-jdk15-130.jar:./props:./build com.bensmyth.fyp.example.IssuerServer
    Can I specify -Djava.rmi.server.codebase=file:///home/ben/fyp/build/ without giving the whole path? Can I say ./build?

    I've come back to this issue again (since I am moving code around to different systems again). Using linux I can use -Djava.rmi.server.codebase=file://$PWD/build/
    Presumably there is a similar command in WIndows.

  • Dynamically changing java.rmi.server.hostname

    Hi all,
    I am trying to change the java.rmi.server.hostname value dynamically to force my rmi stubs to be exposed on a particular ip
    The java app is started with a default value of 172.30.30.200 for the java.rmi.server.hostname attribute using the -D parameter. Before the binding is done, I set the value of the java.rmi.server.hostname in the system properties to localhost and then call the rebind (code snippet below).
    After this, if I use a jndi browser, I do not see the entries for the localhost. However, I see the entries for 172.30.30.200.
    The release notes for 1.4.2 and 1.5.0 indicate that this attribute can be changed dynamically; does not say how though.
    http://java.sun.com/j2se/1.4/docs/guide/rmi/relnotes.html
    Can anyone give me an idea as to what is happenning.
    Thanks a lot for your help
    Properties currentProperties = System.
    String ipAddr = "localhost";
    currentProperties.put("java.rmi.server.hostname", ipAddr);
    System.setProperties(currentProperties);
    UnicastRemoteObject.exportObject(this);
    InitialContext ctx=new InitialContext();
    ctx.rebind(getObjectName().toString(), this);

    java.rmi.server.hostname should be set to whatever hostname or IP address the client should use when trying to connect to the server. It only needs to be set in JVMs which export remote objects, i.e. in server JVMs.

  • How to interpret rmi log msgs when setting -Djava.rmi.server.logCalls=true

    i have set this property: -Djava.rmi.server.logCalls=true
    now i am getting the following rmi log msgs on the console:
    Tue Nov 12 15:38:08 PST 2002:RMI:RMI TCP Connection(4851)-172.16.103.94:[172.16.103.94: sun.rmi.transport.DGCImpl[0:0:0, 2]: java.rmi.dgc.Lease dirty(java.rmi.server.ObjID[], long, java.rmi.dgc.Lease)]
    Tue Nov 12 15:38:13 PST 2002:RMI:RMI TCP Connection(4852)-127.0.0.1:[127.0.0.1: sun.rmi.registry.RegistryImpl[0:0:0, 0]: java.rmi.Remote lookup(java.lang.String)]
    Tue Nov 12 15:38:20 PST 2002:RMI:RMI TCP Connection(4853)-172.16.103.94:[172.16.103.94: sun.rmi.transport.DGCImpl[0:0:0, 2]: void clean(java.rmi.server.ObjID[], long,java.rmi.dgc.VMID, boolean)]
    can some one pls tell me know to interpret the messages, what does the number 4853 in TCP Connection(4853) mean ? thanks a lot

    Basically it is:
    date:subsystem:threadid:[remote object[object-id]:method]The 4853 is part of the thread-id and it is something like an instance number of the thread class.
    EJP

  • Spaces in -Djava.rmi.server.codebase path

    hello,
    how must i format the string containing the codebase for a rmi server if the path to the codebase contains spaces?
    -Djava.rmi.server.codebase=file:c:/path/ and -Djava.rmi.server.codebase=file:/path/ works, but
    -Djava.rmi.server.codebase=file:c:/path with spaces/ doesnt work
    i have tried to put the string in quotes and to replace the spaces with %20 (url encoded)
    but nothing does work.
    how must i format the string?
    cu,
    elmar

    I guess you are using a batch file to start your RMI application.
    Spaces in URLs must be encoded with %20, that is correct.
    The problem is: the command line interpreter on Windows interprets % as a special character and will replace it.
    What worked for me (Windows Vista):
    java -Djava.rmi.server.codebase="file:/C:/Users/FirstName%%20LastName/RMI/" App
    So encode each white space with %%20.
    You can very easily check by inserting the following code at the start of your RMI application. These lets you see how the codebase is set.
    System.out.println(" Codebase: " + System.getProperty("java.rmi.server.codebase"));

  • Java.rmi.server.hostname

    Hi,
    i am trying to figure out where this property comes into play. The docs say:
    "The value of this property represents the host name string that should be associated with remote stubs for locally created remote objects, in order to allow clients to invoke methods on the remote object. In 1.1.7 and later, the default value of this property is the IP address of the local host, in "dotted-quad" format."
    So i reverse engineered the stub to see if the value is inside the stub, but it isnt. I am asking because i want to run my RMI server program as a service and i dont want to define a static hostname property, because the server can be installed on several machines. Perhaps i can leave out this property completey and rely on defaults.
    So two questions remain to me:
    - Can i leave out this without getting into trouble?
    - Where is this propery used, obviously not in the stub.
    Thanks.
    marc

    Hi Marc,
    - Can i leave out this without getting into trouble?
    Possibly, see answer to your second question.
    - Where is this propery used, obviously not in the stub?
    The property is used primarily for one of two reasons, otherwise it is generally not necessary.
    1. If you have more than one network interface on a given machine, this property will specify which one to use.
    2. If you are behind a NAT router, this property will specify the actual address to use, outside the NAT subnet.
    Unspecified it will use the default network adapter address specified by your OS.
    Hope that was interesting :-)
    -John

  • Problem in starting RMI server, please help!

    Hi , all:
    I am learning RMI from SUN's tutorial. I set all of program packages as same as the tutorial, compiled all of programs . and built all of the jar files, the server classes and the client classes.When I run the server, ComputeEngine, it did not work ,and the following messages were showed at command lines:
    C:\RMI\doc>java -Djava.rmi.server.codebase=file:/c:\rmi\ann\public_html\classes/
    -Djava.rmi.server.hostname=localhost -Djava.security.policy=java.policy eng
    ine.ComputeEngine
    ComputeEngine exception: access denied (java.net.SocketPermission 127.0.0.1:1099
    connect,resolve)
    java.security.AccessControlException: access denied (java.net.SocketPermission 1
    27.0.0.1:1099 connect,resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlConte
    xt.java:272)
    at java.security.AccessController.checkPermission(AccessController.java:
    399)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
    at java.lang.SecurityManager.checkConnect(SecurityManager.java:1044)
    at java.net.Socket.<init>(Socket.java:262)
    at java.net.Socket.<init>(Socket.java:100)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
    SocketFactory.java:25)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
    SocketFactory.java:120)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318)
    at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
    at java.rmi.Naming.rebind(Naming.java:160)
    at engine.ComputeEngine.main(ComputeEngine.java:25)
    Please give helps .
    Thanks!

    Thank.
    Thank.
    I have put them at the same directory, but is deos not work.
    Something I am not sure.
    On the SUN's tutorial , the follows is given:
    Win32:
    java -Djava.rmi.server.codebase=file:/c:\home\ann\public_html\classes/
    -Djava.rmi.server.hostname=zaphod.east.sun.com
    -Djava.security.policy=java.policy
    engine.ComputeEngine
    I changed hostname = localhost
    I also changed the code of the server class given by tutorial :
    String name = "//host/Compute" ;
    to:
    String name = "//localhost/Compute";
    Should I make such changes?
    Here is the server class given by the tutorial:
    package engine;
    import java.rmi.*;
    import java.rmi.server.*;
    import compute.*;
    public class ComputeEngine extends UnicastRemoteObject
    implements Compute
    public ComputeEngine() throws RemoteException {
    super();
    public Object executeTask(Task t) {
    return t.execute();
    public static void main(String[] args) {
    if (System.getSecurityManager() == null) {
    System.setSecurityManager(new RMISecurityManager());
    String name = "//host/Compute";
    try {
    Compute engine = new ComputeEngine();
    Naming.rebind(name, engine);
    System.out.println("ComputeEngine bound");
    } catch (Exception e) {
    System.err.println("ComputeEngine exception: " +
    e.getMessage());
    e.printStackTrace();

  • Problem in starting RMI server, help please

    Hi , all:
    I am learning RMI from SUN's tutorial. I set all of program packages as same as the tutorial, compiled all of programs . and built all of the jar files, the server classes and the client classes.When I run the server, ComputeEngine, it did not work ,and the following messages are showed at command lines:
    C:\RMI\doc>java -Djava.rmi.server.codebase=file:/c:\rmi\ann\public_html\classes/
    -Djava.rmi.server.hostname=localhost -Djava.security.policy=java.policy eng
    ine.ComputeEngine
    ComputeEngine exception: access denied (java.net.SocketPermission 127.0.0.1:1099
    connect,resolve)
    java.security.AccessControlException: access denied (java.net.SocketPermission 1
    27.0.0.1:1099 connect,resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlConte
    xt.java:272)
    at java.security.AccessController.checkPermission(AccessController.java:
    399)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:545)
    at java.lang.SecurityManager.checkConnect(SecurityManager.java:1044)
    at java.net.Socket.<init>(Socket.java:262)
    at java.net.Socket.<init>(Socket.java:100)
    at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirect
    SocketFactory.java:25)
    at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMaster
    SocketFactory.java:120)
    at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:499)
    at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:190
    at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:174)
    at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:318)
    at sun.rmi.registry.RegistryImpl_Stub.rebind(Unknown Source)
    at java.rmi.Naming.rebind(Naming.java:160)
    at engine.ComputeEngine.main(ComputeEngine.java:25)
    Please give helps .
    Thanks!

    You are setting the security policy to the file named
    java.policy, make sure that it is in the same
    directory where you are invoking the java compiler.Thank.
    I have put them at the same directory, but is deos not work.
    Something I am not sure.
    On the SUN's tutorial , the follows is given:
    Win32:
    java -Djava.rmi.server.codebase=file:/c:\home\ann\public_html\classes/
    -Djava.rmi.server.hostname=zaphod.east.sun.com
    -Djava.security.policy=java.policy
    engine.ComputeEngine
    I changed hostname = localhost
    I also changed the code of the server class given by tutorial :
    String name = "//host/Compute" ;
    to:
    String name = "//localhost/Compute";
    Should I make such changes?
    Here is the server class given by the tutorial:
    package engine;
    import java.rmi.*;
    import java.rmi.server.*;
    import compute.*;
    public class ComputeEngine extends UnicastRemoteObject
    implements Compute
    public ComputeEngine() throws RemoteException {
    super();
    public Object executeTask(Task t) {
    return t.execute();
    public static void main(String[] args) {
    if (System.getSecurityManager() == null) {
    System.setSecurityManager(new RMISecurityManager());
    String name = "//host/Compute";
    try {
    Compute engine = new ComputeEngine();
    Naming.rebind(name, engine);
    System.out.println("ComputeEngine bound");
    } catch (Exception e) {
    System.err.println("ComputeEngine exception: " +
                   e.getMessage());
    e.printStackTrace();

  • RMI Server on MultiHome machine

    Dear all,
    I have a machine with two network interfaces (two IP addresses) , one IP address is "192.168.69.1" other is "192.168.70.1"(hostname is bind to this IP) , I am invoking this server's methods remotly using Client application that is running on "192.168.69.14", from the client machine only "192.168.69.1" is accessible and i have no access to IP "192.168.70.1".
    When i start rmi registry via rmiregistry command without giving any port number then program works fine.
    import java.rmi.registry.Registry;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;
    public class Server implements Hello {
        public Server() {}
        public String sayHello() {
            return "Hello, world!";
        public static void main(String args[]) {
            try {
                 //RMI hostname
              System.setProperty("java.rmi.server.hostname", "192.168.69.1");
                 Server obj = new Server();
                 Hello stub = (Hello) UnicastRemoteObject.exportObject(obj,0);
                 //Bind the remote object's stub in the registry
                 Registry registry = LocateRegistry.getRegistry();
                 registry.bind("Hello", stub);
                 System.err.println("Server ready");
             } catch (Exception e) {
                 System.err.println("Server exception: " + e.toString());
                 e.printStackTrace();
    }Client.java
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    public class Client {
        private Client() {}
        public static void main(String[] args) {
            String host = (args.length < 1) ? null : args[0];
            try {
                Registry registry = LocateRegistry.getRegistry(host);
                Hello stub = (Hello) registry.lookup("Hello");
                String response = stub.sayHello();
                System.out.println("response: " + response);
            } catch (Exception e) {
                System.err.println("Client exception: " + e.toString());
                e.printStackTrace();
    }Whenever i start rmiregistry on some specified port e.g. rmiregistry 6655 , and uses the server version that access the rmiregistry from specified port like blow
    import java.rmi.registry.Registry;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;
    public class Server implements Hello {
        public Server() {}
        public String sayHello() {
            return "Hello, world!";
        public static void main(String args[]) {
            try {
                 //RMI hostname
              System.setProperty("java.rmi.server.hostname", "192.168.69.1");
                 Server obj = new Server();
                 Hello stub = (Hello) UnicastRemoteObject.exportObject(obj,0);
                 //Bind the remote object's stub in the registry
                 Registry registry = LocateRegistry.getRegistry(6655);
                 registry.bind("Hello", stub);
                 System.err.println("Server ready");
             } catch (Exception e) {
                 System.err.println("Server exception: " + e.toString());
                 e.printStackTrace();
    }My Client application is unable to invoke remote Object
    I got following exception
    $ java Client 192.168.69.1
    Client exception: java.rmi.ConnectException: Connection refused to host: 192.168.69.1; nested exception is:
            java.net.ConnectException: Connection refused
    java.rmi.ConnectException: Connection refused to host: 192.168.69.1; nested exception is:
            java.net.ConnectException: Connection refused
            at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:574)
            at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
            at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
            at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:306)
            at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
            at Client.main(Client.java:15)
    Caused by: java.net.ConnectException: Connection refused
            at java.net.PlainSocketImpl.socketConnect(Native Method)
            at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
            at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
            at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
            at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
            at java.net.Socket.connect(Socket.java:516)
            at java.net.Socket.connect(Socket.java:466)
            at java.net.Socket.<init>(Socket.java:366)
            at java.net.Socket.<init>(Socket.java:179)
            at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
            at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
            at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:569)
            ... 5 moreKindly someone have idea to solve the problem ?
    Thanks

    did you try starting your rmiregistry with "-J-Djava.rmi.server.hostname=192.168.69.1" ?

  • RMI server behind firewall--must use host as name, not IP

    Server is running behind a firewall, which runs such that any machine behind the firewall cannot use the external IP to get back to itself.
    That is:
    - outside IP = 192.171.20.5 (port forwards 1099 to 192.168.1.5:1099)
    - inside IP = 192.168.1.5 (rmi server listens on 1099)
    from the machine inside (192.168.1.5), it is IMPOSSIBLE to create a socket to [outside ip](192.171.20.5), port 1099, and expect it to get back to the machine inside--the firewall prohibits this.
    I -can- use name-based lookups, such that I can edit the hosts file on the inside box to route (myhost.com to 192.168.1.5). So, if everyone's DNS resolves myhost.com -> 192.171.20.5, then clients anywhere can go to myhost.com:1099 and will be redirected to my internal machine (192.168.1.5:1099).
    The problem with this is that the names get translated to IPs and sent back to the client.
    Is there a way to keep the names as names, so that both client (using external real-world DNS entries) and server (using local hosts file) can both resolve to the proper IP addresses?
    I'm starting server, as follows:
    java -Djava.rmi.server.codebase=http://myhost.com/rmi/ -Djava.security.policy=/policypath/policy -Djava.rmi.server.hostname=myhost.com mypkg.myclass
    The client connects and gets this message (from a connection exception):
    java.rmi.ConnectException: Connection refused to host: 192.168.1.5;

    Server is running behind a firewall, which runs such
    that any machine behind the firewall cannot use the
    external IP to get back to itself.I dont really understand this statement.. Machines behind the firewall referring to the external ip would be going to the gateway, not themselves.. Or do you have an internal AND external ip on the machines behind the firewall? Or are we referring to the gateway machine as an internal machine as well as external?
    That is:
    - outside IP = 192.171.20.5 (port forwards 1099 to
    192.168.1.5:1099)
    - inside IP = 192.168.1.5 (rmi server listens on
    1099)looks good, what kinda OS/firewall? If we're talking linux/ipchains (or iptables) with ip masquerading, I may be of some use to you...
    from the machine inside (192.168.1.5), it is
    IMPOSSIBLE to create a socket to [outside
    ip](192.171.20.5), port 1099, and expect it to get
    back to the machine inside--the firewall prohibits
    this.If you're on the internal network, why can't you just go for the internal ip addr? If I'm understanding correctly, you want internal dns requests for myhost.com to resolve to 192.168.1.5, and external dns requests to resolve to 192.171.20.5? That should't be a problem...
    I -can- use name-based lookups, such that I can edit
    the hosts file on the inside box to route (myhost.com
    to 192.168.1.5). So, if everyone's DNS resolves
    myhost.com -> 192.171.20.5, then clients anywhere can
    go to myhost.com:1099 and will be redirected to my
    internal machine (192.168.1.5:1099).the hosts file has nothing to do with routing, it's simply a dns-type thing... If your dns is giving external users a 192.168 address as the ip for myhost.com, they will never get to it. 192.168 is not routable on the internet, i think most inet routes will drop packets from 192.168.x.x or 10.x.x.x.
    Is there a way to keep the names as names, so that
    both client (using external real-world DNS entries)
    and server (using local hosts file) can both resolve
    to the proper IP addresses?As long as your dns is working correctly, java doesn't care if you use ips or host names.. Hostnames are preferable, so when you change your network around, you wont affect your rmi server.
    I'm starting server, as follows:
    java -Djava.rmi.server.codebase=http://myhost.com/rmi/
    -Djava.security.policy=/policypath/policy
    -Djava.rmi.server.hostname=myhost.com mypkg.myclass
    The client connects and gets this message (from a
    connection exception):
    java.rmi.ConnectException: Connection refused to host:
    192.168.1.5;Is your server compiled with the 192.171 ip? That's not gonna work, you have to use the same IP the server is running on. I'm still not clear on your network layout, is 192.171.20.5 and 192.168.1.5 the 2 gateway ip's, or is 192.168.1.5 a physically different machine? I'd be willing to bet that your server is compiled with the external address, and if that's not the same machine, then there's no chance of that working....
    There's more than port forwarding going on.. IIRC, java rmi keeps track of its own ip's.. A client request to an external ip will not connect to a server running on the internal ip, even if you forward the port, rmi itself doesn't recognize the internal as the ip it's trying to get to (even if it is true), so it bombs out.. This can happen if you run the rmi server on a gateway, and compile the server with the external ip, and try to connect to the internal ip.. If you want external machines to connect, you MUST run the server on an external ip.
    Give a little more info, we'll getcha running... I'm also assuming you have full control of your network (ie, firewall/dns)
    doug

Maybe you are looking for