title: which hostname or ip is java rmi bind in linux?
body: <p>i am new with java rmi. And i have a question about rmi usage.<br />
  Firstly, i created a server with port(the interface only has a port argument).</p>
  <pre class="lang-java prettyprint-override"><code>this.registry = LocateRegistry.createRegistry(1099);
  </code></pre>
  <p>Then i bind a server like this:</p>
  <pre class="lang-java prettyprint-override"><code>
  public interface MyRmiService extends Remote {
      // return &quot;service name&quot; for example
      String getName() throws RemoteException;
  }
  
   public void register(MyRmiService service) {
          try {
              this.registry.rebind(syncDataService.getName(), service);
          } catch (RemoteException var3) {
              FineLoggerFactory.getLogger().error(var3.getMessage(), var3);
          }
  
  }
  </code></pre>
  <p>and my client code is like this:</p>
  <pre class="lang-java prettyprint-override"><code>// linux ip
  Registry tempRegistry = LocateRegistry.getRegistry(ip, 1099);
  MyRmiService service = (MyRmiService)tempRegistry.lookup(&quot;service name&quot;);
  
  </code></pre>
  <p>These code looks fine if my machine ip looks the same with linux shell:</p>
  <pre><code>[root@node26 ~]# hostname
  node26
  [root@node26 ~]# hostname -i
  192.168.101.26
  [root@node26 ~]# hostname -I
  192.168.101.26 192.168.122.1 172.17.0.1 
  </code></pre>
  <p>if i use 192.168.101.26 as ip.<br />
  But if i get some different ip like this:</p>
  <pre><code># for example
  [root@a ~]# hostname -I
  172.16.5.199 172.17.0.1 
  [root@iZbp124z80qrl3rd8pk42xZ ~]# hostname -i
  10.162.107.99
  [root@iZbp124z80qrl3rd8pk42xZ ~]# hostname
  iZbp124z80qrl3rd8pk42xZ
  </code></pre>
  <p>It doesn't work fine and stuck in the client finding service with <code>lookup</code>.<br />
  Normally i want to use <code>172.16.5.199</code> as ip. But maybe rmi is using <code>10.162.107.99</code> which i cannot ping from client. Is this linux server has the right hostname config?<br />
  Then I'm confused.</p>
  <ol>
  <li>which hostname or ip is used when <code>LocateRegistry.createRegistry(1099);</code> called?</li>
  <li>which hostname or ip is used when <code>registry.rebind(syncDataService.getName(), service);</code>called?</li>
  <li>which ip should i use to call <code>LocateRegistry.getRegistry(ip, 1099);</code> ?
  My question is, what exactly the ip should i use?</li>
  </ol>