Bash script to get all IP addresses

后端 未结 12 2418
-上瘾入骨i
-上瘾入骨i 2020-12-28 22:51

I am trying to write a bash script to get all IP addresses on a server. The script should work on all major distros. Here is what I have:

ifconf         


        
12条回答
  •  滥情空心
    2020-12-28 23:20

    I would to introduce you to a command-line tool called OSQuery by Facebook which helps you get system info by making SQL-like queries. For your case for instance, you would have enter;

    osquery> select * from interface_addresses; 
    

    Which would output something like;

    interface = wlan0
           address = 192.168.0.101
              mask = 255.255.255.0
         broadcast = 192.168.0.255
    point_to_point = 
    

    Which I find a lot more neat and convenient.

提交回复
热议问题