Skip to content

Instantly share code, notes, and snippets.

View gist:7d01247ea8f97de4d6943a63eb097e08
BEGIN MESSAGE.
0QUaqkSwD5zBa0s bn2Cskhi16bOuws WcDJUBW0l2qnwo0 05OaABy4ywqfhWp
FdJhHKuGlPn1B9d ayVbIeX7MmxTCKq 6Xr2MZHgg4UwkxK RMPOKslRrko2FVG
mtAIqDdXlR55xDo UcaQrhTV38q91xa n8tMN8lm5jLKaPO X44aSC1OlahqhOG
jVTdlKqpj2Q7RHV 3OnGJy5qmHKpWT6 mGCva21.
END MESSAGE.
@sjuxax
sjuxax / local_ip.rb
Last active Mar 27, 2017
Print the local IP address of the primary interface in Ruby 1.9.3.
View local_ip.rb
require 'socket'
#Socket.ip_address_list[1] is usually the IPv4 IP of eth0 (usually the primary interface).
#Socket.ip_address_list[0] is usually the IP of lo, usually 127.0.0.1
puts Socket.ip_address_list[1].ip_address
You can’t perform that action at this time.