Ruby - Platform independent way to determine IPs of all network interfaces?

后端 未结 3 1982
难免孤独
难免孤独 2021-02-09 06:26

Is there an easy way in Ruby for me to get a list of the IP addresses for all network interfaces? It needs to work in Linux/Win/OSX and I\'d prefer to not have to parse ifconfi

3条回答
  •  难免孤独
    2021-02-09 07:06

    Check out the following post:

    http://coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/

    There's also a discussion on the solution anshul posted in the comments.

提交回复
热议问题