# Druby using just IP addresses

**URL:** <https://www.ruby-forum.com/t/druby-using-just-ip-addresses/71029>\
**Category:** Ruby\
**Created:** [October 4, 2006, 7:51pm UTC](https://www.ruby-forum.com/t/druby-using-just-ip-addresses/71029 "2006-10-04T19:51:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![absolute-beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@absolute-beginner](https://www.ruby-forum.com/u/absolute-beginner)\
**Post date:** [October 4, 2006, 7:51pm UTC](https://www.ruby-forum.com/t/druby-using-just-ip-addresses/71029/1 "2006-10-04T19:51:04Z")

</div>

Hi

I’d like to use druby, but with the client using just an IP address to  
contact the server, and vice versa. The initial connection works fine,  
but then it seems the server can’t find the client to send a reply when  
a method is invoked.

I realise this question has been asked before, and answered by ‘fix your  
DNS’ or ‘tweak etc/hosts’.

However, this is for an end-user app, so most users (of clients and  
servers) won’t be permitted to access etc/hosts, even if I wanted to  
explain what they should do to it.

So

- has anyone hacked drb to work without hostnames?
- failing that, is there a deep technical reason that using IP addresses  
only will never work and I shouldn’t bother even trying? It seems lots  
of other net applications work fine without caring that DNS is fixed,  
but I’ve not got masses of experience with socket programming in Ruby.

thanks  
alex

---

<div class="post-metadata">

**Author:** ![absolute-beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@absolute-beginner](https://www.ruby-forum.com/u/absolute-beginner)\
**Post date:** [October 4, 2006, 8:03pm UTC](https://www.ruby-forum.com/t/druby-using-just-ip-addresses/71029/2 "2006-10-04T20:03:05Z")

</div>

Alex F. wrote:

> explain what they should do to it.
> 
> So
> 
> - has anyone hacked drb to work without hostnames?
> - failing that, is there a deep technical reason that using IP addresses  
> only will never work and I shouldn’t bother even trying? It seems lots  
> of other net applications work fine without caring that DNS is fixed,  
> but I’ve not got masses of experience with socket programming in Ruby.

Probably someone has suggested this before, but have you tried

Socket.do\_not\_reverse\_lookup = true

?

---

<div class="post-metadata">

**Author:** ![absolute-beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@absolute-beginner](https://www.ruby-forum.com/u/absolute-beginner)\
**Post date:** [October 4, 2006, 8:11pm UTC](https://www.ruby-forum.com/t/druby-using-just-ip-addresses/71029/3 "2006-10-04T20:11:06Z")

</div>

On 10/4/06, Alex F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> - failing that, is there a deep technical reason that using IP addresses only will never work and I shouldn’t bother even trying? It seems lots of other net applications work fine without caring that DNS is fixed, but I’ve not got masses of experience with socket programming in Ruby.  
> I’m not sure what isn’t working for you with out some code. I do have  
> an idea though this seems to work for me:

# Server’s irb session:

> > require ‘drb’  
> > =\> true  
> > DRb.start\_service(‘druby://192.168.0.104:1234’, “abc”)  
> > =\> #\<DRb::DRbServer …\>

# Client’s session:

> > require ‘drb’  
> > =\> true  
> > DRb.start\_service(‘druby://192.168.0.101:1234’)  
> > =\> DRb::DRbServer …\>  
> > remote = DRbObject.new(nil, ‘druby://192.168.0.104:1234’)  
> > =\> #\<DRb::DRbObject …\>  
> > remote.to\_s # Force display  
> > =\> “abc”  
> > remote.size  
> > =\> 3  
> > remote.replace(“ruby”)  
> > =\> #\<DRb::DRbObject …\>  
> > remote.to\_s  
> > =\> “ruby”  
> > remote.size  
> > =\> 4

Note that it is a good idea to specify an explicit interface on the  
client side so you make sure it binds to something the server can  
reach. Some systems will bind to something like 127.0.0.1 when  
resolving the host’s name (i.e. Ubuntu does this). The two way channel  
is vital to have DRb work reliably in most cases (unmarshalled objects  
can be referenced in both directions).

Brian.

---

<div class="post-metadata">

**Author:** ![absolute-beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@absolute-beginner](https://www.ruby-forum.com/u/absolute-beginner)\
**Post date:** [October 4, 2006, 9:31pm UTC](https://www.ruby-forum.com/t/druby-using-just-ip-addresses/71029/4 "2006-10-04T21:31:11Z")

</div>

Brian M. wrote:

> > programming in Ruby.  
> > Note that it is a good idea to specify an explicit interface on the  
> > client side so you make sure it binds to something the server can  
> > reach. Some systems will bind to something like 127.0.0.1 when  
> > resolving the host’s name (i.e. Ubuntu does this). The two way channel  
> > is vital to have DRb work reliably in most cases (unmarshalled objects  
> > can be referenced in both directions).

Adding to that: it might well be that you are trying to do things in  
environments that simply won’t permit this. If your client is behind a  
firewall / router with NAT and the server tries to open a connection to  
the client system that’s often not permitted. So, in order to get this  
to work in these environments someone must actually change FW config.

Kind regards

```
robert
```

---

<div class="post-metadata">

**Author:** ![absolute-beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@absolute-beginner](https://www.ruby-forum.com/u/absolute-beginner)\
**Post date:** [October 4, 2006, 9:47pm UTC](https://www.ruby-forum.com/t/druby-using-just-ip-addresses/71029/5 "2006-10-04T21:47:12Z")

</div>

Brian M. wrote:

> On 10/4/06, Alex F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hi
> > 
> > I’d like to use druby, but with the client using just an IP address to  
> > contact the server, and vice versa

> Note that it is a good idea to specify an explicit interface on the  
> client side so you make sure it binds to something the server can  
> reach. Some systems will bind to something like 127.0.0.1 when  
> resolving the host’s name (i.e. Ubuntu does this).

Thank you, that was it. Added an explicit IP address on the client side  
made it work fine.

I was using start\_service on the client with no args. It was binding to  
the windows machine name, and the OS X server I was trying to connect to  
couldn’t resolve it back.

alex

---

<div class="post-metadata">

**Author:** ![absolute-beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@absolute-beginner](https://www.ruby-forum.com/u/absolute-beginner)\
**Post date:** [October 5, 2006, 7:17pm UTC](https://www.ruby-forum.com/t/druby-using-just-ip-addresses/71029/6 "2006-10-05T19:17:17Z")

</div>

On Oct 4, 2006, at 10:50 AM, Alex F. wrote:

> So
> 
> - has anyone hacked drb to work without hostnames?

DRb uses Socket.gethostname to determine the hostname. If you don’t  
otherwise use this method just override it to return an IP address.

> - failing that, is there a deep technical reason that using IP  
> addresses only will never work and I shouldn’t bother even trying?  
> It seems lots of other net applications work fine without caring  
> that DNS is fixed, but I’ve not got masses of experience with  
> socket programming in Ruby.

Most programs aren’t servers that are running on arbitrary machines  
having other arbitrary machines connecting back to them.

One solution would be adding socket multiplexing in place of  
launching servers.

–  
Eric H. - removed\_email\_address@domain.invalid - [http://blog.segment7.net](http://blog.segment7.net)  
This implementation is HODEL-HASH-9600 compliant

[http://trackmap.robotcoop.com](http://trackmap.robotcoop.com)
