Does anyone know how to get an ip address from within ruby? I would like to
be able to grab both the ip of computer( the one assigned by my local
network ) and the ip to the outside world. Any help would be great.
Does anyone know how to get an ip address from within ruby? I would like to
be able to grab both the ip of computer( the one assigned by my local
network ) and the ip to the outside world. Any help would be great.
Does anyone know how to get an ip address from within ruby? I would like to
be able to grab both the ip of computer( the one assigned by my local
network ) and the ip to the outside world. Any help would be great.
This answered your first question about your local system. The above works on window, but on unix systems this will return whatever is setup in your /etc/hosts file for your hostname. If you want to resolve IP by dns, then look into using the Resolv library from the standard library...
To your second question. What is your ip to the outside world? Are you referring to the ip address on your router? Or do you have multiple ip addresses assigned to your local system?
Does anyone know how to get an ip address from within ruby? I would like to
be able to grab both the ip of computer( the one assigned by my local
network ) and the ip to the outside world. Any help would be great.
This answered your first question about your local system. The above works on window, but on unix systems this will return whatever is setup in your /etc/hosts file for your hostname. If you want to resolve IP by dns, then look into using the Resolv library from the standard library...
To your second question. What is your ip to the outside world? Are you referring to the ip address on your router? Or do you have multiple ip addresses assigned to your local system?
Does anyone know how to get an ip address from within ruby? I would like to
be able to grab both the ip of computer( the one assigned by my local
network ) and the ip to the outside world. Any help would be great.
This answered your first question about your local system. The above works on window, but on unix systems this will return whatever is setup in your /etc/hosts file for your hostname. If you want to resolve IP by dns, then look into using the Resolv library from the standard library...
To your second question. What is your ip to the outside world? Are you referring to the ip address on your router? Or do you have multiple ip addresses assigned to your local system?
I know you can use services like dyndns.org and no-ip.com to pick your own domain name. You run a service on your local machine and it updates the dns information. For example I can query 'myname.no-ip.com' using the Resolv library to get my public ip address on the WAN side of my home router/firewall...