I am doing Rails development in Ubuntu 12.04LTS OS.
I want to capture my local IP address in a file, not the loopback 127.0.0.1, the one which I get using ifconfig
. Please suggest a solution.
I am doing Rails development in Ubuntu 12.04LTS OS.
I want to capture my local IP address in a file, not the loopback 127.0.0.1, the one which I get using ifconfig
. Please suggest a solution.
This is my first way:
This is my second way, which is not recommended:
The third way:
And a fourth way:
Write below method
and then call local_ip method, you will get ip address of your machine.
Use Socket::ip_address_list.