Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

Socket.ip_address_list

() -> ::Array[::Addrinfo]
Socket.ip_address_list => array

Returns local IP addresses as an array.

The array contains Addrinfo objects.

pp Socket.ip_address_list
#=> [#<Addrinfo: 127.0.0.1>,
     #<Addrinfo: 192.168.0.128>,
     #<Addrinfo: ::1>,
     ...]